@Override public void writeTo(Output output, int number, String value, boolean repeated) throws IOException { output.writeString(number, (CharSequence) value, repeated); }
@Override protected void transfer(Pipe pipe, Input input, Output output, boolean repeated) throws IOException { output.writeObject(number, pipe, schema.pipeSchema, repeated); }
@Override public void writeTo(Output output, Object value) throws IOException { ByteString[] array = (ByteString[]) value; output.writeInt32(ID_ARRAY_LEN, array.length, false); int nullCount = 0; for (int i = 0, len = array.length; i < len; i++) { ByteString v = array[i]; if (v != null) { if (nullCount != 0) { output.writeUInt32(ID_ARRAY_NULLCOUNT, nullCount, false); nullCount = 0; } output.writeBytes(ID_ARRAY_DATA, v, true); } else if (allowNullArrayElement) { nullCount++; } } // if last element is null if (nullCount != 0) output.writeUInt32(ID_ARRAY_NULLCOUNT, nullCount, false); } }
@Override public void writeTo(Output output, Bar message) throws IOException { if (message.someInt != 0) output.writeInt32(1, message.someInt, false); if (message.someString != null) output.writeString(2, message.someString, false); if (message.someBaz != null) output.writeObject(3, message.someBaz, Baz.getSchema(), false); if (message.someEnum != null) output.writeEnum(4, message.someEnum.number, false); if (message.someBytes != null) output.writeBytes(5, message.someBytes, false); if (message.someBoolean) output.writeBool(6, message.someBoolean, false); if (message.someFloat != 0f) output.writeFloat(7, message.someFloat, false); if (message.someDouble != 0d) output.writeDouble(8, message.someDouble, false); if (message.someLong != 0l) output.writeInt64(9, message.someLong, false); }
@Override public void writeTo(Output output, PojoWithInts message) throws IOException { if (message.someInt32 != 0) output.writeInt32(1, message.someInt32, false); if (message.someUint32 != 0) output.writeUInt32(2, message.someUint32, false); if (message.someSint32 != 0) output.writeSInt32(3, message.someSint32, false); if (message.someFixed32 != 0) output.writeFixed32(4, message.someFixed32, false); if (message.someSfixed32 != 0) output.writeSFixed32(5, message.someSfixed32, false); if (message.someInt64 != 0) output.writeInt64(11, message.someInt64, false); if (message.someUint64 != 0) output.writeUInt64(12, message.someUint64, false); if (message.someSint64 != 0) output.writeSInt64(13, message.someSint64, false); if (message.someFixed64 != 0) output.writeFixed64(14, message.someFixed64, false); if (message.someSfixed64 != 0) output.writeSFixed64(15, message.someSfixed64, false); }
@Override public void writeTo(Output output, Baz message) throws IOException { if (message.id != 0) output.writeInt32(1, message.id, false); if (message.name != null) output.writeString(2, message.name, false); if (message.timestamp != 0l) output.writeInt64(3, message.timestamp, false); }
public void writeTo(Output output, SplitRule message) throws IOException { if(message.pattern == null) throw new UninitializedMessageException(message); output.writeString(1, message.pattern, false); if(message.matchType == null) throw new UninitializedMessageException(message); output.writeEnum(2, message.matchType.number, false); if(message.ignoreCase == null) throw new UninitializedMessageException(message); output.writeBool(3, message.ignoreCase, false); }
@Override public void writeTo(Output output, ClubFounder message) throws IOException { if (message.name != null) output.writeString(1, message.name, false); if (message.club != null) output.writeObject(2, message.club, Club.getSchema(), false); }
@Override public void writeTo(Output output, PojoWithBiggerByteArray message) throws IOException { output.writeInt32(1, message.id, false); output.writeByteArray(2, message.b, false); output.writeInt64(3, message.ts, false); }
@Override public void transferByteRangeTo(Output output, boolean utf8String, int fieldNumber, boolean repeated) throws IOException { if (utf8String) output.writeString(fieldNumber, readString(), repeated); else output.writeByteArray(fieldNumber, readByteArray(), repeated); }
/** * Writes the {@link Enum} to the output. */ public void writeTo(Output output, int number, boolean repeated, Enum<?> e) throws IOException { if (0 == (IdStrategy.ENUMS_BY_NAME & strategy.flags)) output.writeEnum(number, getTag(e), repeated); else output.writeString(number, getAlias(e), repeated); }
protected void writeLengthTo(Output output, int len, boolean primitive) throws IOException { output.writeInt32(ID_ARRAY_LEN, len, false); }
@Override public void transferByteRangeTo(Output output, boolean utf8String, int fieldNumber, boolean repeated) throws IOException { final int length = readRawVarInt32(); if (length < 0) { throw ProtocolException.negativeSize(); } if (utf8String) { // if it is a UTF string, we have to call the writeByteRange. if (nioBuffer.hasArray()) { output.writeByteRange(true, fieldNumber, nioBuffer.array(), nioBuffer.arrayOffset() + nioBuffer.position(), length, repeated); nioBuffer.position(nioBuffer.position() + length); } else { byte[] bytes = new byte[length]; nioBuffer.get(bytes); output.writeByteRange(true, fieldNumber, bytes, 0, bytes.length, repeated); } } else { // Do the potentially vastly more efficient potential splice call. if (nioBuffer.remaining() < length) { throw ProtocolException.misreportedSize(); } ByteBuffer dup = nioBuffer.slice(); dup.limit(length); output.writeBytes(fieldNumber, dup, repeated); nioBuffer.position(nioBuffer.position() + length); } }
@Override public void writeInt64(int fieldNumber, long value, boolean repeated) throws IOException { output.writeInt64(fieldNumber, value, repeated); }
@Override public void writeBool(int fieldNumber, boolean value, boolean repeated) throws IOException { output.writeBool(fieldNumber, value, repeated); }
@Override public void writeDouble(int fieldNumber, double value, boolean repeated) throws IOException { output.writeDouble(fieldNumber, value, repeated); }
/** * Writes the bytes to the {@link Output}. */ public static void writeTo(Output output, ByteString bs, int fieldNumber, boolean repeated) throws IOException { output.writeByteArray(fieldNumber, bs.bytes, repeated); }
output.writeBool(ID_ARRAY_DATA, array[i], true); output.writeUInt32(ID_ARRAY_NULLCOUNT, nullCount, false); nullCount = 0; output.writeBool(ID_ARRAY_DATA, v, true); output.writeUInt32(ID_ARRAY_NULLCOUNT, nullCount, false);
@Override public void writeTo(Output output, int number, Character value, boolean repeated) throws IOException { output.writeUInt32(number, value.charValue(), repeated); }
output.writeDouble(ID_ARRAY_DATA, array[i], true); output.writeUInt32(ID_ARRAY_NULLCOUNT, nullCount, false); nullCount = 0; output.writeDouble(ID_ARRAY_DATA, v, true); output.writeUInt32(ID_ARRAY_NULLCOUNT, nullCount, false);