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

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

本文整理了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

  1. @Override
  2. protected void transfer(Pipe pipe, Input input, Output output)
  3. throws IOException
  4. {
  5. for (int number = input.readFieldNumber(wrappedSchema); number != 0; number = input
  6. .readFieldNumber(wrappedSchema))
  7. {
  8. final Field<T> field = fieldsMap.getFieldByNumber(number);
  9. if (field == null)
  10. input.handleUnknownField(number, wrappedSchema);
  11. else
  12. field.transfer(pipe, input, output, field.repeated);
  13. }
  14. }
  15. }

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

  1. @Override
  2. public String readString() throws IOException
  3. {
  4. return input.readString();
  5. }

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

  1. public void mergeFrom(Input input, A message) throws IOException
  2. {
  3. for(int number = input.readFieldNumber(this);; number = input.readFieldNumber(this))
  4. {
  5. switch(number)
  6. {
  7. case 0:
  8. return;
  9. case 1:
  10. message.value = input.readInt32();
  11. break;
  12. default:
  13. input.handleUnknownField(number, this);
  14. }
  15. }
  16. }

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

  1. for (int number = input.readFieldNumber(this);; number = input.readFieldNumber(this))
  2. return;
  3. case 1:
  4. message.someInt = input.readInt32();
  5. break;
  6. case 2:
  7. message.someString = input.readString();
  8. break;
  9. case 3:
  10. message.someBaz = input.mergeObject(message.someBaz, Baz.getSchema());
  11. break;
  12. case 4:
  13. message.someEnum = Status.valueOf(input.readEnum());
  14. break;
  15. case 5:
  16. message.someBytes = input.readBytes();
  17. break;
  18. case 6:
  19. message.someBoolean = input.readBool();
  20. break;
  21. case 7:
  22. message.someFloat = input.readFloat();
  23. break;
  24. case 8:
  25. message.someDouble = input.readDouble();
  26. break;
  27. case 9:
  28. message.someLong = input.readInt64();

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

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

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

  1. @Override
  2. public void mergeFrom(Input input, Baz message) throws IOException
  3. {
  4. for (int number = input.readFieldNumber(this);; number = input.readFieldNumber(this))
  5. {
  6. switch (number)
  7. {
  8. case 0:
  9. return;
  10. case 1:
  11. message.id = input.readInt32();
  12. break;
  13. case 2:
  14. message.name = input.readString();
  15. break;
  16. case 3:
  17. message.timestamp = input.readInt64();
  18. break;
  19. default:
  20. input.handleUnknownField(number, this);
  21. }
  22. }
  23. }

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

  1. @Override
  2. public void mergeFrom(Input input, PojoWithBiggerByteArray message) throws IOException
  3. {
  4. for (int number = input.readFieldNumber(this);; number = input.readFieldNumber(this))
  5. {
  6. switch (number)
  7. {
  8. case 0:
  9. return;
  10. case 1:
  11. message.id = input.readInt32();
  12. break;
  13. case 2:
  14. message.b = input.readByteArray();
  15. break;
  16. case 3:
  17. message.ts = input.readInt64();
  18. break;
  19. default:
  20. input.handleUnknownField(number, this);
  21. }
  22. }
  23. }

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

  1. @Override
  2. public void mergeFrom(Input input, ClubFounder message) throws IOException
  3. {
  4. for (int number = input.readFieldNumber(this);; number = input.readFieldNumber(this))
  5. {
  6. switch (number)
  7. {
  8. case 0:
  9. return;
  10. case 1:
  11. message.name = input.readString();
  12. break;
  13. case 2:
  14. message.club = input.mergeObject(message.club, Club.getSchema());
  15. break;
  16. default:
  17. input.handleUnknownField(number, this);
  18. }
  19. }
  20. }

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

  1. public void mergeFrom(Input input, SampleClass message) throws IOException
  2. {
  3. for (int number = input.readFieldNumber(this);; number = input.readFieldNumber(this))
  4. {
  5. switch (number)
  6. {
  7. case 0:
  8. return;
  9. case 1:
  10. if (message.testString == null)
  11. message.testString = new ArrayList<String>();
  12. message.testString.add(input.readString());
  13. break;
  14. default:
  15. input.handleUnknownField(number, this);
  16. }
  17. }
  18. }

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

  1. @Override
  2. public Object readFrom(Input input, Object owner) throws IOException
  3. {
  4. if (ID_ARRAY_LEN != input.readFieldNumber(this))
  5. throw new ProtostuffException("Corrupt input.");
  6. final int len = input.readInt32();
  7. ByteString[] array = new ByteString[len];
  8. if (input instanceof GraphInput)
  9. {
  10. // update the actual reference.
  11. ((GraphInput) input).updateLast(array, owner);
  12. }
  13. for (int i = 0; i < len;)
  14. {
  15. switch (input.readFieldNumber(this))
  16. {
  17. case ID_ARRAY_DATA:
  18. array[i++] = input.readBytes();
  19. break;
  20. case ID_ARRAY_NULLCOUNT:
  21. i += input.readUInt32();
  22. break;
  23. default:
  24. throw new ProtostuffException("Corrupt input.");
  25. }
  26. }
  27. if (0 != input.readFieldNumber(this))
  28. throw new ProtostuffException("Corrupt input.");
  29. return array;
  30. }

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

  1. @Override
  2. public void mergeFrom(Input input, FPNumbers message) throws IOException
  3. {
  4. for (int number = input.readFieldNumber(this); ; number = input.readFieldNumber(this))
  5. {
  6. switch (number)
  7. {
  8. case 0:
  9. return;
  10. case 1:
  11. message.floatValue = input.readFloat();
  12. break;
  13. case 2:
  14. message.doubleValue = input.readDouble();
  15. break;
  16. default:
  17. input.handleUnknownField(number, this);
  18. }
  19. }
  20. }

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

  1. @Override
  2. public void mergeFrom(Input input, WrapperPojo message) throws IOException
  3. {
  4. for (int number = input.readFieldNumber(this);; number = input.readFieldNumber(this))
  5. {
  6. switch (number)
  7. {
  8. case 0:
  9. return;
  10. case 1:
  11. message.requiresName = input.mergeObject(message.requiresName, RequiresName.SCHEMA);
  12. break;
  13. default:
  14. input.handleUnknownField(number, this);
  15. }
  16. }
  17. }

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

  1. @Override
  2. public void mergeFrom(Input input, Bat message) throws IOException
  3. {
  4. for (int number = input.readFieldNumber(this);; number = input
  5. .readFieldNumber(this))
  6. {
  7. switch (number)
  8. {
  9. case 0:
  10. return;
  11. case 1:
  12. message.id = input.readUInt32();
  13. break;
  14. default:
  15. input.handleUnknownField(number, this);
  16. }
  17. }
  18. }

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

  1. protected Object readBoxedFrom(Input input, Object owner, int len)
  2. throws IOException
  3. {
  4. final Boolean[] array = new Boolean[len];
  5. if (input instanceof GraphInput)
  6. {
  7. // update the actual reference.
  8. ((GraphInput) input).updateLast(array, owner);
  9. }
  10. for (int i = 0; i < len;)
  11. {
  12. switch (input.readFieldNumber(this))
  13. {
  14. case ID_ARRAY_DATA:
  15. array[i++] = input.readBool();
  16. break;
  17. case ID_ARRAY_NULLCOUNT:
  18. i += input.readUInt32();
  19. break;
  20. default:
  21. throw new ProtostuffException("Corrupt input.");
  22. }
  23. }
  24. if (0 != input.readFieldNumber(this))
  25. throw new ProtostuffException("Corrupt input.");
  26. return array;
  27. }

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

  1. protected Object readBoxedFrom(Input input, Object owner, int len)
  2. throws IOException
  3. {
  4. final Double[] array = new Double[len];
  5. if (input instanceof GraphInput)
  6. {
  7. // update the actual reference.
  8. ((GraphInput) input).updateLast(array, owner);
  9. }
  10. for (int i = 0; i < len;)
  11. {
  12. switch (input.readFieldNumber(this))
  13. {
  14. case ID_ARRAY_DATA:
  15. array[i++] = input.readDouble();
  16. break;
  17. case ID_ARRAY_NULLCOUNT:
  18. i += input.readUInt32();
  19. break;
  20. default:
  21. throw new ProtostuffException("Corrupt input.");
  22. }
  23. }
  24. if (0 != input.readFieldNumber(this))
  25. throw new ProtostuffException("Corrupt input.");
  26. return array;
  27. }

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

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

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

  1. protected Object readBoxedFrom(Input input, Object owner, int len)
  2. throws IOException
  3. {
  4. final Long[] array = new Long[len];
  5. if (input instanceof GraphInput)
  6. {
  7. // update the actual reference.
  8. ((GraphInput) input).updateLast(array, owner);
  9. }
  10. for (int i = 0; i < len;)
  11. {
  12. switch (input.readFieldNumber(this))
  13. {
  14. case ID_ARRAY_DATA:
  15. array[i++] = input.readInt64();
  16. break;
  17. case ID_ARRAY_NULLCOUNT:
  18. i += input.readUInt32();
  19. break;
  20. default:
  21. throw new ProtostuffException("Corrupt input.");
  22. }
  23. }
  24. if (0 != input.readFieldNumber(this))
  25. throw new ProtostuffException("Corrupt input.");
  26. return array;
  27. }

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

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

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

  1. protected Object readPrimitiveFrom(Input input, Object owner, int len)
  2. throws IOException
  3. {
  4. long[] array = new long[len];
  5. if (input instanceof GraphInput)
  6. {
  7. // update the actual reference.
  8. ((GraphInput) input).updateLast(array, owner);
  9. }
  10. for (int i = 0; i < len; i++)
  11. {
  12. if (ID_ARRAY_DATA != input.readFieldNumber(this))
  13. throw new ProtostuffException("Corrupt input.");
  14. array[i] = input.readInt64();
  15. }
  16. if (0 != input.readFieldNumber(this))
  17. throw new ProtostuffException("Corrupt input.");
  18. return array;
  19. }

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

  1. protected Object readPrimitiveFrom(Input input, Object owner, int len)
  2. throws IOException
  3. {
  4. boolean[] array = new boolean[len];
  5. if (input instanceof GraphInput)
  6. {
  7. // update the actual reference.
  8. ((GraphInput) input).updateLast(array, owner);
  9. }
  10. for (int i = 0; i < len; i++)
  11. {
  12. if (ID_ARRAY_DATA != input.readFieldNumber(this))
  13. throw new ProtostuffException("Corrupt input.");
  14. array[i] = input.readBool();
  15. }
  16. if (0 != input.readFieldNumber(this))
  17. throw new ProtostuffException("Corrupt input.");
  18. return array;
  19. }

相关文章