Java Code Examples for io.protostuff.Input#readString()

The following examples show how to use io.protostuff.Input#readString() . 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: FastIdStrategy.java    From turbo-rpc with Apache License 2.0 6 votes vote down vote up
@Override
protected MapSchema.MessageFactory resolveMapFrom(Input input) throws IOException {
	final String className = input.readString();
	MapSchema.MessageFactory factory = mapMapping.get(className);
	if (factory == null) {
		if (className.indexOf('.') == -1) {
			factory = MapSchema.MessageFactories.valueOf(className);
		} else {
			factory = new RuntimeMapFactory(RuntimeEnv.loadClass(className));
			MapSchema.MessageFactory f = mapMapping.putIfAbsent(className, factory);
			if (f != null)
				factory = f;
		}
	}

	return factory;
}
 
Example 2
Source File: DefaultIdStrategy.java    From protostuff with Apache License 2.0 6 votes vote down vote up
@Override
protected CollectionSchema.MessageFactory resolveCollectionFrom(Input input)
        throws IOException
{
    final String className = input.readString();
    CollectionSchema.MessageFactory factory = collectionMapping
            .get(className);
    if (factory == null)
    {
        if (className.indexOf('.') == -1 && CollectionSchema.MessageFactories.accept(className))
        {
            factory = CollectionSchema.MessageFactories.valueOf(className);
        }
        else
        {
            factory = new RuntimeCollectionFactory(
                    RuntimeEnv.loadClass(className));
            CollectionSchema.MessageFactory f = collectionMapping
                    .putIfAbsent(className, factory);
            if (f != null)
                factory = f;
        }
    }

    return factory;
}
 
Example 3
Source File: DefaultIdStrategy.java    From protostuff with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example 4
Source File: ProtostuffCodecTest.java    From c5-replicator with Apache License 2.0 6 votes vote down vote up
@Override
public void mergeFrom(Input input, SerObj message) throws IOException {
  for (int number = input.readFieldNumber(this); ; number = input.readFieldNumber(this)) {
    switch (number) {
      case 0:
        return;

      case 1:
        message.id = input.readInt32();
        break;

      case 2:
        message.desc = input.readString();
        break;

      case 3:
        message.timestamp = input.readInt64();
        break;

      case 4:
        message.cost = input.readDouble();
        break;
    }
  }
}
 
Example 5
Source File: FieldStat.java    From datawave with Apache License 2.0 6 votes vote down vote up
@Override
public void mergeFrom(Input input, FieldStat message) throws IOException {
    int number;
    while ((number = input.readFieldNumber(this)) != 0) {
        switch (number) {
            case 1:
                message.field = input.readString();
                break;
            case 2:
                message.unique = input.readUInt64();
                break;
            case 3:
                message.observed = input.readUInt64();
                break;
            case 4:
                message.selectivity = input.readDouble();
                break;
            default:
                input.handleUnknownField(number, this);
        }
    }
    
}
 
Example 6
Source File: DefaultFieldCardinality.java    From datawave with Apache License 2.0 6 votes vote down vote up
@Override
public void mergeFrom(Input input, DefaultFieldCardinality message) throws IOException {
    int number;
    while ((number = input.readFieldNumber(this)) != 0) {
        switch (number) {
            case 1:
                message.columnVisibility = input.readString();
                break;
            case 2:
                message.cardinality = input.readUInt64();
                break;
            case 3:
                message.lower = input.readString();
                break;
            case 4:
                message.upper = input.readString();
                break;
            default:
                input.handleUnknownField(number, this);
                break;
        }
    }
}
 
Example 7
Source File: EdgeSummaryQueryMessage.java    From datawave with Apache License 2.0 6 votes vote down vote up
@Override
public void mergeFrom(Input input, EdgeSummaryQueryMessage message) throws IOException {
    int number;
    while ((number = input.readFieldNumber(this)) != 0) {
        switch (number) {
            case 1:
                message.scanLimitHit = input.readBool();
                break;
            case 2:
                message.queryLogicWarning = input.readString();
                break;
            default:
                input.handleUnknownField(number, this);
                break;
        }
    }
}
 
