List of usage examples for com.fasterxml.jackson.core JsonParser readValueAs
@SuppressWarnings("unchecked") public <T> T readValueAs(TypeReference<?> valueTypeRef) throws IOException, JsonProcessingException
From source file:org.apache.olingo.client.core.edm.xml.EnumTypeDeserializer.java
@Override protected AbstractEnumType doDeserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException { final AbstractEnumType enumType = ODataServiceVersion.V30 == version ? new org.apache.olingo.client.core.edm.xml.v3.EnumTypeImpl() : new org.apache.olingo.client.core.edm.xml.v4.EnumTypeImpl(); for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { final JsonToken token = jp.getCurrentToken(); if (token == JsonToken.FIELD_NAME) { if ("Name".equals(jp.getCurrentName())) { enumType.setName(jp.nextTextValue()); } else if ("UnderlyingType".equals(jp.getCurrentName())) { enumType.setUnderlyingType(jp.nextTextValue()); } else if ("IsFlags".equals(jp.getCurrentName())) { enumType.setFlags(BooleanUtils.toBoolean(jp.nextTextValue())); } else if ("Member".equals(jp.getCurrentName())) { jp.nextToken();//from w w w. ja va2 s . com if (enumType instanceof org.apache.olingo.client.core.edm.xml.v3.EnumTypeImpl) { ((org.apache.olingo.client.core.edm.xml.v3.EnumTypeImpl) enumType).getMembers() .add(jp.readValueAs(org.apache.olingo.client.core.edm.xml.v3.MemberImpl.class)); } else { ((org.apache.olingo.client.core.edm.xml.v4.EnumTypeImpl) enumType).getMembers() .add(jp.readValueAs(org.apache.olingo.client.core.edm.xml.v4.MemberImpl.class)); } } else if ("Annotation".equals(jp.getCurrentName())) { jp.nextToken(); ((org.apache.olingo.client.core.edm.xml.v4.EnumTypeImpl) enumType).getAnnotations() .add(jp.readValueAs(AnnotationImpl.class)); } } } return enumType; }
From source file:org.apache.olingo.client.core.edm.xml.FunctionDeserializer.java
@Override protected FunctionImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException { final FunctionImpl functionImpl = new FunctionImpl(); for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { final JsonToken token = jp.getCurrentToken(); if (token == JsonToken.FIELD_NAME) { if ("Name".equals(jp.getCurrentName())) { functionImpl.setName(jp.nextTextValue()); } else if ("IsBound".equals(jp.getCurrentName())) { functionImpl.setBound(BooleanUtils.toBoolean(jp.nextTextValue())); } else if ("IsComposable".equals(jp.getCurrentName())) { functionImpl.setComposable(BooleanUtils.toBoolean(jp.nextTextValue())); } else if ("EntitySetPath".equals(jp.getCurrentName())) { functionImpl.setEntitySetPath(jp.nextTextValue()); } else if ("Parameter".equals(jp.getCurrentName())) { jp.nextToken();/*from w ww.j av a 2 s .c om*/ functionImpl.getParameters().add(jp.readValueAs(ParameterImpl.class)); } else if ("ReturnType".equals(jp.getCurrentName())) { functionImpl.setReturnType(parseReturnType(jp, "Function")); } else if ("Annotation".equals(jp.getCurrentName())) { jp.nextToken(); functionImpl.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); } } } return functionImpl; }
From source file:org.apache.olingo.client.core.edm.xml.FunctionImportDeserializer.java
@Override protected FunctionImportImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException { final FunctionImportImpl functImpImpl = new FunctionImportImpl(); for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { final JsonToken token = jp.getCurrentToken(); if (token == JsonToken.FIELD_NAME) { if ("Name".equals(jp.getCurrentName())) { functImpImpl.setName(jp.nextTextValue()); } else if ("Function".equals(jp.getCurrentName())) { functImpImpl.setFunction(jp.nextTextValue()); } else if ("EntitySet".equals(jp.getCurrentName())) { functImpImpl.setEntitySet(jp.nextTextValue()); } else if ("IncludeInServiceDocument".equals(jp.getCurrentName())) { functImpImpl.setIncludeInServiceDocument(BooleanUtils.toBoolean(jp.nextTextValue())); } else if ("Annotation".equals(jp.getCurrentName())) { jp.nextToken();/*from w ww . ja va 2 s . c o m*/ functImpImpl.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); } } } return functImpImpl; }
From source file:org.apache.olingo.client.core.edm.xml.NavigationPropertyDeserializer.java
@Override protected NavigationPropertyImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException { final NavigationPropertyImpl property = new NavigationPropertyImpl(); 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 ww w. j av a 2 s. co m*/ property.getReferentialConstraints().add(jp.readValueAs(ReferentialConstraintImpl.class)); } else if ("OnDelete".equals(jp.getCurrentName())) { jp.nextToken(); property.setOnDelete(jp.readValueAs(OnDeleteImpl.class)); } else if ("Annotation".equals(jp.getCurrentName())) { jp.nextToken(); property.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); } } } return property; }
From source file:org.apache.olingo.client.core.edm.xml.ParameterDeserializer.java
@Override protected AbstractParameter doDeserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException { final AbstractParameter parameter = ODataServiceVersion.V30 == version ? new org.apache.olingo.client.core.edm.xml.v3.ParameterImpl() : new org.apache.olingo.client.core.edm.xml.v4.ParameterImpl(); for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { final JsonToken token = jp.getCurrentToken(); if (token == JsonToken.FIELD_NAME) { if ("Name".equals(jp.getCurrentName())) { parameter.setName(jp.nextTextValue()); } else if ("Type".equals(jp.getCurrentName())) { parameter.setType(jp.nextTextValue()); } else if ("Nullable".equals(jp.getCurrentName())) { parameter.setNullable(BooleanUtils.toBoolean(jp.nextTextValue())); } else if ("MaxLength".equals(jp.getCurrentName())) { final String maxLenght = jp.nextTextValue(); parameter.setMaxLength(/*from w w w . j a va 2 s.c om*/ maxLenght.equalsIgnoreCase("max") ? Integer.MAX_VALUE : Integer.valueOf(maxLenght)); } else if ("Precision".equals(jp.getCurrentName())) { parameter.setPrecision(Integer.valueOf(jp.nextTextValue())); } else if ("Scale".equals(jp.getCurrentName())) { final String scale = jp.nextTextValue(); parameter.setScale(scale.equalsIgnoreCase("variable") ? 0 : Integer.valueOf(scale)); } else if ("Mode".equals(jp.getCurrentName())) { ((org.apache.olingo.client.core.edm.xml.v3.ParameterImpl) parameter) .setMode(ParameterMode.valueOf(jp.nextTextValue())); } else if ("SRID".equals(jp.getCurrentName())) { final String srid = jp.nextTextValue(); if (srid != null) { ((org.apache.olingo.client.core.edm.xml.v4.ParameterImpl) parameter) .setSrid(SRID.valueOf(srid)); } } else if ("Annotation".equals(jp.getCurrentName())) { jp.nextToken(); ((org.apache.olingo.client.core.edm.xml.v4.ParameterImpl) parameter).getAnnotations() .add(jp.readValueAs(AnnotationImpl.class)); } } } return parameter; }
From source file:org.apache.olingo.client.core.edm.xml.PropertyDeserializer.java
@Override protected AbstractProperty doDeserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException { final AbstractProperty property = ODataServiceVersion.V30 == version ? new org.apache.olingo.client.core.edm.xml.v3.PropertyImpl() : new org.apache.olingo.client.core.edm.xml.v4.PropertyImpl(); 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 ("DefaultValue".equals(jp.getCurrentName())) { property.setDefaultValue(jp.nextTextValue()); } else if ("MaxLength".equals(jp.getCurrentName())) { final String maxLenght = jp.nextTextValue(); property.setMaxLength(// ww w .j a v a2 s. c o m maxLenght.equalsIgnoreCase("max") ? Integer.MAX_VALUE : Integer.valueOf(maxLenght)); } else if ("FixedLength".equals(jp.getCurrentName())) { if (property instanceof org.apache.olingo.client.core.edm.xml.v3.PropertyImpl) { ((org.apache.olingo.client.core.edm.xml.v3.PropertyImpl) property) .setFixedLength(BooleanUtils.toBoolean(jp.nextTextValue())); } } else if ("Precision".equals(jp.getCurrentName())) { property.setPrecision(Integer.valueOf(jp.nextTextValue())); } else if ("Scale".equals(jp.getCurrentName())) { final String scale = jp.nextTextValue(); property.setScale(scale.equalsIgnoreCase("variable") ? 0 : Integer.valueOf(scale)); } else if ("Unicode".equals(jp.getCurrentName())) { property.setUnicode(BooleanUtils.toBoolean(jp.nextTextValue())); } else if ("Collation".equals(jp.getCurrentName())) { if (property instanceof org.apache.olingo.client.core.edm.xml.v3.PropertyImpl) { ((org.apache.olingo.client.core.edm.xml.v3.PropertyImpl) property) .setCollation(jp.nextTextValue()); } } else if ("SRID".equals(jp.getCurrentName())) { final String srid = jp.nextTextValue(); if (srid != null) { property.setSrid(SRID.valueOf(srid)); } } else if ("ConcurrencyMode".equals(jp.getCurrentName())) { if (property instanceof org.apache.olingo.client.core.edm.xml.v3.PropertyImpl) { ((org.apache.olingo.client.core.edm.xml.v3.PropertyImpl) property) .setConcurrencyMode(ConcurrencyMode.valueOf(jp.nextTextValue())); } } else if ("StoreGeneratedPattern".equals(jp.getCurrentName())) { if (property instanceof org.apache.olingo.client.core.edm.xml.v3.PropertyImpl) { ((org.apache.olingo.client.core.edm.xml.v3.PropertyImpl) property) .setStoreGeneratedPattern(StoreGeneratedPattern.valueOf(jp.nextTextValue())); } } else if ("FC_SourcePath".equals(jp.getCurrentName())) { if (property instanceof org.apache.olingo.client.core.edm.xml.v3.PropertyImpl) { ((org.apache.olingo.client.core.edm.xml.v3.PropertyImpl) property) .setFcSourcePath(jp.nextTextValue()); } } else if ("FC_TargetPath".equals(jp.getCurrentName())) { if (property instanceof org.apache.olingo.client.core.edm.xml.v3.PropertyImpl) { ((org.apache.olingo.client.core.edm.xml.v3.PropertyImpl) property) .setFcTargetPath(jp.nextTextValue()); } } else if ("FC_ContentKind".equals(jp.getCurrentName())) { if (property instanceof org.apache.olingo.client.core.edm.xml.v3.PropertyImpl) { ((org.apache.olingo.client.core.edm.xml.v3.PropertyImpl) property) .setFcContentKind(EdmContentKind.valueOf(jp.nextTextValue())); } } else if ("FC_NsPrefix".equals(jp.getCurrentName())) { if (property instanceof org.apache.olingo.client.core.edm.xml.v3.PropertyImpl) { ((org.apache.olingo.client.core.edm.xml.v3.PropertyImpl) property) .setFcNSPrefix(jp.nextTextValue()); } } else if ("FC_NsUri".equals(jp.getCurrentName())) { if (property instanceof org.apache.olingo.client.core.edm.xml.v3.PropertyImpl) { ((org.apache.olingo.client.core.edm.xml.v3.PropertyImpl) property) .setFcNSURI(jp.nextTextValue()); } } else if ("FC_KeepInContent".equals(jp.getCurrentName())) { if (property instanceof org.apache.olingo.client.core.edm.xml.v3.PropertyImpl) { ((org.apache.olingo.client.core.edm.xml.v3.PropertyImpl) property) .setFcKeepInContent(BooleanUtils.toBoolean(jp.nextTextValue())); } } else if ("Annotation".equals(jp.getCurrentName())) { jp.nextToken(); ((org.apache.olingo.client.core.edm.xml.v4.PropertyImpl) property).getAnnotations() .add(jp.readValueAs(AnnotationImpl.class)); } } } return property; }
From source file:org.apache.olingo.client.core.edm.xml.TermDeserializer.java
@Override protected TermImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException { final TermImpl term = new TermImpl(); for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { final JsonToken token = jp.getCurrentToken(); if (token == JsonToken.FIELD_NAME) { if ("Name".equals(jp.getCurrentName())) { term.setName(jp.nextTextValue()); } else if ("Type".equals(jp.getCurrentName())) { term.setType(jp.nextTextValue()); } else if ("BaseTerm".equals(jp.getCurrentName())) { term.setBaseTerm(jp.nextTextValue()); } else if ("DefaultValue".equals(jp.getCurrentName())) { term.setDefaultValue(jp.nextTextValue()); } else if ("Nullable".equals(jp.getCurrentName())) { term.setNullable(BooleanUtils.toBoolean(jp.nextTextValue())); } else if ("MaxLength".equals(jp.getCurrentName())) { final String maxLenght = jp.nextTextValue(); term.setMaxLength(//from ww w . ja va 2s . c o m maxLenght.equalsIgnoreCase("max") ? Integer.MAX_VALUE : Integer.valueOf(maxLenght)); } else if ("Precision".equals(jp.getCurrentName())) { term.setPrecision(Integer.valueOf(jp.nextTextValue())); } else if ("Scale".equals(jp.getCurrentName())) { final String scale = jp.nextTextValue(); term.setScale(scale.equalsIgnoreCase("variable") ? 0 : Integer.valueOf(scale)); } else if ("SRID".equals(jp.getCurrentName())) { final String srid = jp.nextTextValue(); if (srid != null) { term.setSrid(SRID.valueOf(srid)); } } else if ("AppliesTo".equals(jp.getCurrentName())) { term.getAppliesTo().addAll(Arrays.asList(StringUtils.split(jp.nextTextValue()))); } else if ("Annotation".equals(jp.getCurrentName())) { jp.nextToken(); term.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); } } } return term; }
From source file:org.apache.olingo.client.core.edm.xml.TypeDefinitionDeserializer.java
@Override protected TypeDefinitionImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException { final TypeDefinitionImpl typeDefinition = new TypeDefinitionImpl(); 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.nextIntValue(0)); } else if ("Unicode".equals(jp.getCurrentName())) { typeDefinition.setUnicode(BooleanUtils.toBoolean(jp.nextTextValue())); } else if ("Precision".equals(jp.getCurrentName())) { typeDefinition.setPrecision(jp.nextIntValue(0)); } else if ("Scale".equals(jp.getCurrentName())) { final String scale = jp.nextTextValue(); typeDefinition.setScale(scale.equalsIgnoreCase("variable") ? 0 : Integer.valueOf(scale)); } else if ("SRID".equals(jp.getCurrentName())) { final String srid = jp.nextTextValue(); if (srid != null) { typeDefinition.setSrid(SRID.valueOf(srid)); }// w w w . j a va 2 s . c om } else if ("Annotation".equals(jp.getCurrentName())) { jp.nextToken(); typeDefinition.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); } } } return typeDefinition; }
From source file:org.apache.olingo.client.core.edm.xml.v3.FunctionImportDeserializer.java
@Override protected FunctionImportImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException { final FunctionImportImpl funcImp = new FunctionImportImpl(); for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { final JsonToken token = jp.getCurrentToken(); if (token == JsonToken.FIELD_NAME) { if ("Name".equals(jp.getCurrentName())) { funcImp.setName(jp.nextTextValue()); } else if ("ReturnType".equals(jp.getCurrentName())) { funcImp.setReturnType(jp.nextTextValue()); } else if ("EntitySet".equals(jp.getCurrentName())) { funcImp.setEntitySet(jp.nextTextValue()); } else if ("EntitySetPath".equals(jp.getCurrentName())) { funcImp.setEntitySetPath(jp.nextTextValue()); } else if ("IsComposable".equals(jp.getCurrentName())) { funcImp.setComposable(BooleanUtils.toBoolean(jp.nextTextValue())); } else if ("IsSideEffecting".equals(jp.getCurrentName())) { funcImp.setSideEffecting(BooleanUtils.toBoolean(jp.nextTextValue())); } else if ("IsBindable".equals(jp.getCurrentName())) { funcImp.setBindable(BooleanUtils.toBoolean(jp.nextTextValue())); } else if ("IsAlwaysBindable".equals(jp.getCurrentName())) { funcImp.setAlwaysBindable(BooleanUtils.toBoolean(jp.nextTextValue())); } else if ("HttpMethod".equals(jp.getCurrentName())) { funcImp.setHttpMethod(jp.nextTextValue()); } else if ("Parameter".equals(jp.getCurrentName())) { jp.nextToken();//from www . j a v a2s . c o m funcImp.getParameters().add(jp.readValueAs(ParameterImpl.class)); } } } return funcImp; }
From source file:org.apache.olingo.client.core.edm.xml.v4.annotation.DynExprConstructDeserializer.java
private ExprConstructImpl parseConstOrEnumExprConstruct(final JsonParser jp) throws IOException { ExprConstructImpl result;/*w w w . j a va2 s.c om*/ if (isAnnotationConstExprConstruct(jp)) { result = parseAnnotationConstExprConstruct(jp); } else { result = jp.readValueAs(DynExprConstructImpl.class); } jp.nextToken(); return result; }