本文整理汇总了Java中com.dyuproject.protostuff.LinkedBuffer.clear方法的典型用法代码示例。如果您正苦于以下问题:Java LinkedBuffer.clear方法的具体用法?Java LinkedBuffer.clear怎么用?Java LinkedBuffer.clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.dyuproject.protostuff.LinkedBuffer
的用法示例。
在下文中一共展示了LinkedBuffer.clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: serialize
import com.dyuproject.protostuff.LinkedBuffer; //导入方法依赖的package包/类
/**
* 序列化对象
*
* @param obj
* @return
*/
public static <T> byte[] serialize(T obj) {
if (obj == null) {
throw new RuntimeException("序列化对象(" + obj + ")!");
}
@SuppressWarnings("unchecked")
Schema<T> schema = (Schema<T>) RuntimeSchema.getSchema(obj.getClass());
LinkedBuffer buffer = LinkedBuffer.allocate(1024 * 1024);
byte[] protostuff = null;
try {
protostuff = ProtostuffIOUtil.toByteArray(obj, schema, buffer);
} catch (Exception e) {
throw new RuntimeException("序列化(" + obj.getClass() + ")对象(" + obj + ")发生异常!", e);
} finally {
buffer.clear();
}
return protostuff;
}
示例2: serialize
import com.dyuproject.protostuff.LinkedBuffer; //导入方法依赖的package包/类
/**
* 序列化对象
*
* @param obj 需要序更列化的对象
* @return byte []
* @throws TccException
*/
@Override
public byte[] serialize(Object obj) throws TccException {
Class cls = obj.getClass();
LinkedBuffer buffer = LinkedBuffer.allocate(LinkedBuffer.DEFAULT_BUFFER_SIZE);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
try {
Schema schema = getSchema(cls);
ProtostuffIOUtil.writeTo(outputStream, obj, schema, buffer);
} catch (Exception e) {
throw new TccException(e.getMessage(), e);
} finally {
buffer.clear();
}
return outputStream.toByteArray();
}
示例3: serialize
import com.dyuproject.protostuff.LinkedBuffer; //导入方法依赖的package包/类
/**
* 序列化对象
*
* @param obj 需要序更列化的对象
* @return byte []
* @throws MythException 异常信息
*/
@Override
public byte[] serialize(Object obj) throws MythException {
Class cls = obj.getClass();
LinkedBuffer buffer = LinkedBuffer.allocate(LinkedBuffer.DEFAULT_BUFFER_SIZE);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
try {
Schema schema = getSchema(cls);
ProtostuffIOUtil.writeTo(outputStream, obj, schema, buffer);
} catch (Exception e) {
throw new MythException(e.getMessage(), e);
} finally {
buffer.clear();
}
return outputStream.toByteArray();
}
示例4: serialize
import com.dyuproject.protostuff.LinkedBuffer; //导入方法依赖的package包/类
@Override
public void serialize(OutputStream output, Object object) {
Class cls = object.getClass();
LinkedBuffer buffer = LinkedBuffer.allocate(LinkedBuffer.DEFAULT_BUFFER_SIZE);
try {
Schema schema = getSchema(cls);
ProtostuffIOUtil.writeTo(output, object, schema, buffer);
} catch (Exception e) {
throw new IllegalStateException(e.getMessage(), e);
} finally {
buffer.clear();
}
}
示例5: serialize
import com.dyuproject.protostuff.LinkedBuffer; //导入方法依赖的package包/类
/**
* 序列化对象
*
* @param obj 需要序更列化的对象
* @return byte []
* @throws TransactionException
*/
@Override
public byte[] serialize(Object obj) throws TransactionException {
Class cls = obj.getClass();
LinkedBuffer buffer = LinkedBuffer.allocate(LinkedBuffer.DEFAULT_BUFFER_SIZE);
try ( ByteArrayOutputStream outputStream = new ByteArrayOutputStream();){
Schema schema = getSchema(cls);
ProtostuffIOUtil.writeTo(outputStream, obj, schema, buffer);
return outputStream.toByteArray();
} catch (Exception e) {
throw new TransactionException(e.getMessage(), e);
} finally {
buffer.clear();
}
}
示例6: serialize
import com.dyuproject.protostuff.LinkedBuffer; //导入方法依赖的package包/类
@Override
public byte[] serialize(Object obj) throws SerializerException {
Class cls = obj.getClass();
LinkedBuffer buffer = LinkedBuffer.allocate(LinkedBuffer.DEFAULT_BUFFER_SIZE);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
try {
Schema schema = getSchema(cls);
ProtostuffIOUtil.writeTo(outputStream, obj, schema, buffer);
} catch (Exception e) {
throw new SerializerException(e.getMessage(), e);
} finally {
buffer.clear();
}
return outputStream.toByteArray();
}
示例7: serialize
import com.dyuproject.protostuff.LinkedBuffer; //导入方法依赖的package包/类
public byte[] serialize(Object object) {
if(object == null){
return null;
}
LinkedBuffer buffer = LinkedBuffer.allocate(LinkedBuffer.DEFAULT_BUFFER_SIZE);
try {
//return ProtobufIOUtil.toByteArray(new ObjectWrapper(object), schema, buffer);
return ProtostuffIOUtil.toByteArray(new ObjectWrapper(object), schema, buffer);
} finally {
buffer.clear();
}
}
示例8: serialize
import com.dyuproject.protostuff.LinkedBuffer; //导入方法依赖的package包/类
public <T> byte[] serialize(T obj) {
Class<T> cls = (Class<T>) obj.getClass();
LinkedBuffer buffer = LinkedBuffer.allocate(LinkedBuffer.DEFAULT_BUFFER_SIZE);
try {
Schema<T> schema = getSchema(cls);
return ProtostuffIOUtil.toByteArray(obj, schema, buffer);
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
buffer.clear();
}
}
示例9: serialize
import com.dyuproject.protostuff.LinkedBuffer; //导入方法依赖的package包/类
@Override
public byte[] serialize(Object msg) throws IOException {
LinkedBuffer buffer = LinkedBuffer.allocate(LinkedBuffer.DEFAULT_BUFFER_SIZE);
try {
Schema schema = getSchema(msg.getClass());
byte[] arr = ProtostuffIOUtil.toByteArray(msg, schema, buffer);
return arr;
} finally {
buffer.clear();
}
}
示例10: serialize
import com.dyuproject.protostuff.LinkedBuffer; //导入方法依赖的package包/类
public void serialize(OutputStream output, Object object) {
Class cls = (Class) object.getClass();
LinkedBuffer buffer = LinkedBuffer.allocate(LinkedBuffer.DEFAULT_BUFFER_SIZE);
try {
Schema schema = getSchema(cls);
ProtostuffIOUtil.writeTo(output, object, schema, buffer);
} catch (Exception e) {
throw new IllegalStateException(e.getMessage(), e);
} finally {
buffer.clear();
}
}
示例11: serialize
import com.dyuproject.protostuff.LinkedBuffer; //导入方法依赖的package包/类
@Override
public <T> byte[] serialize(T obj) throws IOException {
Class cls = obj.getClass();
LinkedBuffer buffer = LinkedBuffer.allocate(LinkedBuffer.DEFAULT_BUFFER_SIZE);
try {
Schema<T> schema = getSchema(cls);
return ProtostuffIOUtil.toByteArray(obj, schema, buffer);
} catch (Exception e) {
throw new IllegalStateException(e.getMessage(), e);
} finally {
buffer.clear();
}
}
示例12: serialize
import com.dyuproject.protostuff.LinkedBuffer; //导入方法依赖的package包/类
@Override
public byte[] serialize(Object obj) throws SerializationException {
LinkedBuffer buffer = LinkedBuffer.allocate(1024);
try {
Schema schema = getSchema(obj.getClass());
return ProtostuffIOUtil.toByteArray(obj, schema, buffer);
} catch (Throwable e) {
throw new SerializationException(e.getMessage(), e);
} finally {
buffer.clear();
}
}
示例13: serialize
import com.dyuproject.protostuff.LinkedBuffer; //导入方法依赖的package包/类
@Override
public <T> byte[] serialize(T obj) {
@SuppressWarnings("unchecked")
Class<T> cls = (Class<T>) obj.getClass();
LinkedBuffer buffer = LinkedBuffer.allocate(LinkedBuffer.DEFAULT_BUFFER_SIZE);
try {
Schema<T> schema = getSchema(cls);
return ProtostuffIOUtil.toByteArray(obj, schema, buffer);
} catch (Exception e) {
throw new IllegalStateException(e.getMessage(), e);
} finally {
buffer.clear();
}
}
示例14: encode
import com.dyuproject.protostuff.LinkedBuffer; //导入方法依赖的package包/类
@Override
protected void encode(ChannelHandlerContext ctx, Object msg, ByteBuf out) throws Exception {
LinkedBuffer buffer = LinkedBuffer.allocate(LinkedBuffer.DEFAULT_BUFFER_SIZE);
try {
Schema<T> schema = SchemaCache.getSchema(type);
byte[] arr = ProtostuffIOUtil.toByteArray((T)msg, schema, buffer);
out.writeBytes(arr);
} finally {
buffer.clear();
}
}
示例15: encode
import com.dyuproject.protostuff.LinkedBuffer; //导入方法依赖的package包/类
@Override
public byte[] encode(Object msg) throws IOException {
LinkedBuffer buffer = LinkedBuffer.allocate(LinkedBuffer.DEFAULT_BUFFER_SIZE);
try {
Schema schema = getSchema(msg.getClass());
byte[] arr = ProtostuffIOUtil.toByteArray(msg, schema, buffer);
return arr;
} finally {
buffer.clear();
}
}