当前位置: 首页>>代码示例>>Java>>正文


Java Schema.mergeFrom方法代码示例

本文整理汇总了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;
}
 
开发者ID:dmart28,项目名称:reveno,代码行数:23,代码来源:ProtostuffSerializer.java

示例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);
}
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:19,代码来源:ClientHttpProtostuffDecoder.java

示例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;
}
 
开发者ID:protostuff,项目名称:protostuff,代码行数:18,代码来源:PolymorphicPojoMapSchema.java

示例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);
  }
}
 
开发者ID:cloud-software-foundation,项目名称:c5-replicator,代码行数:13,代码来源:OLogProtostuffContent.java

示例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)
  );
}
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:16,代码来源:ServerDecodeCommandRequest.java

示例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;
}
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:30,代码来源:ByteBufInput.java

示例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;
}
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:13,代码来源:ByteBufInput.java

示例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;
}
 
开发者ID:BFergerson,项目名称:Beam,代码行数:66,代码来源:NumberSchema.java

示例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);
}
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:17,代码来源:ServerHttpProtostuffDecoder.java


注:本文中的io.protostuff.Schema.mergeFrom方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。