本文整理汇总了Java中io.protostuff.Output.writeBytes方法的典型用法代码示例。如果您正苦于以下问题:Java Output.writeBytes方法的具体用法?Java Output.writeBytes怎么用?Java Output.writeBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.protostuff.Output
的用法示例。
在下文中一共展示了Output.writeBytes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeTo
import io.protostuff.Output; //导入方法依赖的package包/类
@Override
public void writeTo(Output output, Object value) throws IOException
{
ByteString[] array = (ByteString[]) value;
output.writeUInt32(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 (ALLOW_NULL_ARRAY_ELEMENT)
{
nullCount++;
}
}
// if last element is null
if (nullCount != 0)
output.writeUInt32(ID_ARRAY_NULLCOUNT, nullCount, false);
}
示例2: transferByteRangeTo
import io.protostuff.Output; //导入方法依赖的package包/类
public void transferByteRangeTo(Output output, boolean utf8String, int fieldNumber,
boolean repeated) throws IOException {
final int length = readRawVarint32();
if (length < 0) {
throw negativeSize();
}
if (utf8String) {
// if it is a UTF string, we have to call the writeByteRange.
if (buffer.hasArray()) {
output.writeByteRange(true, fieldNumber, buffer.array(),
buffer.arrayOffset() + buffer.readerIndex(), length, repeated);
buffer.skipBytes(length);
} else {
byte[] bytes = new byte[length];
buffer.readBytes(bytes);
output.writeByteRange(true, fieldNumber, bytes, 0, bytes.length, repeated);
}
} else {
// Do the potentially vastly more efficient potential splice call.
if (!buffer.isReadable(length)) {
throw misreportedSize();
}
ByteBuf dup = buffer.slice(buffer.readerIndex(), length);
output.writeBytes(fieldNumber, dup.nioBuffer(), repeated);
buffer.skipBytes(length);
}
}
示例3: writeTo
import io.protostuff.Output; //导入方法依赖的package包/类
@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);
}
示例4: writeTo
import io.protostuff.Output; //导入方法依赖的package包/类
@Override
public void writeTo(Output output, int number, ByteString value,
boolean repeated) throws IOException
{
output.writeBytes(number, value, repeated);
}