List of usage examples for com.fasterxml.jackson.core JsonParser getCodec
public abstract ObjectCodec getCodec();
From source file:com.msopentech.odatajclient.engine.metadata.edm.EntityContainerDeserializer.java
@Override protected AbstractEntityContainer doDeserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException { final AbstractEntityContainer entityContainer = ODataVersion.V3 == client.getWorkingVersion() ? new com.msopentech.odatajclient.engine.metadata.edm.v3.EntityContainer() : new com.msopentech.odatajclient.engine.metadata.edm.v4.EntityContainer(); for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { final JsonToken token = jp.getCurrentToken(); if (token == JsonToken.FIELD_NAME) { if ("Name".equals(jp.getCurrentName())) { entityContainer.setName(jp.nextTextValue()); } else if ("Extends".equals(jp.getCurrentName())) { entityContainer.setExtends(jp.nextTextValue()); } else if ("LazyLoadingEnabled".equals(jp.getCurrentName())) { entityContainer.setLazyLoadingEnabled(BooleanUtils.toBoolean(jp.nextTextValue())); } else if ("IsDefaultEntityContainer".equals(jp.getCurrentName())) { entityContainer.setDefaultEntityContainer(BooleanUtils.toBoolean(jp.nextTextValue())); } else if ("EntitySet".equals(jp.getCurrentName())) { jp.nextToken();//from w ww .j av a 2s .c o m if (entityContainer instanceof com.msopentech.odatajclient.engine.metadata.edm.v3.EntityContainer) { ((com.msopentech.odatajclient.engine.metadata.edm.v3.EntityContainer) entityContainer) .getEntitySets().add(jp.getCodec().readValue(jp, com.msopentech.odatajclient.engine.metadata.edm.v3.EntitySet.class)); } else { ((com.msopentech.odatajclient.engine.metadata.edm.v4.EntityContainer) entityContainer) .getEntitySets().add(jp.getCodec().readValue(jp, com.msopentech.odatajclient.engine.metadata.edm.v4.EntitySet.class)); } } else if ("AssociationSet".equals(jp.getCurrentName())) { jp.nextToken(); ((com.msopentech.odatajclient.engine.metadata.edm.v3.EntityContainer) entityContainer) .getAssociationSets().add(jp.getCodec().readValue(jp, AssociationSet.class)); } else if ("Singleton".equals(jp.getCurrentName())) { jp.nextToken(); ((com.msopentech.odatajclient.engine.metadata.edm.v4.EntityContainer) entityContainer) .getSingletons().add(jp.getCodec().readValue(jp, Singleton.class)); } else if ("ActionImport".equals(jp.getCurrentName())) { jp.nextToken(); ((com.msopentech.odatajclient.engine.metadata.edm.v4.EntityContainer) entityContainer) .getActionImports().add(jp.getCodec().readValue(jp, ActionImport.class)); } else if ("FunctionImport".equals(jp.getCurrentName())) { jp.nextToken(); if (entityContainer instanceof com.msopentech.odatajclient.engine.metadata.edm.v3.EntityContainer) { ((com.msopentech.odatajclient.engine.metadata.edm.v3.EntityContainer) entityContainer) .getFunctionImports().add(jp.getCodec().readValue(jp, com.msopentech.odatajclient.engine.metadata.edm.v3.FunctionImport.class)); } else { ((com.msopentech.odatajclient.engine.metadata.edm.v4.EntityContainer) entityContainer) .getFunctionImports().add(jp.getCodec().readValue(jp, com.msopentech.odatajclient.engine.metadata.edm.v4.FunctionImport.class)); } } else if ("Annotation".equals(jp.getCurrentName())) { jp.nextToken(); ((com.msopentech.odatajclient.engine.metadata.edm.v4.EntityContainer) entityContainer) .setAnnotation(jp.getCodec().readValue(jp, Annotation.class)); } } } return entityContainer; }
From source file:com.msopentech.odatajclient.engine.data.metadata.edm.EntityContainerDeserializer.java
@Override protected AbstractEntityContainer doDeserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException { final AbstractEntityContainer entityContainer = ODataVersion.V3 == client.getWorkingVersion() ? new com.msopentech.odatajclient.engine.data.metadata.edm.v3.EntityContainer() : new com.msopentech.odatajclient.engine.data.metadata.edm.v4.EntityContainer(); for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { final JsonToken token = jp.getCurrentToken(); if (token == JsonToken.FIELD_NAME) { if ("Name".equals(jp.getCurrentName())) { entityContainer.setName(jp.nextTextValue()); } else if ("Extends".equals(jp.getCurrentName())) { entityContainer.setExtends(jp.nextTextValue()); } else if ("LazyLoadingEnabled".equals(jp.getCurrentName())) { entityContainer.setLazyLoadingEnabled(BooleanUtils.toBoolean(jp.nextTextValue())); } else if ("IsDefaultEntityContainer".equals(jp.getCurrentName())) { entityContainer.setDefaultEntityContainer(BooleanUtils.toBoolean(jp.nextTextValue())); } else if ("EntitySet".equals(jp.getCurrentName())) { jp.nextToken();/*w ww .j a va 2 s . c o m*/ if (entityContainer instanceof com.msopentech.odatajclient.engine.data.metadata.edm.v3.EntityContainer) { ((com.msopentech.odatajclient.engine.data.metadata.edm.v3.EntityContainer) entityContainer) .getEntitySets().add(jp.getCodec().readValue(jp, com.msopentech.odatajclient.engine.data.metadata.edm.v3.EntitySet.class)); } else { ((com.msopentech.odatajclient.engine.data.metadata.edm.v4.EntityContainer) entityContainer) .getEntitySets().add(jp.getCodec().readValue(jp, com.msopentech.odatajclient.engine.data.metadata.edm.v4.EntitySet.class)); } } else if ("AssociationSet".equals(jp.getCurrentName())) { jp.nextToken(); ((com.msopentech.odatajclient.engine.data.metadata.edm.v3.EntityContainer) entityContainer) .getAssociationSets().add(jp.getCodec().readValue(jp, AssociationSet.class)); } else if ("Singleton".equals(jp.getCurrentName())) { jp.nextToken(); ((com.msopentech.odatajclient.engine.data.metadata.edm.v4.EntityContainer) entityContainer) .getSingletons().add(jp.getCodec().readValue(jp, Singleton.class)); } else if ("ActionImport".equals(jp.getCurrentName())) { jp.nextToken(); ((com.msopentech.odatajclient.engine.data.metadata.edm.v4.EntityContainer) entityContainer) .getActionImports().add(jp.getCodec().readValue(jp, ActionImport.class)); } else if ("FunctionImport".equals(jp.getCurrentName())) { jp.nextToken(); if (entityContainer instanceof com.msopentech.odatajclient.engine.data.metadata.edm.v3.EntityContainer) { ((com.msopentech.odatajclient.engine.data.metadata.edm.v3.EntityContainer) entityContainer) .getFunctionImports().add(jp.getCodec().readValue(jp, com.msopentech.odatajclient.engine.data.metadata.edm.v3.FunctionImport.class)); } else { ((com.msopentech.odatajclient.engine.data.metadata.edm.v4.EntityContainer) entityContainer) .getFunctionImports().add(jp.getCodec().readValue(jp, com.msopentech.odatajclient.engine.data.metadata.edm.v4.FunctionImport.class)); } } else if ("Annotation".equals(jp.getCurrentName())) { jp.nextToken(); ((com.msopentech.odatajclient.engine.data.metadata.edm.v4.EntityContainer) entityContainer) .setAnnotation(jp.getCodec().readValue(jp, Annotation.class)); } } } return entityContainer; }
From source file:com.msopentech.odatajclient.engine.data.metadata.edm.FunctionImportDeserializer.java
@Override public FunctionImport deserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException { final FunctionImport funcImp = new FunctionImport(); 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(Boolean.valueOf(jp.nextTextValue())); } else if ("IsSideEffecting".equals(jp.getCurrentName())) { funcImp.setSideEffecting(Boolean.valueOf(jp.nextTextValue())); } else if ("IsBindable".equals(jp.getCurrentName())) { funcImp.setBindable(Boolean.valueOf(jp.nextTextValue())); } else if ("IsAlwaysBindable".equals(jp.getCurrentName())) { funcImp.setAlwaysBindable(Boolean.valueOf(jp.nextTextValue())); } else if ("HttpMethod".equals(jp.getCurrentName())) { funcImp.setHttpMethod(jp.nextTextValue()); } else if ("Parameter".equals(jp.getCurrentName())) { jp.nextToken();/*w w w .ja v a2 s . co m*/ funcImp.getParameters().add(jp.getCodec().readValue(jp, Parameter.class)); } } } return funcImp; }
From source file:com.msopentech.odatajclient.engine.data.metadata.edm.v3.FunctionImportDeserializer.java
@Override protected FunctionImport doDeserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException { final FunctionImport funcImp = new FunctionImport(); 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();/* w w w .j av a 2s.c o m*/ funcImp.getParameters().add(jp.getCodec().readValue(jp, Parameter.class)); } } } return funcImp; }
From source file:com.msopentech.odatajclient.engine.metadata.edm.ComplexTypeDeserializer.java
@Override protected AbstractComplexType doDeserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException { final AbstractComplexType complexType = ODataVersion.V3 == client.getWorkingVersion() ? new com.msopentech.odatajclient.engine.metadata.edm.v3.ComplexType() : new com.msopentech.odatajclient.engine.metadata.edm.v4.ComplexType(); for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { final JsonToken token = jp.getCurrentToken(); if (token == JsonToken.FIELD_NAME) { if ("Name".equals(jp.getCurrentName())) { complexType.setName(jp.nextTextValue()); } else if ("Abstract".equals(jp.getCurrentName())) { ((com.msopentech.odatajclient.engine.metadata.edm.v4.ComplexType) complexType) .setAbstractEntityType(BooleanUtils.toBoolean(jp.nextTextValue())); } else if ("BaseType".equals(jp.getCurrentName())) { ((com.msopentech.odatajclient.engine.metadata.edm.v4.ComplexType) complexType) .setBaseType(jp.nextTextValue()); } else if ("OpenType".equals(jp.getCurrentName())) { ((com.msopentech.odatajclient.engine.metadata.edm.v4.ComplexType) complexType) .setOpenType(BooleanUtils.toBoolean(jp.nextTextValue())); } else if ("Property".equals(jp.getCurrentName())) { jp.nextToken();/* w ww .j a va 2s .c o m*/ if (complexType instanceof com.msopentech.odatajclient.engine.metadata.edm.v3.ComplexType) { ((com.msopentech.odatajclient.engine.metadata.edm.v3.ComplexType) complexType) .getProperties().add(jp.getCodec().readValue(jp, com.msopentech.odatajclient.engine.metadata.edm.v3.Property.class)); } else { ((com.msopentech.odatajclient.engine.metadata.edm.v4.ComplexType) complexType) .getProperties().add(jp.getCodec().readValue(jp, com.msopentech.odatajclient.engine.metadata.edm.v4.Property.class)); } } else if ("NavigationProperty".equals(jp.getCurrentName())) { jp.nextToken(); ((com.msopentech.odatajclient.engine.metadata.edm.v4.ComplexType) complexType) .getNavigationProperties().add(jp.getCodec().readValue(jp, com.msopentech.odatajclient.engine.metadata.edm.v4.NavigationProperty.class)); } else if ("Annotation".equals(jp.getCurrentName())) { jp.nextToken(); ((com.msopentech.odatajclient.engine.metadata.edm.v4.ComplexType) complexType) .setAnnotation(jp.getCodec().readValue(jp, Annotation.class)); } } } return complexType; }
From source file:com.msopentech.odatajclient.engine.data.metadata.edm.ComplexTypeDeserializer.java
@Override protected AbstractComplexType doDeserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException { final AbstractComplexType complexType = ODataVersion.V3 == client.getWorkingVersion() ? new com.msopentech.odatajclient.engine.data.metadata.edm.v3.ComplexType() : new com.msopentech.odatajclient.engine.data.metadata.edm.v4.ComplexType(); for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { final JsonToken token = jp.getCurrentToken(); if (token == JsonToken.FIELD_NAME) { if ("Name".equals(jp.getCurrentName())) { complexType.setName(jp.nextTextValue()); } else if ("Abstract".equals(jp.getCurrentName())) { ((com.msopentech.odatajclient.engine.data.metadata.edm.v4.ComplexType) complexType) .setAbstractEntityType(BooleanUtils.toBoolean(jp.nextTextValue())); } else if ("BaseType".equals(jp.getCurrentName())) { ((com.msopentech.odatajclient.engine.data.metadata.edm.v4.ComplexType) complexType) .setBaseType(jp.nextTextValue()); } else if ("OpenType".equals(jp.getCurrentName())) { ((com.msopentech.odatajclient.engine.data.metadata.edm.v4.ComplexType) complexType) .setOpenType(BooleanUtils.toBoolean(jp.nextTextValue())); } else if ("Property".equals(jp.getCurrentName())) { jp.nextToken();/*from w w w. jav a 2 s . com*/ if (complexType instanceof com.msopentech.odatajclient.engine.data.metadata.edm.v3.ComplexType) { ((com.msopentech.odatajclient.engine.data.metadata.edm.v3.ComplexType) complexType) .getProperties().add(jp.getCodec().readValue(jp, com.msopentech.odatajclient.engine.data.metadata.edm.v3.Property.class)); } else { ((com.msopentech.odatajclient.engine.data.metadata.edm.v4.ComplexType) complexType) .getProperties().add(jp.getCodec().readValue(jp, com.msopentech.odatajclient.engine.data.metadata.edm.v4.Property.class)); } } else if ("NavigationProperty".equals(jp.getCurrentName())) { jp.nextToken(); ((com.msopentech.odatajclient.engine.data.metadata.edm.v4.ComplexType) complexType) .getNavigationProperties().add(jp.getCodec().readValue(jp, com.msopentech.odatajclient.engine.data.metadata.edm.v4.NavigationProperty.class)); } else if ("Annotation".equals(jp.getCurrentName())) { jp.nextToken(); ((com.msopentech.odatajclient.engine.data.metadata.edm.v4.ComplexType) complexType) .setAnnotation(jp.getCodec().readValue(jp, Annotation.class)); } } } return complexType; }
From source file:com.msopentech.odatajclient.engine.data.metadata.edm.v4.TermDeserializer.java
@Override protected Term doDeserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException { final Term term = new Term(); 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())) { term.setMaxLength(jp.nextTextValue()); } else if ("Precision".equals(jp.getCurrentName())) { term.setPrecision(BigInteger.valueOf(jp.nextLongValue(0L))); } else if ("Scale".equals(jp.getCurrentName())) { term.setScale(BigInteger.valueOf(jp.nextLongValue(0L))); } else if ("SRID".equals(jp.getCurrentName())) { term.setSrid(jp.nextTextValue()); } else if ("AppliesTo".equals(jp.getCurrentName())) { for (String split : StringUtils.split(jp.nextTextValue())) { term.getAppliesTo().add(CSDLElement.valueOf(split)); }//from w w w . j a va 2s . c o m } else if ("Annotation".equals(jp.getCurrentName())) { jp.nextToken(); term.setAnnotation(jp.getCodec().readValue(jp, Annotation.class)); } } } return term; }
From source file:org.thingsplode.synapse.serializers.jackson.adapters.ParameterWrapperDeserializer.java
@Override public ParameterWrapper deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { JsonNode node = jp.readValueAsTree(); if (node != null && node.size() > 0 && node.isContainerNode()) { ParameterWrapper pw = ParameterWrapper.create(); ArrayNode paramsNode = (ArrayNode) node.get("params"); Iterator<JsonNode> elemIterator = paramsNode.elements(); while (elemIterator.hasNext()) { JsonNode currentNode = elemIterator.next(); if (currentNode.getNodeType() == JsonNodeType.OBJECT) { try { String paramid = ((ObjectNode) currentNode).get("paramid").asText(); String typeName = ((ObjectNode) currentNode).get("type").asText(); Class paramType = null; if (null != typeName) switch (typeName) { case "long": paramType = Long.TYPE; break; case "byte": paramType = Byte.TYPE; break; case "short": paramType = Short.TYPE; break; case "int": paramType = Integer.TYPE; break; case "float": paramType = Float.TYPE; break; case "double": paramType = Double.TYPE; break; case "boolean": paramType = Boolean.TYPE; break; case "char": paramType = Character.TYPE; break; default: paramType = Class.forName(typeName); break; }/*from w w w .j a va 2 s . com*/ Object parameterObject = jp.getCodec().treeToValue(currentNode.get("value"), paramType); pw.add(paramid, paramType, parameterObject); } catch (ClassNotFoundException ex) { throw new JsonParseException(jp, ex.getMessage()); } } } return pw; } else { return null; } }