Example 8
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 9
Source File: FastIdStrategy.java    From turbo-rpc with Apache License 2.0 6 votes vote down vote up
@Override
protected CollectionSchema.MessageFactory resolveCollectionFrom(Input input) throws IOException {
	final String className = input.readString();
	CollectionSchema.MessageFactory factory = collectionMapping.get(className);
	if (factory == null) {
		if (className.indexOf('.') == -1) {
			factory = CollectionSchema.MessageFactories.valueOf(className);
		} else {
			factory = new RuntimeCollectionFactory(RuntimeEnv.loadClass(className));
			CollectionSchema.MessageFactory f = collectionMapping.putIfAbsent(className, factory);
			if (f != null)
				factory = f;
		}
	}

	return factory;
}
 
Example 10
Source File: DefaultIdStrategy.java    From protostuff with Apache License 2.0 5 votes vote down vote up
@Override
protected <T> HasSchema<T> resolvePojoFrom(Input input, 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);

    return wrapper;
}
 
Example 11
Source File: DefaultField.java    From datawave with Apache License 2.0 5 votes vote down vote up
@Override
public void mergeFrom(Input input, DefaultField message) throws IOException {
    int number;
    while ((number = input.readFieldNumber(this)) != 0) {
        switch (number) {
            case 1:
                message.markings = new HashMap<String,String>();
                input.mergeObject(message.markings, MapSchema.SCHEMA);
                break;
            case 2:
                message.columnVisibility = input.readString();
                break;
            case 3:
                message.timestamp = input.readUInt64();
                break;
            case 4:
                message.name = input.readString();
                break;
            case 5:
                message.value = input.mergeObject(null, TypedValue.getSchema());
                break;
            default:
                input.handleUnknownField(number, this);
                break;
        }
    }
}
 
Example 12
Source File: DefaultEdgeQueryResponse.java    From datawave with Apache License 2.0 5 votes vote down vote up
public void mergeFrom(Input input, DefaultEdgeQueryResponse message) throws IOException {
    LinkedList<QueryExceptionType> exceptions = null;
    int number;
    while ((number = input.readFieldNumber(this)) != 0) {
        switch (number) {
            case 1:
                message.setQueryId(input.readString());
                break;
            case 2:
                message.setLogicName(input.readString());
                break;
            case 3:
                message.setOperationTimeMS(input.readUInt64());
                break;
            case 4:
                message.addMessage(input.readString());
                break;
            case 5:
                if (exceptions == null)
                    exceptions = new LinkedList<QueryExceptionType>();
                exceptions.add(input.mergeObject(null, QueryExceptionType.getSchema()));
                break;
            case 6:
                message.securityMarkings = input.readString();
                break;
            case 7:
                if (message.edges == null)
                    message.edges = new ArrayList<DefaultEdge>();
                message.edges.add(input.mergeObject(null, DefaultEdge.getSchema()));
                break;
            default:
                input.handleUnknownField(number, this);
                break;
        }
    }
    if (exceptions != null)
        message.setExceptions(exceptions);
}
 
Example 13
Source File: ArraySchemas.java    From protostuff with Apache License 2.0 5 votes vote down vote up
@Override
public Object readFrom(Input input, Object owner) throws IOException
{
    if (ID_ARRAY_LEN != input.readFieldNumber(this))
        throw new ProtostuffException("Corrupt input.");

    final int len = input.readInt32();

    String[] array = new String[len];
    if (input instanceof GraphInput)
    {
        // update the actual reference.
        ((GraphInput) input).updateLast(array, owner);
    }

    for (int i = 0; i < len;)
    {
        switch (input.readFieldNumber(this))
        {
            case ID_ARRAY_DATA:
                array[i++] = input.readString();
                break;
            case ID_ARRAY_NULLCOUNT:
                i += input.readUInt32();
                break;
            default:
                throw new ProtostuffException("Corrupt input.");
        }
    }

    if (0 != input.readFieldNumber(this))
        throw new ProtostuffException("Corrupt input.");

    return array;
}
 
Example 14
Source File: ArraySchemas.java    From protostuff with Apache License 2.0 5 votes vote down vote up
@Override
public Object readFrom(Input input, Object owner) throws IOException
{
    if (ID_ARRAY_LEN != input.readFieldNumber(this))
        throw new ProtostuffException("Corrupt input.");

    final int len = input.readInt32();

    BigDecimal[] array = new BigDecimal[len];
    if (input instanceof GraphInput)
    {
        // update the actual reference.
        ((GraphInput) input).updateLast(array, owner);
    }

    for (int i = 0; i < len;)
    {
        switch (input.readFieldNumber(this))
        {
            case ID_ARRAY_DATA:
                array[i++] = new BigDecimal(input.readString());
                break;
            case ID_ARRAY_NULLCOUNT:
                i += input.readUInt32();
                break;
            default:
                throw new ProtostuffException("Corrupt input.");
        }
    }

    if (0 != input.readFieldNumber(this))
        throw new ProtostuffException("Corrupt input.");

    return array;
}
 
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> resolveDelegateFrom(Input input)
        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)");

    return hd;
}
 
