Example usage for com.fasterxml.jackson.core JsonParser nextTextValue

List of usage examples for com.fasterxml.jackson.core JsonParser nextTextValue

Introduction

In this page you can find the example usage for com.fasterxml.jackson.core JsonParser nextTextValue.

Prototype

public String nextTextValue() throws IOException, JsonParseException 

Source Link

Document

Method that fetches next token (as if calling #nextToken ) and if it is JsonToken#VALUE_STRING returns contained String value; otherwise returns null.

Usage

From source file:com.msopentech.odatajclient.engine.data.metadata.edm.SchemaDeserializer.java

@Override
public Schema deserialize(final JsonParser jp, final DeserializationContext ctxt)
        throws IOException, JsonProcessingException {

    final Schema schema = new Schema();

    for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
        final JsonToken token = jp.getCurrentToken();
        if (token == JsonToken.FIELD_NAME) {
            if ("Namespace".equals(jp.getCurrentName())) {
                schema.setNamespace(jp.nextTextValue());
            } else if ("Alias".equals(jp.getCurrentName())) {
                schema.setAlias(jp.nextTextValue());
            } else if ("Using".equals(jp.getCurrentName())) {
                jp.nextToken();//from  w  w w . j  av  a  2s. c  o m
                schema.getUsings().add(jp.getCodec().readValue(jp, Using.class));
            } else if ("Association".equals(jp.getCurrentName())) {
                jp.nextToken();
                schema.getAssociations().add(jp.getCodec().readValue(jp, Association.class));
            } else if ("ComplexType".equals(jp.getCurrentName())) {
                jp.nextToken();
                schema.getComplexTypes().add(jp.getCodec().readValue(jp, ComplexType.class));
            } else if ("EntityType".equals(jp.getCurrentName())) {
                jp.nextToken();
                schema.getEntityTypes().add(jp.getCodec().readValue(jp, EntityType.class));
            } else if ("EnumType".equals(jp.getCurrentName())) {
                jp.nextToken();
                schema.getEnumTypes().add(jp.getCodec().readValue(jp, EnumType.class));
            } else if ("ValueTerm".equals(jp.getCurrentName())) {
                jp.nextToken();
                schema.getValueTerms().add(jp.getCodec().readValue(jp, ValueTerm.class));
            } else if ("EntityContainer".equals(jp.getCurrentName())) {
                jp.nextToken();
                schema.getEntityContainers().add(jp.getCodec().readValue(jp, EntityContainer.class));
            } else if ("Annotations".equals(jp.getCurrentName())) {
                jp.nextToken();
                schema.getAnnotations().add(jp.getCodec().readValue(jp, Annotations.class));
            }
        }
    }

    return schema;
}

From source file:com.msopentech.odatajclient.engine.data.metadata.edm.v4.TypeDefinitionDeserializer.java

@Override
protected TypeDefinition doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
        throws IOException, JsonProcessingException {

    final TypeDefinition typeDefinition = new TypeDefinition();

    for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
        final JsonToken token = jp.getCurrentToken();
        if (token == JsonToken.FIELD_NAME) {
            if ("Name".equals(jp.getCurrentName())) {
                typeDefinition.setName(jp.nextTextValue());
            } else if ("UnderlyingType".equals(jp.getCurrentName())) {
                typeDefinition.setUnderlyingType(jp.nextTextValue());
            } else if ("MaxLength".equals(jp.getCurrentName())) {
                typeDefinition.setMaxLength(jp.nextTextValue());
            } else if ("Unicode".equals(jp.getCurrentName())) {
                typeDefinition.setUnicode(BooleanUtils.toBoolean(jp.nextTextValue()));
            } else if ("Precision".equals(jp.getCurrentName())) {
                typeDefinition.setPrecision(BigInteger.valueOf(jp.nextLongValue(0L)));
            } else if ("Scale".equals(jp.getCurrentName())) {
                typeDefinition.setScale(BigInteger.valueOf(jp.nextLongValue(0L)));
            } else if ("SRID".equals(jp.getCurrentName())) {
                typeDefinition.setSrid(jp.nextTextValue());
            } else if ("Annotation".equals(jp.getCurrentName())) {
                jp.nextToken();//from w w  w .  j a v  a  2  s  .  c om
                typeDefinition.getAnnotations().add(jp.getCodec().readValue(jp, Annotation.class));
            }
        }
    }

    return typeDefinition;
}

From source file:com.msopentech.odatajclient.engine.data.metadata.edm.v4.NavigationPropertyDeserializer.java

