Java Code Examples for io.protostuff.Output#writeString()

The following examples show how to use io.protostuff.Output#writeString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultIdStrategy.java    From protostuff with Apache License 2.0 6 votes vote down vote up
@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,
            0 != (AUTO_LOAD_POLYMORPHIC_CLASSES & flags));
    if (wrapper == null)
    {
        throw new ProtostuffException("polymorphic pojo not registered: "
                + className);
    }

    output.writeString(fieldNumber, className, false);

    return wrapper;
}
 
Example 2
Source File: QueryImpl.java    From datawave with Apache License 2.0 5 votes vote down vote up
public void writeTo(Output output, Parameter message) throws IOException {
    if (message.parameterName == null)
        throw new UninitializedMessageException(message);
    output.writeString(1, message.parameterName, false);
    
    if (message.parameterValue == null)
        throw new UninitializedMessageException(message);
    output.writeString(2, message.parameterValue, false);
}
 
Example 3
Source File: FileDetails.java    From datawave with Apache License 2.0 5 votes vote down vote up
public void writeTo(Output output, FileDetails message) throws IOException {
    
    if (message.getPath() != null) {
        output.writeString(1, message.getPath(), false);
    }
    if (message.getDate() != null) {
        output.writeUInt64(2, message.getDate().getTime(), false);
    }
    output.writeUInt64(3, message.getSize(), false);
}
 
Example 4
Source File: BulkResultsInfoResponse.java    From datawave with Apache License 2.0 5 votes vote down vote up
public void writeTo(Output output, BulkResultsInfoResponse message) throws IOException {
    
    if (message.user != null) {
        output.writeString(1, message.user, false);
    }
    
    if (message.bulkResultsId != null) {
        output.writeString(2, message.bulkResultsId, false);
    }
    
    if (message.jobDirectory != null) {
        output.writeString(3, message.jobDirectory, false);
    }
    
    if (message.outputDestination != null) {
        output.writeString(4, message.outputDestination, false);
    }
    
    if (message.configuration != null) {
        output.writeString(5, message.configuration, false);
    }
    
    if (message.queryId != null) {
        output.writeString(6, message.queryId, false);
    }
    
    if (message.serializationFormat != null) {
        output.writeString(7, message.serializationFormat, false);
    }
    
    if (message.jobs != null) {
        for (Job job : message.jobs) {
            if (job != null)
                output.writeObject(6, job, Job.getSchema(), true);
        }
    }
}
 
Example 5
Source File: DefaultEdgeQueryResponse.java    From datawave with Apache License 2.0 5 votes vote down vote up
public void writeTo(Output output, DefaultEdgeQueryResponse message) throws IOException {
    
    if (message.getQueryId() != null) {
        output.writeString(1, message.getQueryId(), false);
    }
    
    if (message.getLogicName() != null) {
        output.writeString(2, message.getLogicName(), false);
    }
    
    output.writeUInt64(3, message.getOperationTimeMS(), false);
    
    List<String> messages = message.getMessages();
    if (messages != null) {
        for (String msg : messages) {
            if (msg != null)
                output.writeString(4, msg, true);
        }
    }
    
    List<QueryExceptionType> exceptions = message.getExceptions();
    if (exceptions != null) {
        for (QueryExceptionType exception : exceptions) {
            if (exception != null)
                output.writeObject(5, exception, QueryExceptionType.getSchema(), true);
        }
    }
    
    if (message.securityMarkings != null)
        output.writeString(6, message.securityMarkings, false);
    
    if (message.edges != null) {
        for (DefaultEdge edge : message.edges) {
            if (edge != null)
                output.writeObject(7, edge, DefaultEdge.getSchema(), true);
        }
    }
}
 
Example 6
Source File: FieldStat.java    From datawave with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(Output output, FieldStat message) throws IOException {
    output.writeString(1, message.field, false);
    output.writeUInt64(2, message.unique, false);
    output.writeUInt64(3, message.observed, false);
    output.writeDouble(4, message.selectivity, false);
}
 
Example 7
Source File: DefaultFieldCardinality.java    From datawave with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(Output output, DefaultFieldCardinality message) throws IOException {
    if (message.columnVisibility != null)
        output.writeString(1, message.columnVisibility, false);
    output.writeUInt64(2, message.cardinality, false);
    output.writeString(3, message.lower, false);
    output.writeString(4, message.upper, false);
}
 
Example 8
Source File: DefaultField.java    From datawave with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(Output output, DefaultField message) throws IOException {
    if (message.markings != null)
        output.writeObject(1, message.markings, MapSchema.SCHEMA, false);
    if (message.columnVisibility != null)
        output.writeString(2, message.columnVisibility, false);
    output.writeUInt64(3, message.timestamp, false);
    if (message.name != null)
        output.writeString(4, message.name, false);
    if (message.value != null)
        output.writeObject(5, message.value, message.value.cachedSchema(), false);
}
 
Example 9
Source File: ArraySchemas.java    From protostuff with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 10
Source File: DefaultIdStrategy.java    From protostuff with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example 11
Source File: EnumIO.java    From protostuff with Apache License 2.0 5 votes vote down vote up
/**
 * Writes the {@link Enum} to the output.
 */
