本文整理了Java中io.protostuff.Output
类的一些代码示例,展示了Output
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Output
类的具体详情如下:
包路径:io.protostuff.Output
类名称:Output
[英]An Output lets an application write primitive data types and objects to a sink of data.
[中]输出允许应用程序将基本数据类型和对象写入数据接收器。
代码示例来源:origin: protostuff/protostuff
@Override
public void writeTo(Output output, int number, String value,
boolean repeated) throws IOException
{
output.writeString(number, (CharSequence) value, repeated);
}
代码示例来源:origin: protostuff/protostuff
@Override
protected void transfer(Pipe pipe, Input input, Output output,
boolean repeated) throws IOException
{
output.writeObject(number, pipe, schema.pipeSchema, repeated);
}
代码示例来源:origin: protostuff/protostuff
@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);
}
}
代码示例来源:origin: protostuff/protostuff
@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);
}
代码示例来源:origin: protostuff/protostuff
@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);
}
代码示例来源:origin: protostuff/protostuff
@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);
}
代码示例来源:origin: dremio/dremio-oss
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);
}
代码示例来源:origin: protostuff/protostuff
@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);
}
代码示例来源:origin: protostuff/protostuff
@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);
}
代码示例来源:origin: protostuff/protostuff
@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);
}
代码示例来源:origin: protostuff/protostuff
/**
* 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);
}
代码示例来源:origin: protostuff/protostuff
protected void writeLengthTo(Output output, int len, boolean primitive)
throws IOException
{
output.writeInt32(ID_ARRAY_LEN, len, false);
}
代码示例来源:origin: fengjiachun/Jupiter
@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);
}
}
代码示例来源:origin: protostuff/protostuff
@Override
public void writeInt64(int fieldNumber, long value, boolean repeated) throws IOException
{
output.writeInt64(fieldNumber, value, repeated);
}
代码示例来源:origin: protostuff/protostuff
@Override
public void writeBool(int fieldNumber, boolean value, boolean repeated) throws IOException
{
output.writeBool(fieldNumber, value, repeated);
}
代码示例来源:origin: protostuff/protostuff
@Override
public void writeDouble(int fieldNumber, double value, boolean repeated) throws IOException
{
output.writeDouble(fieldNumber, value, repeated);
}
代码示例来源:origin: protostuff/protostuff
/**
* 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);
}
代码示例来源:origin: protostuff/protostuff
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);
代码示例来源:origin: protostuff/protostuff
@Override
public void writeTo(Output output, int number, Character value,
boolean repeated) throws IOException
{
output.writeUInt32(number, value.charValue(), repeated);
}
代码示例来源:origin: protostuff/protostuff
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);
内容来源于网络,如有侵权,请联系作者删除!