本文整理汇总了Java中io.protostuff.Output.writeUInt32方法的典型用法代码示例。如果您正苦于以下问题:Java Output.writeUInt32方法的具体用法?Java Output.writeUInt32怎么用?Java Output.writeUInt32使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.protostuff.Output
的用法示例。
在下文中一共展示了Output.writeUInt32方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeObjectTo
import io.protostuff.Output; //导入方法依赖的package包/类
static void writeObjectTo(Output output, Object value,
Schema<?> currentSchema, IdStrategy strategy) throws IOException
{
final Class<?> clazz = value.getClass();
int dimensions = 1;
Class<?> componentType = clazz.getComponentType();
while (componentType.isArray())
{
dimensions++;
componentType = componentType.getComponentType();
}
strategy.writeArrayIdTo(output, componentType);
// write the length of the array
output.writeUInt32(ID_ARRAY_LEN, Array.getLength(value), false);
// write the dimensions of the array
output.writeUInt32(ID_ARRAY_DIMENSION, dimensions, false);
if (output instanceof StatefulOutput)
{
// update using the derived schema.
((StatefulOutput) output).updateLast(strategy.ARRAY_SCHEMA,
currentSchema);
}
strategy.ARRAY_SCHEMA.writeTo(output, value);
}
示例2: writeTo
import io.protostuff.Output; //导入方法依赖的package包/类
@Override
public void writeTo(Output output, Object value) throws IOException
{
String[] array = (String[]) value;
output.writeUInt32(ID_ARRAY_LEN, array.length, false);
int nullCount = 0;
for (int i = 0, len = array.length; i < len; i++)
{
String v = array[i];
if (v != null)
{
if (nullCount != 0)
{
output.writeUInt32(ID_ARRAY_NULLCOUNT, nullCount, false);
nullCount = 0;
}
output.writeString(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);
}
示例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: transfer
import io.protostuff.Output; //导入方法依赖的package包/类
@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.");
}
示例5: transferPojoId
import io.protostuff.Output; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected <T> HasSchema<T> transferPojoId(Input input, Output output,
int fieldNumber) throws IOException
{
final int id = input.readUInt32();
final BaseHS<T> wrapper = (BaseHS<T>) pojos.get(id);
if (wrapper == null)
throw new UnknownTypeException("pojo id: " + id + " (Outdated registry)");
output.writeUInt32(fieldNumber, id, false);
return wrapper;
}
示例6: transferClass
import io.protostuff.Output; //导入方法依赖的package包/类
static void transferClass(Pipe pipe, Input input, Output output, int number,
Pipe.Schema<?> pipeSchema, boolean mapped, boolean array,
IdStrategy strategy) throws IOException
{
strategy.transferClassId(input, output, number, mapped, array);
if (array)
{
if (input.readFieldNumber(pipeSchema.wrappedSchema) != ID_ARRAY_DIMENSION)
throw new ProtostuffException("Corrupt input.");
output.writeUInt32(ID_ARRAY_DIMENSION, input.readUInt32(), false);
}
}
示例7: writeTo
import io.protostuff.Output; //导入方法依赖的package包/类
@Override
public void writeTo(Output output, int number, Byte value,
boolean repeated) throws IOException
{
output.writeUInt32(number, value.byteValue(), repeated);
}
示例8: transferEnumId
import io.protostuff.Output; //导入方法依赖的package包/类
@Override
protected void transferEnumId(Input input, Output output, int fieldNumber)
throws IOException
{
output.writeUInt32(fieldNumber, input.readUInt32(), false);
}
示例9: transfer
import io.protostuff.Output; //导入方法依赖的package包/类
@Override
public void transfer(Pipe pipe, Input input, Output output, int number,
boolean repeated) throws IOException
{
output.writeUInt32(number, input.readUInt32(), repeated);
}
示例10: transferCollectionId
import io.protostuff.Output; //导入方法依赖的package包/类
@Override
protected void transferCollectionId(Input input, Output output, int fieldNumber)
throws IOException
{
output.writeUInt32(fieldNumber, input.readUInt32(), false);
}
示例11: writeTo
import io.protostuff.Output; //导入方法依赖的package包/类
@Override
public void writeTo(Output output, int number, Short value,
boolean repeated) throws IOException
{
output.writeUInt32(number, value.shortValue(), repeated);
}