本文整理汇总了Java中io.protostuff.Schema.mergeFrom方法的典型用法代码示例。如果您正苦于以下问题:Java Schema.mergeFrom方法的具体用法?Java Schema.mergeFrom怎么用?Java Schema.mergeFrom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.protostuff.Schema
的用法示例。
在下文中一共展示了Schema.mergeFrom方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deserializeObject
import io.protostuff.Schema; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public Object deserializeObject(Buffer buffer) {
Input input = new ZeroCopyBufferInput(buffer, true);
byte type = buffer.readByte();
Schema<Object> schema;
if (type == CRC32_TYPE) {
long crc = buffer.readLong();
schema = (Schema<Object>) registeredCrc.get(crc).schema;
} else {
schema = (Schema<Object>) registeredSha1.get(buffer, SHA1_DIGEST_SIZE).schema;
}
int size = buffer.readInt();
Object message = schema.newMessage();
try {
buffer.limitNext(size);
schema.mergeFrom(input, message);
buffer.resetNextLimit();
} catch (Exception e) {
throw new RuntimeException(e);
}
return message;
}
示例2: decode
import io.protostuff.Schema; //导入方法依赖的package包/类
@Override
protected void decode(ChannelHandlerContext ctx, FullHttpResponse response, List<Object> out) throws Exception {
String protostuffJavaMessageType = response.headers().get(HttpProtostuffConstants.PROTOSTUFF_HEADER_NAME);
// All of these may throw exceptions, use netty default handling
Class<?> protostuffClass = Class.forName(protostuffJavaMessageType);
Schema<Message<?>> protostuffSchemaInstance = (Schema<Message<?>>) protostuffClass.newInstance();
Message<?> resultingMessage = protostuffSchemaInstance.newMessage();
// TODO do we do anything with HTTP status?
ByteBuffer content = response.content().nioBuffer();
ByteBufferInput protostuffDecoder = new ByteBufferInput(content, false);
protostuffSchemaInstance.mergeFrom(protostuffDecoder, resultingMessage);
out.add(resultingMessage);
}
示例3: readObjectFrom
import io.protostuff.Schema; //导入方法依赖的package包/类
static Object readObjectFrom(Input input, Schema<?> schema, Object owner,
IdStrategy strategy, int number) throws IOException
{
final Schema<Object> derivedSchema = strategy.resolvePojoFrom(input,
number).getSchema();
final Object pojo = derivedSchema.newMessage();
if (input instanceof GraphInput)
{
// update the actual reference.
((GraphInput) input).updateLast(pojo, owner);
}
derivedSchema.mergeFrom(input, pojo);
return pojo;
}
示例4: deserialize
import io.protostuff.Schema; //导入方法依赖的package包/类
public static <T extends Schema<T> & Message<T>> OLogProtostuffContent<T> deserialize(ByteBuffer buffer,
Schema<T> schema) {
final ByteBufferInput input = new ByteBufferInput(buffer, false);
final T message = schema.newMessage();
try {
schema.mergeFrom(input, message);
return new OLogProtostuffContent<>(message);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
示例5: decode
import io.protostuff.Schema; //导入方法依赖的package包/类
@Override
protected void decode(ChannelHandlerContext ctx, ControlWireMessage msg, List<Object> out) throws Exception {
Class<?> protostuffClass = Class.forName(msg.getSubType());
Schema<Message<?>> protostuffSchemaInstance = (Schema<Message<?>>) protostuffClass.newInstance();
Message<?> resultingMessage = protostuffSchemaInstance.newMessage();
ByteBuffer fromMsg = msg.getSubMessage();
ByteBufferInput input = new ByteBufferInput(fromMsg, false);
protostuffSchemaInstance.mergeFrom(input, resultingMessage);
out.add(
new CommandRpcRequest(msg.getReceipientNodeId(), resultingMessage)
);
}
示例6: mergeObject
import io.protostuff.Schema; //导入方法依赖的package包/类
public <T> T mergeObject(T value, final Schema<T> schema) throws IOException {
if (decodeNestedMessageAsGroup) {
return mergeObjectEncodedAsGroup(value, schema);
}
final int length = readRawVarint32();
if (length < 0) {
throw negativeSize();
}
if (!buffer.isReadable(length)) {
throw misreportedSize();
}
ByteBuf dup = buffer.slice(buffer.readerIndex(), length);
if (value == null) {
value = schema.newMessage();
}
ByteBufInput nestedInput = new ByteBufInput(dup, decodeNestedMessageAsGroup);
schema.mergeFrom(nestedInput, value);
if (!schema.isInitialized(value)) {
throw new UninitializedMessageException(value, schema);
}
nestedInput.checkLastTagWas(0);
buffer.skipBytes(length);
return value;
}
示例7: mergeObjectEncodedAsGroup
import io.protostuff.Schema; //导入方法依赖的package包/类
private <T> T mergeObjectEncodedAsGroup(T value, final Schema<T> schema) throws IOException {
if (value == null) {
value = schema.newMessage();
}
schema.mergeFrom(this, value);
if (!schema.isInitialized(value)) {
throw new UninitializedMessageException(value, schema);
}
// handling is in #readFieldNumber
checkLastTagWas(0);
return value;
}
示例8: readObjectFrom
import io.protostuff.Schema; //导入方法依赖的package包/类
static Object readObjectFrom(Input input, Schema<?> schema, Object owner,
IdStrategy strategy) throws IOException
{
final int number = input.readFieldNumber(schema);
if (number == ID_POJO)
{
// AtomicInteger/AtomicLong
final Schema<Object> derivedSchema = strategy.resolvePojoFrom(
input, number).getSchema();
final Object pojo = derivedSchema.newMessage();
if (input instanceof GraphInput)
{
// update the actual reference.
((GraphInput) input).updateLast(pojo, owner);
}
derivedSchema.mergeFrom(input, pojo);
return pojo;
}
final Object value;
switch (number)
{
case ID_BYTE:
value = BYTE.readFrom(input);
break;
case ID_SHORT:
value = SHORT.readFrom(input);
break;
case ID_INT32:
value = INT32.readFrom(input);
break;
case ID_INT64:
value = INT64.readFrom(input);
break;
case ID_FLOAT:
value = FLOAT.readFrom(input);
break;
case ID_DOUBLE:
value = DOUBLE.readFrom(input);
break;
case ID_BIGDECIMAL:
value = BIGDECIMAL.readFrom(input);
break;
case ID_BIGINTEGER:
value = BIGINTEGER.readFrom(input);
break;
default:
throw new ProtostuffException("Corrupt input.");
}
if (input instanceof GraphInput)
{
// update the actual reference.
((GraphInput) input).updateLast(value, owner);
}
if (0 != input.readFieldNumber(schema))
throw new ProtostuffException("Corrupt input.");
return value;
}
示例9: decode
import io.protostuff.Schema; //导入方法依赖的package包/类
@Override
protected void decode(ChannelHandlerContext ctx, FullHttpRequest request, List<Object> out) throws Exception {
String protostuffJavaMessageType = request.headers().get(HttpProtostuffConstants.PROTOSTUFF_HEADER_NAME);
Class<?> protostuffClass = Class.forName(protostuffJavaMessageType);
Schema<Message<?>> protostuffSchemaInstance = (Schema<Message<?>>) protostuffClass.newInstance();
Message<?> resultingMessage = protostuffSchemaInstance.newMessage();
ByteBuffer content = request.content().nioBuffer();
ByteBufferInput protostuffDecoder = new ByteBufferInput(content, false);
protostuffSchemaInstance.mergeFrom(protostuffDecoder, resultingMessage);
out.add(resultingMessage);
}