io.protostuff.Input类的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(283)

本文整理了Java中io.protostuff.Input类的一些代码示例,展示了Input类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Input类的具体详情如下:
包路径:io.protostuff.Input
类名称:Input

Input介绍

[英]An Input lets an application read primitive data types and objects from a source of data.
[中]输入允许应用程序从数据源读取基本数据类型和对象。

代码示例

代码示例来源:origin: protostuff/protostuff

@Override
  protected void transfer(Pipe pipe, Input input, Output output)
      throws IOException
  {
    for (int number = input.readFieldNumber(wrappedSchema); number != 0; number = input
        .readFieldNumber(wrappedSchema))
    {
      final Field<T> field = fieldsMap.getFieldByNumber(number);
      if (field == null)
        input.handleUnknownField(number, wrappedSchema);
      else
        field.transfer(pipe, input, output, field.repeated);
    }
  }
}

代码示例来源:origin: protostuff/protostuff

@Override
public String readString() throws IOException
{
  return input.readString();
}

代码示例来源:origin: protostuff/protostuff

public void mergeFrom(Input input, A message) throws IOException
{
  for(int number = input.readFieldNumber(this);; number = input.readFieldNumber(this))
  {
    switch(number)
    {
      case 0:
        return;
      case 1:
        message.value = input.readInt32();
        break;
      default:
        input.handleUnknownField(number, this);
    }   
  }
}

代码示例来源:origin: protostuff/protostuff

for (int number = input.readFieldNumber(this);; number = input.readFieldNumber(this))
      return;
    case 1:
      message.someInt = input.readInt32();
      break;
    case 2:
      message.someString = input.readString();
      break;
    case 3:
      message.someBaz = input.mergeObject(message.someBaz, Baz.getSchema());
      break;
    case 4:
      message.someEnum = Status.valueOf(input.readEnum());
      break;
    case 5:
      message.someBytes = input.readBytes();
      break;
    case 6:
      message.someBoolean = input.readBool();
      break;
    case 7:
      message.someFloat = input.readFloat();
      break;
    case 8:
      message.someDouble = input.readDouble();
      break;
    case 9:
      message.someLong = input.readInt64();

代码示例来源:origin: protostuff/protostuff

@Override
public Object readFrom(Input input, Object owner) throws IOException
{
  if (ID_ARRAY_LEN != input.readFieldNumber(this))
    throw new ProtostuffException("Corrupt input.");
  final int len = input.readInt32();
  return primitive ? readPrimitiveFrom(input, owner, len) : 
      readBoxedFrom(input, owner, len);
}

代码示例来源:origin: protostuff/protostuff

@Override
public void mergeFrom(Input input, Baz message) throws IOException
{
  for (int number = input.readFieldNumber(this);; number = input.readFieldNumber(this))
  {
    switch (number)
    {
      case 0:
        return;
      case 1:
        message.id = input.readInt32();
        break;
      case 2:
        message.name = input.readString();
        break;
      case 3:
        message.timestamp = input.readInt64();
        break;
      default:
        input.handleUnknownField(number, this);
    }
  }
}

代码示例来源:origin: protostuff/protostuff

@Override
public void mergeFrom(Input input, PojoWithBiggerByteArray message) throws IOException
{
  for (int number = input.readFieldNumber(this);; number = input.readFieldNumber(this))
  {
    switch (number)
    {
      case 0:
        return;
      case 1:
        message.id = input.readInt32();
        break;
      case 2:
        message.b = input.readByteArray();
        break;
      case 3:
        message.ts = input.readInt64();
        break;
      default:
        input.handleUnknownField(number, this);
    }
  }
}

代码示例来源:origin: protostuff/protostuff

@Override
public void mergeFrom(Input input, ClubFounder message) throws IOException
{
  for (int number = input.readFieldNumber(this);; number = input.readFieldNumber(this))
  {
    switch (number)
    {
      case 0:
        return;
      case 1:
        message.name = input.readString();
        break;
      case 2:
        message.club = input.mergeObject(message.club, Club.getSchema());
        break;
      default:
        input.handleUnknownField(number, this);
    }
  }
}

代码示例来源:origin: protostuff/protostuff

public void mergeFrom(Input input, SampleClass message) throws IOException
{
  for (int number = input.readFieldNumber(this);; number = input.readFieldNumber(this))
  {
    switch (number)
    {
      case 0:
        return;
      case 1:
        if (message.testString == null)
          message.testString = new ArrayList<String>();
        message.testString.add(input.readString());
        break;
      default:
        input.handleUnknownField(number, this);
    }
  }
}

代码示例来源:origin: protostuff/protostuff

@Override
public Object readFrom(Input input, Object owner) throws IOException
{
  if (ID_ARRAY_LEN != input.readFieldNumber(this))
    throw new ProtostuffException("Corrupt input.");
  final int len = input.readInt32();
  ByteString[] array = new ByteString[len];
  if (input instanceof GraphInput)
  {
    // update the actual reference.
    ((GraphInput) input).updateLast(array, owner);
  }
  for (int i = 0; i < len;)
  {
    switch (input.readFieldNumber(this))
    {
      case ID_ARRAY_DATA:
        array[i++] = input.readBytes();
        break;
      case ID_ARRAY_NULLCOUNT:
        i += input.readUInt32();
        break;
      default:
        throw new ProtostuffException("Corrupt input.");
    }
  }
  if (0 != input.readFieldNumber(this))
    throw new ProtostuffException("Corrupt input.");
  return array;
}

代码示例来源:origin: protostuff/protostuff

