Example usage for com.fasterxml.jackson.core JsonLocation NA

List of usage examples for com.fasterxml.jackson.core JsonLocation NA

Introduction

In this page you can find the example usage for com.fasterxml.jackson.core JsonLocation NA.

Prototype

JsonLocation NA

To view the source code for com.fasterxml.jackson.core JsonLocation NA.

Click Source Link

Document

Shared immutable "N/A location" that can be returned to indicate that no location information is available

Usage

From source file:es.logongas.iothome.agent.http.DateDeserializer.java

@Override
public Date deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
        throws IOException, JsonProcessingException {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");

    try {// w  w  w .j a  va  2 s .  com
        return sdf.parse(jsonParser.getText());
    } catch (ParseException ex) {
        throw new JsonParseException("El formato de la fecha '" + jsonParser.getText() + "' no es correcto",
                JsonLocation.NA);
    }
}

From source file:es.logongas.ix3.web.json.impl.DateDeserializer.java

@Override
public Date deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
        throws IOException, JsonProcessingException {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");

    try {/*  w  w  w .j a v a2 s .  c  o m*/
        return sdf.parse(jsonParser.getText());
    } catch (ParseException ex) {
        try {
            long numericDate = Long.parseLong(jsonParser.getText());
            return new Date(numericDate);
        } catch (NumberFormatException ex2) {
            throw new JsonParseException("El formato de la fecha '" + jsonParser.getText() + "' no es correcto",
                    JsonLocation.NA);
        }
    }
}

From source file:org.anhonesteffort.flock.registration.model.SubscriptionPlanDeserializer.java

@Override
public SubscriptionPlan deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
        throws IOException, JsonProcessingException {
    try {//from ww  w . j  a  v a  2 s .c  o  m

        JsonNode node = jsonParser.getCodec().readTree(jsonParser);
        Integer planType = (Integer) node.get("plan_type").numberValue();
        String accountId = node.get("account_id").textValue();
        String planId = node.get("plan_id").textValue();

        switch (planType) {
        case SubscriptionPlan.PLAN_TYPE_NONE:
            return new SubscriptionPlan(accountId, planType, planId);

        case SubscriptionPlan.PLAN_TYPE_STRIPE:
            return new StripePlan(accountId, planId);

        case SubscriptionPlan.PLAN_TYPE_GOOGLE:
            String purchaseToken = node.get("purchase_token").textValue();
            Long expirationDate = (Long) node.get("expiration_date").numberValue();
            return new GooglePlan(accountId, planId, purchaseToken, expirationDate);

        default: {
            throw new JsonParseException("unknown plan type " + planType, JsonLocation.NA);
        }
        }

    } catch (NullPointerException e) {
        throw new JsonParseException("something was null D:", JsonLocation.NA);
    }
}

From source file:com.msopentech.odatajclient.engine.metadata.edm.v4.annotation.DynExprConstructDeserializer.java

private AbstractElOrAttrConstruct getElOrAttrInstance(final String simpleClassName) throws JsonParseException {
    try {// w  w  w . ja va 2s  .  c o  m
        @SuppressWarnings("unchecked")
        Class<? extends AbstractElOrAttrConstruct> elOrAttrClass = (Class<? extends AbstractElOrAttrConstruct>) ClassUtils
                .getClass(getClass().getPackage().getName() + "." + simpleClassName);
        return elOrAttrClass.newInstance();
    } catch (Exception e) {
        throw new JsonParseException("Could not instantiate " + simpleClassName, JsonLocation.NA, e);
    }
}

From source file:com.msopentech.odatajclient.engine.data.json.JSONPropertySerializer.java

/**
 * {@inheritDoc }/*from   ww  w  .jav  a  2  s.c o m*/
 */
@Override
public void serialize(final JSONProperty property, final JsonGenerator jgen, final SerializerProvider provider)
        throws IOException, JsonProcessingException {

    jgen.writeStartObject();

    if (property.getMetadata() != null) {
        jgen.writeStringField(ODataConstants.JSON_METADATA, property.getMetadata().toASCIIString());
    }

    final Element content = property.getContent();
    if (XMLUtils.hasOnlyTextChildNodes(content)) {
        jgen.writeStringField(ODataConstants.JSON_VALUE, content.getTextContent());
    } else {
        try {
            final DocumentBuilder builder = ODataConstants.DOC_BUILDER_FACTORY.newDocumentBuilder();
            final Document document = builder.newDocument();
            final Element wrapper = document.createElement(ODataConstants.ELEM_PROPERTY);

            if (XMLUtils.hasElementsChildNode(content)) {
                wrapper.appendChild(document.renameNode(document.importNode(content, true), null,
                        ODataConstants.JSON_VALUE));

                DOMTreeUtils.writeSubtree(jgen, wrapper);
            } else if (EdmSimpleType.isGeospatial(content.getAttribute(ODataConstants.ATTR_M_TYPE))) {
                wrapper.appendChild(document.renameNode(document.importNode(content, true), null,
                        ODataConstants.JSON_VALUE));

                DOMTreeUtils.writeSubtree(jgen, wrapper, true);
            } else {
                DOMTreeUtils.writeSubtree(jgen, content);
            }
        } catch (Exception e) {
            throw new JsonParseException("Cannot serialize property", JsonLocation.NA, e);
        }
    }

    jgen.writeEndObject();
}

From source file:org.mongojack.internal.object.BsonObjectTraversingParser.java

@Override
public JsonLocation getTokenLocation() {
    return JsonLocation.NA;
}

From source file:org.mongojack.internal.object.BsonObjectTraversingParser.java

@Override
public JsonLocation getCurrentLocation() {
    return JsonLocation.NA;
}

From source file:com.addthis.codec.jackson.Jackson.java

public static boolean isRealLocation(JsonLocation jsonLocation) {
    return (jsonLocation != null) && (jsonLocation != JsonLocation.NA);
}

From source file:com.addthis.codec.config.ConfigTraversingParser.java

@Override
public JsonLocation getTokenLocation() {
    ConfigValue current = currentConfig();
    if (current == null) {
        return JsonLocation.NA;
    }//from   w w w .j a va  2 s  .  c o m
    ConfigOrigin nodeOrigin = current.origin();
    return new JsonLocation(current, -1, nodeOrigin.lineNumber(), -1);
}

From source file:org.apache.olingo.client.core.edm.xml.annotation.DynamicAnnotationExpressionDeserializer.java

private AbstractElementOrAttributeExpression getElementOrAttributeExpressio(final String simpleClassName)
        throws JsonParseException {

    try {//  ww w.jav a  2s.c  o  m
        @SuppressWarnings("unchecked")
        Class<? extends AbstractElementOrAttributeExpression> elOrAttrClass = (Class<? extends AbstractElementOrAttributeExpression>) ClassUtils
                .getClass(getClass().getPackage().getName() + "." + simpleClassName + "Impl");
        return elOrAttrClass.newInstance();
    } catch (Exception e) {
        throw new JsonParseException("Could not instantiate " + simpleClassName, JsonLocation.NA, e);
    }
}