Example 16
Source File: DefaultEdge.java    From datawave with Apache License 2.0 4 votes vote down vote up
@Override
public void mergeFrom(Input input, DefaultEdge message) throws IOException {
    ArrayList<Long> counts = new ArrayList<Long>();
    int number;
    while ((number = input.readFieldNumber(this)) != 0) {
        switch (number) {
            case 1:
                message.columnVisibility = input.readString();
                break;
            case 2:
                message.source = input.readString();
                break;
            case 3:
                message.sink = input.readString();
                break;
            case 4:
                message.edgeType = input.readString();
                break;
            case 5:
                message.edgeRelationship = input.readString();
                break;
            case 6:
                message.edgeAttribute1Source = input.readString();
                break;
            case 7:
                message.statsType = input.readString();
                break;
            case 8:
                message.date = input.readString();
                break;
            case 9:
                message.count = input.readUInt64();
                break;
            case 10:
                counts.add(input.readUInt64());
                break;
            case 11:
                message.edgeAttribute3 = input.readString();
                break;
            case 12:
                message.edgeAttribute2 = input.readString();
                break;
            case 13:
                message.loadDate = input.readString();
                break;
            case 14:
                message.activityDate = input.readString();
                break;
            default:
                input.handleUnknownField(number, this);
                break;
        }
    }
    if (!counts.isEmpty()) {
        message.counts = new ArrayList<Long>(counts.size());
        for (int i = 0; i < message.counts.size(); ++i) {
            message.counts.set(i, counts.get(i));
        }
    }
}
 
Example 17
Source File: QueryImpl.java    From datawave with Apache License 2.0 4 votes vote down vote up
public void mergeFrom(Input input, QueryImpl message) throws IOException {
    int number;
    while ((number = input.readFieldNumber(this)) != 0) {
        switch (number) {
            case 1:
                message.queryLogicName = input.readString();
                break;
            case 2:
                message.id = input.readString();
                break;
            case 3:
                message.queryName = input.readString();
                break;
            case 4:
                message.userDN = input.readString();
                break;
            case 5:
                message.query = input.readString();
                break;
            
            case 6:
                message.beginDate = new Date(input.readInt64());
                break;
            case 7:
                message.endDate = new Date(input.readInt64());
                break;
            case 8:
                message.queryAuthorizations = input.readString();
                break;
            case 9:
                message.expirationDate = new Date(input.readInt64());
                break;
            case 10:
                message.pagesize = input.readUInt32();
                break;
            case 11:
                if (message.parameters == null)
                    message.parameters = new HashSet<Parameter>();
                Parameter p = input.mergeObject(null, Parameter.SCHEMA);
                message.addParameter(p.getParameterName(), p.getParameterValue());
                break;
            case 12:
                message.owner = input.readString();
                break;
            case 13:
                if (null == message.dnList)
                    message.dnList = new ArrayList<String>();
                message.dnList.add(input.readString());
                break;
            case 14:
                message.columnVisibility = input.readString();
                break;
            case 15:
                message.pageTimeout = input.readUInt32();
                break;
            default:
                input.handleUnknownField(number, this);
                break;
        }
    }
}
 
Example 18
Source File: RuntimeUnsafeFieldFactory.java    From protostuff with Apache License 2.0 4 votes vote down vote up
@Override
public BigDecimal readFrom(Input input) throws IOException
{
    return new BigDecimal(input.readString());
}
 
Example 19
Source File: RuntimeReflectionFieldFactory.java    From protostuff with Apache License 2.0 4 votes vote down vote up
@Override
public String readFrom(Input input) throws IOException
{
    return input.readString();
}
 
Example 20
Source File: RuntimeReflectionFieldFactory.java    From protostuff with Apache License 2.0 4 votes vote down vote up
@Override
public BigDecimal readFrom(Input input) throws IOException
{
    return new BigDecimal(input.readString());
}