@Override
protected NavigationProperty doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
        throws IOException, JsonProcessingException {

    final NavigationProperty property = new NavigationProperty();

    for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
        final JsonToken token = jp.getCurrentToken();
        if (token == JsonToken.FIELD_NAME) {
            if ("Name".equals(jp.getCurrentName())) {
                property.setName(jp.nextTextValue());
            } else if ("Type".equals(jp.getCurrentName())) {
                property.setType(jp.nextTextValue());
            } else if ("Nullable".equals(jp.getCurrentName())) {
                property.setNullable(BooleanUtils.toBoolean(jp.nextTextValue()));
            } else if ("Partner".equals(jp.getCurrentName())) {
                property.setPartner(jp.nextTextValue());
            } else if ("ContainsTarget".equals(jp.getCurrentName())) {
                property.setContainsTarget(BooleanUtils.toBoolean(jp.nextTextValue()));
            } else if ("ReferentialConstraint".equals(jp.getCurrentName())) {
                jp.nextToken();//from  www .j a v  a  2  s  .c  o  m
                property.getReferentialConstraints()
                        .add(jp.getCodec().readValue(jp, ReferentialConstraint.class));
            } else if ("OnDelete".equals(jp.getCurrentName())) {
                jp.nextToken();
                property.setOnDelete(jp.getCodec().readValue(jp, OnDelete.class));
            } else if ("Annotation".equals(jp.getCurrentName())) {
                jp.nextToken();
                property.setAnnotation(jp.getCodec().readValue(jp, Annotation.class));
            }
        }
    }

    return property;
}

From source file:org.emfjson.jackson.streaming.StreamReader.java

protected ReferenceEntry createReferenceEntry(JsonParser parser, EReference reference, EObject owner)
        throws IOException {

    String id = null;//from   w w  w  . j  a v  a  2s .  co m

    while (parser.nextToken() != JsonToken.END_OBJECT) {
        String field = parser.getCurrentName();
        if (field.equalsIgnoreCase(Constants.EJS_REF_KEYWORD)) {
            id = parser.nextTextValue();
        }
    }

    return new ReferenceEntry(owner, reference, id);
}

From source file:org.emfjson.jackson.streaming.StreamReader.java

@SuppressWarnings("unchecked")
protected JsonToken parseEntry(JsonParser parser, EReference reference, EObject owner) throws IOException {

    EList<EObject> values = null;/*from w w  w. ja  v a2s.  c  o m*/
    if (reference.isMany()) {
        values = (EList<EObject>) owner.eGet(reference);
    }

    while (parser.nextToken() != JsonToken.END_OBJECT) {
        final String field = parser.getCurrentName();
        final String value = parser.nextTextValue();

        if (reference.isMany() && values != null) {
            values.add(createEntry(field, value));
        } else {
            owner.eSet(reference, createEntry(field, value));
        }
    }

    return parser.getCurrentToken();
}

From source file:com.msopentech.odatajclient.engine.metadata.edm.EntitySetDeserializer.java

@Override
protected AbstractEntitySet doDeserialize(final JsonParser jp, final DeserializationContext ctxt)
        throws IOException, JsonProcessingException {

    final AbstractEntitySet entitySet = ODataVersion.V3 == client.getWorkingVersion()
            ? new com.msopentech.odatajclient.engine.metadata.edm.v3.EntitySet()
            : new com.msopentech.odatajclient.engine.metadata.edm.v4.EntitySet();

    for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) {
        final JsonToken token = jp.getCurrentToken();
        if (token == JsonToken.FIELD_NAME) {
            if ("Name".equals(jp.getCurrentName())) {
                entitySet.setName(jp.nextTextValue());
            } else if ("EntityType".equals(jp.getCurrentName())) {
                entitySet.setEntityType(jp.nextTextValue());
            } else if ("IncludeInServiceDocument".equals(jp.getCurrentName())) {
                ((com.msopentech.odatajclient.engine.metadata.edm.v4.EntitySet) entitySet)
                        .setIncludeInServiceDocument(BooleanUtils.toBoolean(jp.nextTextValue()));
            } else if ("NavigationPropertyBinding".equals(jp.getCurrentName())) {
                jp.nextToken();//from  w  w w.  j  a va2  s .  c  om
                ((com.msopentech.odatajclient.engine.metadata.edm.v4.EntitySet) entitySet)
                        .getNavigationPropertyBindings()
                        .add(jp.getCodec().readValue(jp, NavigationPropertyBinding.class));
            } else if ("Annotation".equals(jp.getCurrentName())) {
                jp.nextToken();
                ((com.msopentech.odatajclient.engine.metadata.edm.v4.EntitySet) entitySet)
                        .setAnnotation(jp.getCodec().readValue(jp, Annotation.class));
            }
        }
    }

    return entitySet;
}