本文整理汇总了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);
}
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}