本文整理汇总了Java中io.protostuff.ProtobufIOUtil.writeTo方法的典型用法代码示例。如果您正苦于以下问题:Java ProtobufIOUtil.writeTo方法的具体用法?Java ProtobufIOUtil.writeTo怎么用?Java ProtobufIOUtil.writeTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.protostuff.ProtobufIOUtil
的用法示例。
在下文中一共展示了ProtobufIOUtil.writeTo方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testInheritanceProtobuf
import io.protostuff.ProtobufIOUtil; //导入方法依赖的package包/类
public void testInheritanceProtobuf() throws IOException
{
if (skipTests)
{
System.err
.println("RuntimeSchema.MORPH_NON_FINAL_POJOS was not enabled.");
return;
}
System.err.println("executing inheritance test for protobuf ... ");
Schema<InputSystem> schema = RuntimeSchema.getSchema(InputSystem.class);
InputSystem sys = new InputSystem();
KeyBoard kb = new KeyBoard();
Mouse ms = new Mouse();
kb.setName("Test");
kb.setNumberOfKeys(10);
ms.setName("Test1");
ms.setNumberOfButtons(2);
List<InputDevice> devices = new ArrayList<InputDevice>();
devices.add(ms);
devices.add(kb);
sys.setInputDevices(devices);
ByteArrayOutputStream out = new ByteArrayOutputStream();
ProtobufIOUtil.writeTo(out, sys, schema, buf());
byte[] listData = out.toByteArray();
InputSystem deserSystem = new InputSystem();
ByteArrayInputStream in = new ByteArrayInputStream(listData);
ProtobufIOUtil.mergeFrom(in, deserSystem, schema, buf());
assertEquals(sys, deserSystem);
}
示例2: runtime_serialize_1_int_field
import io.protostuff.ProtobufIOUtil; //导入方法依赖的package包/类
@Benchmark
public void runtime_serialize_1_int_field() throws Exception
{
try
{
ProtobufIOUtil.writeTo(buffer, int1, int1RuntimeSchema);
}
finally
{
buffer.clear();
}
}
示例3: runtime_serialize_10_int_fields
import io.protostuff.ProtobufIOUtil; //导入方法依赖的package包/类
@Benchmark
public void runtime_serialize_10_int_fields() throws Exception
{
try
{
ProtobufIOUtil.writeTo(buffer, int10, int10RuntimeSchema);
}
finally
{
buffer.clear();
}
}
示例4: runtime_sparse_serialize_1_int_field
import io.protostuff.ProtobufIOUtil; //导入方法依赖的package包/类
@Benchmark
public void runtime_sparse_serialize_1_int_field() throws Exception
{
try
{
ProtobufIOUtil.writeTo(buffer, sparseInt1, sparseInt1RuntimeSchema);
}
finally
{
buffer.clear();
}
}
示例5: runtime_sparse_serialize_10_int_fields
import io.protostuff.ProtobufIOUtil; //导入方法依赖的package包/类
@Benchmark
public void runtime_sparse_serialize_10_int_fields() throws Exception
{
try
{
ProtobufIOUtil.writeTo(buffer, sparseInt10, sparseInt10RuntimeSchema);
}
finally
{
buffer.clear();
}
}
示例6: generated_serialize_1_int_field
import io.protostuff.ProtobufIOUtil; //导入方法依赖的package包/类
@Benchmark
public void generated_serialize_1_int_field() throws Exception
{
try
{
ProtobufIOUtil.writeTo(buffer, generatedInt1, generatedInt1Schema);
}
finally
{
buffer.clear();
}
}
示例7: generated_serialize_10_int_field
import io.protostuff.ProtobufIOUtil; //导入方法依赖的package包/类
@Benchmark
public void generated_serialize_10_int_field() throws Exception
{
try
{
ProtobufIOUtil.writeTo(buffer, generatedInt10, generatedInt10Schema);
}
finally
{
buffer.clear();
}
}
示例8: writeObject
import io.protostuff.ProtobufIOUtil; //导入方法依赖的package包/类
protected <T> int writeObject(LinkedBuffer buffer, T object,
Schema<T> schema) {
return ProtobufIOUtil.writeTo(buffer, object, schema);
}
示例9: serialize
import io.protostuff.ProtobufIOUtil; //导入方法依赖的package包/类
private byte[] serialize(HelloResponse response) throws IOException {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
LinkedBuffer buffer = LinkedBuffer.allocate();
ProtobufIOUtil.writeTo(outputStream, response, SEARCH_RESPONSE_SCHEMA, buffer);
return outputStream.toByteArray();
}
示例10: serialize
import io.protostuff.ProtobufIOUtil; //导入方法依赖的package包/类
private byte[] serialize(Foo foo) throws java.io.IOException {
ByteArrayOutputStream temp = new ByteArrayOutputStream();
ProtobufIOUtil.writeTo(temp, foo, SCHEMA, BUFFER);
return temp.toByteArray();
}
示例11: writeTo
import io.protostuff.ProtobufIOUtil; //导入方法依赖的package包/类
@Override
protected <T> void writeTo(OutputStream out, T message, Schema<T> schema)
throws IOException
{
ProtobufIOUtil.writeTo(out, message, schema, buf());
}
示例12: prepare
import io.protostuff.ProtobufIOUtil; //导入方法依赖的package包/类
@Setup
public void prepare() throws IOException
{
int1RuntimeSchema = RuntimeSchema.createFrom(Int1.class);
int10RuntimeSchema = RuntimeSchema.createFrom(Int10.class);
sparseInt1RuntimeSchema = RuntimeSchema.createFrom(SparseInt1.class);
sparseInt10RuntimeSchema = RuntimeSchema.createFrom(SparseInt10.class);
generatedInt1Schema = GeneratedInt1.getSchema();
generatedInt10Schema = GeneratedInt10.getSchema();
int1 = new Int1();
int1.a0 = 1;
int10 = new Int10();
int10.a0 = 1;
int10.a1 = 2;
int10.a2 = 3;
int10.a3 = 4;
int10.a4 = 5;
int10.a5 = 6;
int10.a6 = 7;
int10.a7 = 8;
int10.a8 = 9;
int10.a9 = 10;
sparseInt1 = new SparseInt1();
sparseInt1.a0 = 1;
sparseInt10 = new SparseInt10();
sparseInt10.a0 = 1;
sparseInt10.a1 = 2;
sparseInt10.a2 = 3;
sparseInt10.a3 = 4;
sparseInt10.a4 = 5;
sparseInt10.a5 = 6;
sparseInt10.a6 = 7;
sparseInt10.a7 = 8;
sparseInt10.a8 = 9;
sparseInt10.a9 = 10;
generatedInt1 = new GeneratedInt1();
generatedInt1.setA0(1);
generatedInt10 = new GeneratedInt10();
generatedInt10.setA0(1);
generatedInt10.setA1(2);
generatedInt10.setA2(3);
generatedInt10.setA3(4);
generatedInt10.setA4(5);
generatedInt10.setA5(6);
generatedInt10.setA6(7);
generatedInt10.setA7(8);
generatedInt10.setA8(9);
generatedInt10.setA9(10);
buffer = LinkedBuffer.allocate();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ProtobufIOUtil.writeTo(outputStream, int1, int1RuntimeSchema, buffer);
data_1_int = outputStream.toByteArray();
outputStream.reset();
buffer.clear();
ProtobufIOUtil.writeTo(outputStream, int10, int10RuntimeSchema, buffer);
data_10_int = outputStream.toByteArray();
outputStream.reset();
buffer.clear();
}