本文整理匯總了Java中io.protostuff.GraphIOUtil.toByteArray方法的典型用法代碼示例。如果您正苦於以下問題:Java GraphIOUtil.toByteArray方法的具體用法?Java GraphIOUtil.toByteArray怎麽用?Java GraphIOUtil.toByteArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.protostuff.GraphIOUtil
的用法示例。
在下文中一共展示了GraphIOUtil.toByteArray方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testGraph
import io.protostuff.GraphIOUtil; //導入方法依賴的package包/類
public void testGraph()
{
System.err.println(RuntimeEnv.COLLECTION_SCHEMA_ON_REPEATED_FIELDS);
Bean bean = fill(new Bean());
verify(bean);
Schema<Bean> schema = RuntimeSchema.getSchema(Bean.class);
// print(schema);
byte[] bytes = GraphIOUtil.toByteArray(bean, schema,
LinkedBuffer.allocate(256));
Bean deBean = new Bean();
GraphIOUtil.mergeFrom(bytes, deBean, schema);
verify(deBean);
}
示例2: testBeanCyclic
import io.protostuff.GraphIOUtil; //導入方法依賴的package包/類
public void testBeanCyclic()
{
System.err.println(RuntimeEnv.COLLECTION_SCHEMA_ON_REPEATED_FIELDS);
Bean bean = fillCyclic(new Bean());
verifyCyclic(bean);
Schema<Bean> schema = RuntimeSchema.getSchema(Bean.class);
// print(schema);
byte[] bytes = GraphIOUtil.toByteArray(bean, schema,
LinkedBuffer.allocate(256));
Bean deBean = new Bean();
GraphIOUtil.mergeFrom(bytes, deBean, schema);
verifyCyclic(deBean);
}
示例3: translate
import io.protostuff.GraphIOUtil; //導入方法依賴的package包/類
@Override
@SuppressWarnings("unchecked")
public byte[] translate(RequestWrapper requestWrapper, ResponseWrapper responseWrapper) throws IOException {
Object result = responseWrapper.getResult();
Schema schema;
try {
schema = schemaCache.get(result.getClass());
} catch (ExecutionException e) {
schema = RuntimeSchema.getSchema(result.getClass());
}
return GraphIOUtil.toByteArray(result, schema, LinkedBuffer.allocate(LinkedBuffer.DEFAULT_BUFFER_SIZE));
}
示例4: serializeGraph
import io.protostuff.GraphIOUtil; //導入方法依賴的package包/類
private static <T> byte[] serializeGraph(T object)
{
@SuppressWarnings("unchecked")
Class<T> clazz = (Class<T>) object.getClass();
Schema<T> schema = RuntimeSchema.getSchema(clazz);
return GraphIOUtil.toByteArray(object, schema, LinkedBuffer.allocate());
}