@Override
public void mergeFrom(Input input, FPNumbers message) throws IOException
{
  for (int number = input.readFieldNumber(this); ; number = input.readFieldNumber(this))
  {
    switch (number)
    {
      case 0:
        return;
      case 1:
        message.floatValue = input.readFloat();
        break;
      case 2:
        message.doubleValue = input.readDouble();
        break;
      default:
        input.handleUnknownField(number, this);
    }
  }
}

代码示例来源:origin: protostuff/protostuff

@Override
public void mergeFrom(Input input, WrapperPojo message) throws IOException
{
  for (int number = input.readFieldNumber(this);; number = input.readFieldNumber(this))
  {
    switch (number)
    {
      case 0:
        return;
      case 1:
        message.requiresName = input.mergeObject(message.requiresName, RequiresName.SCHEMA);
        break;
      default:
        input.handleUnknownField(number, this);
    }
  }
}

代码示例来源:origin: protostuff/protostuff

@Override
public void mergeFrom(Input input, Bat message) throws IOException
{
  for (int number = input.readFieldNumber(this);; number = input
      .readFieldNumber(this))
  {
    switch (number)
    {
      case 0:
        return;
      case 1:
        message.id = input.readUInt32();
        break;
      default:
        input.handleUnknownField(number, this);
    }
  }
}

代码示例来源:origin: protostuff/protostuff

protected Object readBoxedFrom(Input input, Object owner, int len)
    throws IOException
{
  final Boolean[] array = new Boolean[len];
  if (input instanceof GraphInput)
  {
    // update the actual reference.
    ((GraphInput) input).updateLast(array, owner);
  }
  for (int i = 0; i < len;)
  {
    switch (input.readFieldNumber(this))
    {
      case ID_ARRAY_DATA:
        array[i++] = input.readBool();
        break;
      case ID_ARRAY_NULLCOUNT:
        i += input.readUInt32();
        break;
      default:
        throw new ProtostuffException("Corrupt input.");
    }
  }
  if (0 != input.readFieldNumber(this))
    throw new ProtostuffException("Corrupt input.");
  return array;
}

代码示例来源:origin: protostuff/protostuff

protected Object readBoxedFrom(Input input, Object owner, int len)
    throws IOException
{
  final Double[] array = new Double[len];
  if (input instanceof GraphInput)
  {
    // update the actual reference.
    ((GraphInput) input).updateLast(array, owner);
  }
  for (int i = 0; i < len;)
  {
    switch (input.readFieldNumber(this))
    {
      case ID_ARRAY_DATA:
        array[i++] = input.readDouble();
        break;
      case ID_ARRAY_NULLCOUNT:
        i += input.readUInt32();
        break;
      default:
        throw new ProtostuffException("Corrupt input.");
    }
  }
  if (0 != input.readFieldNumber(this))
    throw new ProtostuffException("Corrupt input.");
  return array;
}

代码示例来源:origin: protostuff/protostuff

static void transferObject(Pipe.Schema<Object> pipeSchema, Pipe pipe,
    Input input, Output output, IdStrategy strategy) throws IOException
{
  transferObject(pipeSchema, pipe, input, output, strategy, 
      input.readFieldNumber(pipeSchema.wrappedSchema));
}

代码示例来源:origin: protostuff/protostuff

protected Object readBoxedFrom(Input input, Object owner, int len)
    throws IOException
{
  final Long[] array = new Long[len];
  if (input instanceof GraphInput)
  {
    // update the actual reference.
    ((GraphInput) input).updateLast(array, owner);
  }
  for (int i = 0; i < len;)
  {
    switch (input.readFieldNumber(this))
    {
      case ID_ARRAY_DATA:
        array[i++] = input.readInt64();
        break;
      case ID_ARRAY_NULLCOUNT:
        i += input.readUInt32();
        break;
      default:
        throw new ProtostuffException("Corrupt input.");
    }
  }
  if (0 != input.readFieldNumber(this))
    throw new ProtostuffException("Corrupt input.");
  return array;
}

代码示例来源:origin: protostuff/protostuff

@Override
protected Object kFrom(Input input,
    MapWrapper<Object, Object> wrapper) throws IOException
{
  return input.mergeObject(null, schemaK.getSchema());
}

代码示例来源:origin: protostuff/protostuff

protected Object readPrimitiveFrom(Input input, Object owner, int len)
    throws IOException
{
  long[] array = new long[len];
  if (input instanceof GraphInput)
  {
    // update the actual reference.
    ((GraphInput) input).updateLast(array, owner);
  }
  for (int i = 0; i < len; i++)
  {
    if (ID_ARRAY_DATA != input.readFieldNumber(this))
      throw new ProtostuffException("Corrupt input.");
    array[i] = input.readInt64();
  }
  if (0 != input.readFieldNumber(this))
    throw new ProtostuffException("Corrupt input.");
  return array;
}

代码示例来源:origin: protostuff/protostuff

protected Object readPrimitiveFrom(Input input, Object owner, int len)
    throws IOException
{
  boolean[] array = new boolean[len];
  if (input instanceof GraphInput)
  {
    // update the actual reference.
    ((GraphInput) input).updateLast(array, owner);
  }
  for (int i = 0; i < len; i++)
  {
    if (ID_ARRAY_DATA != input.readFieldNumber(this))
      throw new ProtostuffException("Corrupt input.");
    array[i] = input.readBool();
  }
  if (0 != input.readFieldNumber(this))
    throw new ProtostuffException("Corrupt input.");
  return array;
}

相关文章