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


Java Output.writeString方法代码示例

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


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

示例1: writeMapIdTo

import io.protostuff.Output; //导入方法依赖的package包/类
@Override
protected void writeMapIdTo(Output output, int fieldNumber, Class<?> clazz)
        throws IOException
{
    final MapSchema.MessageFactory factory = mapMapping.get(clazz);
    if (factory == null && clazz.getName().startsWith("java.util"))
    {
        // jdk map
        // better not to register the jdk map 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,代码行数:18,代码来源:DefaultIdStrategy.java

示例2: transferDelegateId

import io.protostuff.Output; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected <T> HasDelegate<T> transferDelegateId(Input input, Output output,
        int fieldNumber) throws IOException
{
    final String className = input.readString();

    final HasDelegate<T> hd = (HasDelegate<T>) delegateMapping
            .get(className);
    if (hd == null)
        throw new UnknownTypeException("delegate: " + className
                + " (Outdated registry)");

    output.writeString(fieldNumber, className, false);

    return hd;
}
 
开发者ID:BFergerson,项目名称:Beam,代码行数:18,代码来源:DefaultIdStrategy.java

示例3: transferPojoId

import io.protostuff.Output; //导入方法依赖的package包/类
@Override
protected <T> HasSchema<T> transferPojoId(Input input, Output output,
        int fieldNumber) throws IOException
{
    final String className = input.readString();

    final HasSchema<T> wrapper = getSchemaWrapper(className,
            RuntimeEnv.AUTO_LOAD_POLYMORPHIC_CLASSES);
    if (wrapper == null)
    {
        throw new ProtostuffException("polymorphic pojo not registered: "
                + className);
    }

    output.writeString(fieldNumber, className, false);

    return wrapper;
}
 
开发者ID:BFergerson,项目名称:Beam,代码行数:19,代码来源:DefaultIdStrategy.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:protostuff,项目名称:protostuff,代码行数:19,代码来源:DefaultIdStrategy.java

示例5: 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

示例6: tryWriteDelegateIdTo

import io.protostuff.Output; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected <T> HasDelegate<T> tryWriteDelegateIdTo(Output output,
        int fieldNumber, Class<T> clazz) throws IOException
{
    final HasDelegate<T> hd = (HasDelegate<T>) delegateMapping.get(clazz
            .getName());
    if (hd == null)
        return null;

    output.writeString(fieldNumber, clazz.getName(), false);

    return hd;
}
 
开发者ID:protostuff,项目名称:protostuff,代码行数:15,代码来源:DefaultIdStrategy.java

示例7: writeTo

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

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

            output.writeString(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

示例8: writeMessageIdTo

import io.protostuff.Output; //导入方法依赖的package包/类
@Override
protected <T> Schema<T> writeMessageIdTo(Output output, int fieldNumber,
        Message<T> message) throws IOException
{
    output.writeString(fieldNumber, message.getClass().getName(), false);

    return message.cachedSchema();
}
 
开发者ID:protostuff,项目名称:protostuff,代码行数:9,代码来源:DefaultIdStrategy.java

示例9: writePojoIdTo

import io.protostuff.Output; //导入方法依赖的package包/类
@Override
protected <T> HasSchema<T> writePojoIdTo(Output output, int fieldNumber,
        Class<T> clazz) throws IOException
{
    output.writeString(fieldNumber, clazz.getName(), false);

    // it is important to return the schema initialized (if it hasn't been).
    return getSchemaWrapper(clazz, true);
}
 
开发者ID:BFergerson,项目名称:Beam,代码行数:10,代码来源:DefaultIdStrategy.java

示例10: writeArrayIdTo

import io.protostuff.Output; //导入方法依赖的package包/类
@Override
protected void writeArrayIdTo(Output output, Class<?> componentType)
        throws IOException
{
    output.writeString(RuntimeFieldFactory.ID_ARRAY,
            componentType.getName(), false);
}
 
开发者ID:protostuff,项目名称:protostuff,代码行数:8,代码来源:DefaultIdStrategy.java

示例11: 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

示例12: writeTo

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

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

            output.writeString(ID_ARRAY_DATA, v.toString(), true);
        }
        else if (allowNullArrayElement)
        {
            nullCount++;
        }
    }

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

示例13: writeTo

import io.protostuff.Output; //导入方法依赖的package包/类
@Override
public void writeTo(Output output, int number, String value,
        boolean repeated) throws IOException
{
    output.writeString(number, (CharSequence) value, repeated);
}
 
开发者ID:protostuff,项目名称:protostuff,代码行数:7,代码来源:RuntimeReflectionFieldFactory.java

示例14: writeEnumIdTo

import io.protostuff.Output; //导入方法依赖的package包/类
@Override
protected void writeEnumIdTo(Output output, int fieldNumber, Class<?> clazz)
        throws IOException
{
    output.writeString(fieldNumber, clazz.getName(), false);
}
 
开发者ID:protostuff,项目名称:protostuff,代码行数:7,代码来源:DefaultIdStrategy.java

示例15: writeTo

import io.protostuff.Output; //导入方法依赖的package包/类
@Override
public void writeTo(Output output, int number, String value,
        boolean repeated) throws IOException
{
    output.writeString(number, value, repeated);
}
 
开发者ID:BFergerson,项目名称:Beam,代码行数:7,代码来源:RuntimeUnsafeFieldFactory.java


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