• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Output类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中io.protostuff.Output的典型用法代码示例。如果您正苦于以下问题:Java Output类的具体用法?Java Output怎么用?Java Output使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Output类属于io.protostuff包,在下文中一共展示了Output类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: writeTo

import io.protostuff.Output; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected void writeTo(Output output, T message) throws IOException {
  if (!ProtobufFeatureUtils.isUseProtobufMapCodec()) {
    runtimeMapField.writeTo(output, message);
    return;
  }

  final Map<Object, Object> existing;
  try {
    existing = (Map<Object, Object>) field.get(message);
  } catch (Exception e) {
    throw new RuntimeException(e);
  }

  if (existing != null) {
    for (Entry<Object, Object> entry : existing.entrySet()) {
      output.writeObject(number, entry, entrySchema, true);
    }
  }
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:22,代码来源:RuntimeMapFieldProtobuf.java


示例2: writeUnmodifiableCollectionTo

import io.protostuff.Output; //导入依赖的package包/类
private static void writeUnmodifiableCollectionTo(Output output,
        Object value, Schema<?> currentSchema, IdStrategy strategy, int id)
        throws IOException
{
    final Object c;
    try
    {
        c = fUnmodifiableCollection_c.get(value);
    }
    catch (IllegalArgumentException | IllegalAccessException e)
    {
        throw new RuntimeException(e);
    }

    output.writeObject(id, c, strategy.POLYMORPHIC_COLLECTION_SCHEMA, false);
}
 
开发者ID:BFergerson,项目名称:Beam,代码行数:17,代码来源:PolymorphicCollectionSchema.java


示例3: writeObjectTo

import io.protostuff.Output; //导入依赖的package包/类
static void writeObjectTo(Output output, Object value,
        Schema<?> currentSchema, IdStrategy strategy) throws IOException
{
    final Class<?> c = ((Class<?>) value);
    if (c.isArray())
    {
        int dimensions = 1;
        Class<?> componentType = c.getComponentType();
        while (componentType.isArray())
        {
            dimensions++;
            componentType = componentType.getComponentType();
        }

        strategy.writeClassIdTo(output, componentType, true);
        // write the dimensions of the array
        output.writeUInt32(ID_ARRAY_DIMENSION, dimensions, false);
        return;
    }

    strategy.writeClassIdTo(output, c, false);
}
 
开发者ID:protostuff,项目名称:protostuff,代码行数:23,代码来源:ClassSchema.java


示例4: writeCollectionIdTo

import io.protostuff.Output; //导入依赖的package包/类
@Override
protected void writeCollectionIdTo(Output output, int fieldNumber,
        Class<?> clazz) throws IOException
{
    final CollectionSchema.MessageFactory factory = collectionMapping
            .get(clazz);
    if (factory == null && clazz.getName().startsWith("java.util"))
    {
        // jdk collection
        // better not to register the jdk collection if using this strategy
        // as it saves space by not writing the full package
        output.writeString(fieldNumber, clazz.getSimpleName(), false);
    }
    else
    {
        output.writeString(fieldNumber, clazz.getName(), false);
    }
}
 
开发者ID:BFergerson,项目名称:Beam,代码行数:19,代码来源:DefaultIdStrategy.java


示例5: writeObjectTo

import io.protostuff.Output; //导入依赖的package包/类
@SuppressWarnings("unchecked")
static void writeObjectTo(Output output, Object value,
        Schema<?> currentSchema, IdStrategy strategy) throws IOException
{
    final HasSchema<Object> hs = strategy.tryWritePojoIdTo(output, ID_POJO, 
            (Class<Object>)value.getClass(), true);
    
    if (hs == null)
    {
        PolymorphicCollectionSchema.writeObjectTo(output, value, currentSchema, 
                strategy);
        return;
    }
    
    final Schema<Object> schema = hs.getSchema();
    
    if (output instanceof StatefulOutput)
    {
        // update using the derived schema.
        ((StatefulOutput) output).updateLast(schema, currentSchema);
    }
    
    schema.writeTo(output, value);
}
 
开发者ID:protostuff,项目名称:protostuff,代码行数:25,代码来源:PolymorphicPojoCollectionSchema.java


示例6: writeMessageIdTo

import io.protostuff.Output; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected <T> Schema<T> writeMessageIdTo(Output output, int fieldNumber,
        Message<T> message) throws IOException
{
    int id;
    BaseHS<T> wrapper = (BaseHS<T>) getSchemaWrapper(message.getClass(), true);

    // wait till everything is completely set
    while (0 == (id = wrapper.id))
        LockSupport.parkNanos(1);

    output.writeUInt32(fieldNumber, id, false);

    // TODO allow the wrapper to return an override schema?
    return message.cachedSchema();
}
 
开发者ID:protostuff,项目名称:protostuff,代码行数:18,代码来源:IncrementalIdStrategy.java


示例7: writeTo

import io.protostuff.Output; //导入依赖的package包/类
/**
 * Delegates to the schema derived from the {@code value}.
 */
@Override
@SuppressWarnings("unchecked")
public void writeTo(final Output output, final Object value)
        throws IOException
{
    final Schema<Object> schema = strategy.writePojoIdTo(output, ID_POJO,
            (Class<Object>) value.getClass()).getSchema();

    if (output instanceof StatefulOutput)
    {
        // update using the derived schema.
        ((StatefulOutput) output).updateLast(schema, this);
    }

    // write the rest of the fields of the exact type
    schema.writeTo(output, value);
}
 
开发者ID:protostuff,项目名称:protostuff,代码行数:21,代码来源:DerivativeSchema.java


示例8: writeObjectTo

import io.protostuff.Output; //导入依赖的package包/类
@SuppressWarnings("unchecked")
static void writeObjectTo(Output output, Object value,
        Schema<?> currentSchema, IdStrategy strategy) throws IOException
{
    final Schema<Object> schema = strategy.writePojoIdTo(output,
            ID_THROWABLE, (Class<Object>) value.getClass()).getSchema();

    if (output instanceof StatefulOutput)
    {
        // update using the derived schema.
        ((StatefulOutput) output).updateLast(schema, currentSchema);
    }

    if (tryWriteWithoutCause(output, value, schema))
        return;

    schema.writeTo(output, value);
}
 
开发者ID:protostuff,项目名称:protostuff,代码行数:19,代码来源:PolymorphicThrowableSchema.java


示例9: writeUnmodifiableMapTo

import io.protostuff.Output; //导入依赖的package包/类
private static void writeUnmodifiableMapTo(Output output, Object value,
        Schema<?> currentSchema, IdStrategy strategy, int id)
        throws IOException
{
    final Object m;
    try
    {
        m = fUnmodifiableMap_m.get(value);
    }
    catch (IllegalArgumentException | IllegalAccessException e)
    {
        throw new RuntimeException(e);
    }

    output.writeObject(id, m, strategy.POLYMORPHIC_MAP_SCHEMA, false);
}
 
开发者ID:BFergerson,项目名称:Beam,代码行数:17,代码来源:PolymorphicMapSchema.java


示例10: writeObject

import io.protostuff.Output; //导入依赖的package包/类
default void writeObject(Output output, Object value, ProtobufFeature protobufFeature) throws Exception {
  ProtobufFeatureUtils.setProtobufFeature(protobufFeature);
  try {
    writeObject(output, value);
  } finally {
    ProtobufFeatureUtils.removeProtobufFeature();
  }
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:9,代码来源:WrapSchema.java


示例11: writeObject

import io.protostuff.Output; //导入依赖的package包/类
public void writeObject(Output output, Object value) throws IOException {
  if (value == null) {
    return;
  }

  schema.writeTo(output, value);
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:8,代码来源:NotWrapSchema.java


示例12: writeObject

import io.protostuff.Output; //导入依赖的package包/类
public void writeObject(Output output, Object value) throws IOException {
  if (value == null) {
    return;
  }

  SingleWrapper wrapper = (SingleWrapper) schema.newMessage();
  wrapper.writeField(value);

  schema.writeTo(output, wrapper);
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:11,代码来源:NormalWrapSchema.java


示例13: writeObject

import io.protostuff.Output; //导入依赖的package包/类
public void writeObject(Output output, Object value) throws IOException {
  Object writeValue = ((Object[]) value)[0];
  if (writeValue == null) {
    return;
  }

  schema.writeTo(output, writeValue);
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:9,代码来源:ArgsNotWrapSchema.java


示例14: writeTo

import io.protostuff.Output; //导入依赖的package包/类
@Override
public void writeTo(Output output, Message message) throws IOException {
  // Write headers
  if (!message.headers().isEmpty()) {
    for (Map.Entry<String, String> headerEntry : message.headers().entrySet()) {
      if (headerEntry.getKey() != null && headerEntry.getValue() != null) {
        output.writeString(HEADER_KEYS_FIELD_NUMBER, headerEntry.getKey(), true);
        output.writeString(HEADER_VALUES_FIELD_NUMBER, headerEntry.getValue(), true);
      }
    }
  }

  // Write data
  Object originalData = message.data();
  if (originalData != null) {
    if (originalData instanceof byte[]) {
      // Write data byte array as is
      output.writeByteArray(DATA_FIELD_NUMBER, (byte[]) originalData, false);
    } else {
      // Write data class as an additional header
      Class<?> dataClass = originalData.getClass();
      output.writeString(HEADER_KEYS_FIELD_NUMBER, Message.HEADER_DATA_TYPE, true);
      output.writeString(HEADER_VALUES_FIELD_NUMBER, dataClass.getName(), true);

      // Write data as serialized byte array
      Schema dataSchema = RuntimeSchema.getSchema(dataClass);
      try (RecyclableLinkedBuffer rlb = recyclableLinkedBuffer.get()) {
        byte[] array = ProtostuffIOUtil.toByteArray(originalData, dataSchema, rlb.buffer());
        output.writeByteArray(DATA_FIELD_NUMBER, array, false);
      }
    }
  }

  // Write sender
  Address sender = message.sender();
  if (sender != null) {
    output.writeString(SENDER_HOST_FIELD_NUMBER, sender.host(), false);
    output.writeInt32(SENDER_PORT_FIELD_NUMBER, sender.port(), false);
  }
}
 
开发者ID:scalecube,项目名称:scalecube,代码行数:41,代码来源:MessageSchema.java


示例15: writeObjectTo

import io.protostuff.Output; //导入依赖的package包/类
@SuppressWarnings("unchecked")
static void writeObjectTo(Output output, Object value,
        Schema<?> currentSchema, IdStrategy strategy) throws IOException
{
    if (Collections.class == value.getClass().getDeclaringClass())
    {
        writeNonPublicCollectionTo(output, value, currentSchema, strategy);
        return;
    }

    if (EnumSet.class.isAssignableFrom(value.getClass()))
    {
        strategy.writeEnumIdTo(output, ID_ENUM_SET,
                EnumIO.getElementTypeFromEnumSet(value));

        // TODO optimize
    }
    else
    {
        strategy.writeCollectionIdTo(output, ID_COLLECTION,
                value.getClass());
    }

    if (output instanceof StatefulOutput)
    {
        // update using the derived schema.
        ((StatefulOutput) output).updateLast(strategy.COLLECTION_SCHEMA,
                currentSchema);
    }

    strategy.COLLECTION_SCHEMA.writeTo(output, (Collection<Object>) value);
}
 
开发者ID:BFergerson,项目名称:Beam,代码行数:33,代码来源:PolymorphicCollectionSchema.java


示例16: transfer

import io.protostuff.Output; //导入依赖的package包/类
@Override
protected void transfer(Pipe pipe, Input input, Output output)
        throws IOException
{
    transferObject(this, pipe, input, output, strategy,
            RuntimeFieldFactory.SHORT);
}
 
开发者ID:protostuff,项目名称:protostuff,代码行数:8,代码来源:ArraySchemas.java


示例17: transfer

import io.protostuff.Output; //导入依赖的package包/类
@Override
protected void transfer(Pipe pipe, Input input, Output output)
        throws IOException
{
    transferObject(this, pipe, input, output, strategy,
            RuntimeFieldFactory.BOOL);
}
 
开发者ID:BFergerson,项目名称:Beam,代码行数:8,代码来源:ArraySchemas.java


示例18: writeClassIdTo

import io.protostuff.Output; //导入依赖的package包/类
@Override
protected void writeClassIdTo(Output output, Class<?> componentType,
        boolean array) throws IOException
{
    final int id = array ? RuntimeFieldFactory.ID_CLASS_ARRAY
            : RuntimeFieldFactory.ID_CLASS;

    output.writeString(id, componentType.getName(), false);
}
 
开发者ID:protostuff,项目名称:protostuff,代码行数:10,代码来源:DefaultIdStrategy.java


示例19: writeTo

import io.protostuff.Output; //导入依赖的package包/类
@Override
public void writeTo(Output output, Object value) throws IOException
{
    byte[][] array = (byte[][]) value;
    output.writeUInt32(ID_ARRAY_LEN, array.length, false);

    int nullCount = 0;
    for (int i = 0, len = array.length; i < len; i++)
    {
        byte[] v = array[i];
        if (v != null)
        {
            if (nullCount != 0)
            {
                output.writeUInt32(ID_ARRAY_NULLCOUNT, nullCount, false);
                nullCount = 0;
            }

            output.writeByteArray(ID_ARRAY_DATA, v, true);
        }
        else if (ALLOW_NULL_ARRAY_ELEMENT)
        {
            nullCount++;
        }
    }

    // if last element is null
    if (nullCount != 0)
        output.writeUInt32(ID_ARRAY_NULLCOUNT, nullCount, false);
}
 
开发者ID:BFergerson,项目名称:Beam,代码行数:31,代码来源:ArraySchemas.java


示例20: writeTo

import io.protostuff.Output; //导入依赖的package包/类
@Override
public void writeTo(Output output, Object array) throws IOException
{
    final int len = Array.getLength(array);

    output.writeInt32(ID_ARRAY_LEN, len, false);

    int nullCount = 0;
    for (int i = 0; i < len; i++)
    {
        Object v = Array.get(array, i);
        if (v != null)
        {
            if (nullCount != 0)
            {
                output.writeUInt32(ID_ARRAY_NULLCOUNT, nullCount, false);
                nullCount = 0;
            }

            output.writeObject(ID_ARRAY_DATA, v, hs.getSchema(), true);
        }
        else if (allowNullArrayElement)
        {
            nullCount++;
        }
    }

    // if last element is null
    if (nullCount != 0)
        output.writeUInt32(ID_ARRAY_NULLCOUNT, nullCount, false);
}
 
开发者ID:protostuff,项目名称:protostuff,代码行数:32,代码来源:ArraySchemas.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java VisiblityData类代码示例发布时间:2022-05-22
下一篇:
Java TileEntityLockableLoot类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap