Java Code Examples for io.protostuff.Output#writeInt32()
The following examples show how to use
io.protostuff.Output#writeInt32() .
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: 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."); }
Example 2
Source File: ArraySchemas.java From protostuff with Apache License 2.0 | 5 votes |
@Override public void writeTo(Output output, Object value) throws IOException { Date[] array = (Date[]) value; output.writeInt32(ID_ARRAY_LEN, array.length, false); int nullCount = 0; for (int i = 0, len = array.length; i < len; i++) { Date v = array[i]; if (v != null) { if (nullCount != 0) { output.writeUInt32(ID_ARRAY_NULLCOUNT, nullCount, false); nullCount = 0; } output.writeFixed64(ID_ARRAY_DATA, v.getTime(), true); } else if (allowNullArrayElement) { nullCount++; } } // if last element is null if (nullCount != 0) output.writeUInt32(ID_ARRAY_NULLCOUNT, nullCount, false); }
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++; 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 4
Source File: ProtostuffCodecTest.java From c5-replicator with Apache License 2.0 | 5 votes |
@Override public void writeTo(Output output, SerObj message) throws IOException { output.writeInt32(1, message.id, false); output.writeString(2, message.desc, false); output.writeInt64(3, message.timestamp, false); output.writeDouble(4, message.cost, false); }
Example 5
Source File: LocalTimeSchema.java From joyrpc with Apache License 2.0 | 5 votes |
@Override public void writeTo(final Output output, final LocalTime message) throws IOException { output.writeInt32(1, message.getHour(), false); output.writeInt32(2, message.getMinute(), false); output.writeInt32(3, message.getSecond(), false); output.writeInt32(4, message.getNano(), false); }
Example 6
Source File: ArraySchemas.java From protostuff with Apache License 2.0 | 5 votes |
@Override public void writeTo(Output output, Object value) throws IOException { BigDecimal[] array = (BigDecimal[]) value; output.writeInt32(ID_ARRAY_LEN, array.length, false); int nullCount = 0; for (int i = 0, len = array.length; i < len; i++) { BigDecimal v = array[i]; if (v != null) { if (nullCount != 0) { output.writeUInt32(ID_ARRAY_NULLCOUNT, nullCount, false); nullCount = 0; } output.writeString(ID_ARRAY_DATA, v.toString(), true); } else if (allowNullArrayElement) { nullCount++; } } // if last element is null if (nullCount != 0) output.writeUInt32(ID_ARRAY_NULLCOUNT, nullCount, false); }
Example 7
Source File: ArraySchemas.java From protostuff with Apache License 2.0 | 5 votes |
@Override public void writeTo(Output output, Object message) throws IOException { final Object[] array = (Object[])message; final int len = array.length; output.writeInt32(ID_ARRAY_LEN, len, false); int nullCount = 0; for (int i = 0; i < len; i++) { Object v = array[i]; if (v != null) { if (nullCount != 0) { output.writeUInt32(ID_ARRAY_NULLCOUNT, nullCount, false); nullCount = 0; } delegate.writeTo(output, ID_ARRAY_DATA, v, true); } else if (allowNullArrayElement) { nullCount++; } } // if last element is null if (nullCount != 0) output.writeUInt32(ID_ARRAY_NULLCOUNT, nullCount, false); }
Example 8
Source File: InstantSchema.java From joyrpc with Apache License 2.0 | 4 votes |
@Override public void writeTo(final Output output, final Instant message) throws IOException { output.writeInt64(1, message.getEpochSecond(), false); output.writeInt32(2, message.getNano(), false); }
Example 9
Source File: ZoneOffsetSchema.java From joyrpc with Apache License 2.0 | 4 votes |
@Override public void writeTo(final Output output, final ZoneOffset message) throws IOException { output.writeInt32(1, message.getTotalSeconds(), false); }
Example 10
Source File: DurationSchema.java From joyrpc with Apache License 2.0 | 4 votes |
@Override public void writeTo(final Output output, final Duration message) throws IOException { output.writeInt64(1, message.getSeconds(), false); output.writeInt32(2, message.getNano(), false); }
Example 11
Source File: MonthDaySchema.java From joyrpc with Apache License 2.0 | 4 votes |
@Override public void writeTo(final Output output, final MonthDay message) throws IOException { output.writeInt32(1, message.getMonthValue(), false); output.writeInt32(2, message.getDayOfMonth(), false); }
Example 12
Source File: YearSchema.java From joyrpc with Apache License 2.0 | 4 votes |
@Override public void writeTo(final Output output, final Year message) throws IOException { output.writeInt32(1, message.getValue(), false); }
Example 13
Source File: RuntimeReflectionFieldFactory.java From protostuff with Apache License 2.0 | 4 votes |
@Override public void writeTo(Output output, int number, Integer value, boolean repeated) throws IOException { output.writeInt32(number, value.intValue(), repeated); }
Example 14
Source File: ArraySchemas.java From protostuff with Apache License 2.0 | 4 votes |
protected void writeLengthTo(Output output, int len, boolean primitive) throws IOException { output.writeInt32(ID_ARRAY_LEN, len, false); }
Example 15
Source File: ArraySchemas.java From protostuff with Apache License 2.0 | 4 votes |
protected void writeLengthTo(Output output, int len, boolean primitive) throws IOException { output.writeInt32(ID_ARRAY_LEN, len, false); }
Example 16
Source File: ArraySchemas.java From protostuff with Apache License 2.0 | 4 votes |
protected void writeLengthTo(Output output, int len, boolean primitive) throws IOException { output.writeInt32(ID_ARRAY_LEN, len, false); }
Example 17
Source File: ArraySchemas.java From protostuff with Apache License 2.0 | 4 votes |
protected void writeLengthTo(Output output, int len, boolean primitive) throws IOException { output.writeInt32(ID_ARRAY_LEN, len, false); }
Example 18
Source File: ArraySchemas.java From protostuff with Apache License 2.0 | 4 votes |
protected void writeLengthTo(Output output, int len, boolean primitive) throws IOException { output.writeInt32(ID_ARRAY_LEN, len, false); }
Example 19
Source File: ArraySchemas.java From protostuff with Apache License 2.0 | 4 votes |
protected void writeLengthTo(Output output, int len, boolean primitive) throws IOException { output.writeInt32(ID_ARRAY_LEN, len, false); }
Example 20
Source File: ArraySchemas.java From protostuff with Apache License 2.0 | 4 votes |
protected void writeLengthTo(Output output, int len, boolean primitive) throws IOException { output.writeInt32(ID_ARRAY_LEN, len, false); }