Java Code Examples for io.protostuff.Input#readInt32()
The following examples show how to use
io.protostuff.Input#readInt32() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProtostuffCodecTest.java From c5-replicator with Apache License 2.0 | 6 votes |
@Override public void mergeFrom(Input input, SerObj 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.desc = input.readString(); break; case 3: message.timestamp = input.readInt64(); break; case 4: message.cost = input.readDouble(); break; } } }
Example 2
Source File: ArraySchemas.java From protostuff with Apache License 2.0 | 6 votes |
protected Object readPrimitiveFrom(Input input, Object owner, int len) throws IOException { int[] array = new int[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.readInt32(); } if (0 != input.readFieldNumber(this)) throw new ProtostuffException("Corrupt input."); return array; }
Example 3
Source File: ArraySchemas.java From protostuff with Apache License 2.0 | 5 votes |
@Override protected void transfer(Pipe pipe, Input input, Output output) throws IOException { if (ID_ARRAY_LEN != input .readFieldNumber(pipeSchema.wrappedSchema)) throw new ProtostuffException("Corrupt input."); final int len = input.readInt32(); // write it back output.writeInt32(ID_ARRAY_LEN, len, false); for (int i = 0, nullCount = 0; i < len;) { switch (input.readFieldNumber(pipeSchema.wrappedSchema)) { case ID_ARRAY_DATA: i++; EnumIO.transfer(pipe, input, output, ID_ARRAY_DATA, true, eio.strategy); break; case ID_ARRAY_NULLCOUNT: nullCount = input.readUInt32(); i += nullCount; output.writeUInt32(ID_ARRAY_NULLCOUNT, nullCount, false); break; default: throw new ProtostuffException("Corrupt input."); } } if (0 != input.readFieldNumber(pipeSchema.wrappedSchema)) throw new ProtostuffException("Corrupt input."); }
Example 4
Source File: ArraySchemas.java From protostuff with Apache License 2.0 | 5 votes |
@Override protected void transfer(Pipe pipe, Input input, Output output) throws IOException { if (ID_ARRAY_LEN != input .readFieldNumber(pipeSchema.wrappedSchema)) throw new ProtostuffException("Corrupt input."); final int len = input.readInt32(); // write it back output.writeInt32(ID_ARRAY_LEN, len, false); for (int i = 0, nullCount = 0; i < len;) { switch (input.readFieldNumber(pipeSchema.wrappedSchema)) { case ID_ARRAY_DATA: i++; output.writeObject(ID_ARRAY_DATA, pipe, hs.getPipeSchema(), true); break; case ID_ARRAY_NULLCOUNT: nullCount = input.readUInt32(); i += nullCount; output.writeUInt32(ID_ARRAY_NULLCOUNT, nullCount, false); break; default: throw new ProtostuffException("Corrupt input."); } } if (0 != input.readFieldNumber(pipeSchema.wrappedSchema)) throw new ProtostuffException("Corrupt input."); }
Example 5
Source File: ArraySchemas.java From protostuff with Apache License 2.0 | 5 votes |
@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(); Object[] array = (Object[])Array.newInstance(delegate.typeClass(), 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++] = delegate.readFrom(input); 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; }
Example 6
Source File: ArraySchemas.java From protostuff with Apache License 2.0 | 5 votes |
@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(); Date[] array = new Date[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++] = new Date(input.readFixed64()); 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; }
Example 7
Source File: ArraySchemas.java From protostuff with Apache License 2.0 | 5 votes |
@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(); BigInteger[] array = new BigInteger[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++] = new BigInteger(input.readByteArray()); 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; }
Example 8
Source File: ArraySchemas.java From protostuff with Apache License 2.0 | 5 votes |
@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(); BigDecimal[] array = new BigDecimal[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++] = new BigDecimal(input.readString()); 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; }
Example 9
Source File: ArraySchemas.java From protostuff with Apache License 2.0 | 5 votes |
@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(); byte[][] array = new byte[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.readByteArray(); 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; }
Example 10
Source File: ArraySchemas.java From protostuff with Apache License 2.0 | 5 votes |
@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; }
Example 11
Source File: ArraySchemas.java From protostuff with Apache License 2.0 | 5 votes |
@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(); String[] array = new String[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.readString(); 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; }
Example 12
Source File: ArraySchemas.java From protostuff with Apache License 2.0 | 5 votes |
@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); }
Example 13
Source File: ArraySchemas.java From protostuff with Apache License 2.0 | 5 votes |
@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); }
Example 14
Source File: ArraySchemas.java From protostuff with Apache License 2.0 | 5 votes |
@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); }
Example 15
Source File: ArraySchemas.java From protostuff with Apache License 2.0 | 5 votes |
@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(); Object[] array = (Object[])Array.newInstance(eio.enumClass, 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++] = eio.readFrom(input); 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; }
Example 16
Source File: ArraySchemas.java From protostuff with Apache License 2.0 | 5 votes |
protected Object readBoxedFrom(Input input, Object owner, int len) throws IOException { final Integer[] array = new Integer[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.readInt32(); 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; }
Example 17
Source File: ArraySchemas.java From protostuff with Apache License 2.0 | 5 votes |
@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(); Object[] array = (Object[])Array.newInstance(hs.getSchema().typeClass(), 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.mergeObject(null, hs.getSchema()); 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; }
Example 18
Source File: ArraySchemas.java From protostuff with Apache License 2.0 | 5 votes |
@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); }
Example 19
Source File: ArraySchemas.java From protostuff with Apache License 2.0 | 5 votes |
@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); }
Example 20
Source File: ArraySchemas.java From protostuff with Apache License 2.0 | 5 votes |
static void transferObject(Pipe.Schema<Object> pipeSchema, Pipe pipe, Input input, Output output, IdStrategy strategy, Delegate<?> delegate) throws IOException { if (ID_ARRAY_LEN != input.readFieldNumber(pipeSchema.wrappedSchema)) throw new ProtostuffException("Corrupt input."); int len = input.readInt32(); // write it back output.writeInt32(ID_ARRAY_LEN, len, false); // if from derived schema and the array is boxed, the length written // during serialization is: -(len + 1) if (len < 0) len = -len - 1; for (int i = 0, nullCount = 0; i < len;) { switch (input.readFieldNumber(pipeSchema.wrappedSchema)) { case ID_ARRAY_DATA: i++; delegate.transfer(pipe, input, output, ID_ARRAY_DATA, true); break; case ID_ARRAY_NULLCOUNT: nullCount = input.readUInt32(); i += nullCount; output.writeUInt32(ID_ARRAY_NULLCOUNT, nullCount, false); break; default: throw new ProtostuffException("Corrupt input."); } } if (0 != input.readFieldNumber(pipeSchema.wrappedSchema)) throw new ProtostuffException("Corrupt input."); }