public void writeTo(Output output, int number, boolean repeated,
        Enum<?> e) throws IOException
{
    if (0 == (IdStrategy.ENUMS_BY_NAME & strategy.flags))
        output.writeEnum(number, getTag(e), repeated);
    else
        output.writeString(number, getAlias(e), repeated);
}
 
Example 12
Source File: ArraySchemas.java    From protostuff with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(Output output, Object value) throws IOException
{
    CharSequence[] array = (CharSequence []) value;
    output.writeInt32(ID_ARRAY_LEN, array.length, false);

    int nullCount = 0;
    for (int i = 0, len = array.length; i < len; i++)
    {
        CharSequence 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 (allowNullArrayElement)
        {
            nullCount++;
        }
    }

    // if last element is null
    if (nullCount != 0)
        output.writeUInt32(ID_ARRAY_NULLCOUNT, nullCount, false);
}
 
Example 13
Source File: BulkResultsInfoResponse.java    From datawave with Apache License 2.0 5 votes vote down vote up
public void writeTo(Output output, History message) throws IOException {
    if (message.getState() != null) {
        output.writeString(1, message.getState(), false);
    }
    
    if (message.getTimestamp() != null) {
        output.writeUInt64(2, message.getTimestamp(), false);
    }
}
 
Example 14
Source File: DefaultIdStrategy.java    From protostuff with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 15
Source File: DefaultIdStrategy.java    From protostuff with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 16
Source File: DefaultIdStrategy.java    From protostuff with Apache License 2.0 5 votes vote down vote up
@Override
protected <T> HasSchema<T> tryWritePojoIdTo(Output output, int fieldNumber,
        Class<T> clazz, boolean registered) throws IOException
{
    HasSchema<T> hs = getSchemaWrapper(clazz, false);
    if (hs == null || (registered && hs instanceof Lazy<?>))
        return null;
    
    output.writeString(fieldNumber, clazz.getName(), false);
    
    return hs;
}
 
Example 17
Source File: ZoneIdSchema.java    From joyrpc with Apache License 2.0 4 votes vote down vote up
@Override
public void writeTo(final Output output, final ZoneId message) throws IOException {
    output.writeString(1, message.getId(), false);
}
 
Example 18
Source File: QueryImpl.java    From datawave with Apache License 2.0 4 votes vote down vote up
public void writeTo(Output output, QueryImpl message) throws IOException {
    if (message.queryLogicName == null)
        throw new UninitializedMessageException(message, SCHEMA);
    output.writeString(1, message.queryLogicName, false);
    
    if (message.id == null)
        throw new UninitializedMessageException(message, SCHEMA);
    output.writeString(2, message.id, false);
    
    if (message.queryName != null)
        output.writeString(3, message.queryName, false);
    
    if (message.userDN == null)
        throw new UninitializedMessageException(message, SCHEMA);
    output.writeString(4, message.userDN, false);
    
    if (message.query == null)
        throw new UninitializedMessageException(message, SCHEMA);
    output.writeString(5, message.query, false);
    
    if (message.beginDate != null)
        output.writeInt64(6, message.beginDate.getTime(), false);
    
    if (message.endDate != null)
        output.writeInt64(7, message.endDate.getTime(), false);
    
    if (message.queryAuthorizations == null)
        throw new UninitializedMessageException(message, SCHEMA);
    output.writeString(8, message.queryAuthorizations, false);
    
    if (message.expirationDate == null)
        throw new UninitializedMessageException(message, SCHEMA);
    output.writeInt64(9, message.expirationDate.getTime(), false);
    
    if (message.pagesize <= 0)
        throw new UninitializedMessageException(message, SCHEMA);
    output.writeUInt32(10, message.pagesize, false);
    
    if (message.parameters != null) {
        for (Parameter p : message.parameters) {
            output.writeObject(11, p, Parameter.SCHEMA, true);
        }
    }
    
    if (message.owner == null)
        throw new UninitializedMessageException(message, SCHEMA);
    output.writeString(12, message.owner, false);
    
    if (null != message.dnList) {
        for (String dn : message.dnList)
            output.writeString(13, dn, true);
    }
    
    if (message.columnVisibility != null) {
        output.writeString(14, message.columnVisibility, false);
    }
    
    if (message.pageTimeout == 0)
        throw new UninitializedMessageException(message, SCHEMA);
    output.writeUInt32(15, message.pageTimeout, false);
}
 
Example 19
Source File: FastIdStrategy.java    From turbo-rpc with Apache License 2.0 4 votes vote down vote up
@Override
protected void writeArrayIdTo(Output output, Class<?> componentType) throws IOException {
	output.writeString(RuntimeFieldFactory.ID_ARRAY, componentType.getName(), false);
}
 
Example 20
Source File: LocaleSchema.java    From joyrpc with Apache License 2.0 4 votes vote down vote up
@Override
public void writeTo(final Output output, final Locale message) throws IOException {
    output.writeString(1, message.toString(), false);
}