Java 类org.codehaus.jackson.node.LongNode 实例源码

项目:datacollector    文件:AvroSchemaGenerator.java   
private JsonNode convertToJsonNode(AvroDefaultConfig defaultConfig) {
  switch (defaultConfig.avroType) {
    case BOOLEAN:
      return Boolean.parseBoolean(defaultConfig.defaultValue) ? BooleanNode.TRUE : BooleanNode.FALSE;
    case INTEGER:
      return new IntNode(Integer.parseInt(defaultConfig.defaultValue));
    case LONG:
      return new LongNode(Long.parseLong(defaultConfig.defaultValue));
    case FLOAT:
      // FloatNode is fairly recent and our Jackson version does not have it yet
      return new DoubleNode(Float.parseFloat(defaultConfig.defaultValue));
    case DOUBLE:
      return new DoubleNode(Double.parseDouble(defaultConfig.defaultValue));
    case STRING:
      return new TextNode(defaultConfig.defaultValue);
    default:
      throw new IllegalArgumentException("Unknown type: " + defaultConfig.avroType);
  }
}
项目:jive-sdk-java-jersey    文件:WebhookInstance.java   
@Override
public WebhookInstance deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
    JsonNode root = jsonParser.getCodec().readTree(jsonParser);

    WebhookInstance webhookInstance = new WebhookInstance();
    webhookInstance.setId(((LongNode)root.get("id")).getLongValue());
    webhookInstance.setObject(root.get("object").getTextValue());

    JsonNode resources = root.get("resources");
    JsonNode self = resources.get("self");

    webhookInstance.setSelfReference(self.get("ref").getTextValue());

    webhookInstance.setCallback(root.get("callback").getTextValue());

    self = null;
    resources = null;
    root = null;

    return webhookInstance;
}
项目:secure-data-service    文件:GenericEntityDeserializer.java   
private Object processPrimitive(final JsonNode prim) {
    Object val;

    if (prim instanceof BooleanNode) {
        val = prim.getBooleanValue();
    } else if (prim instanceof DoubleNode) {
        val = prim.getDoubleValue();
    } else if (prim instanceof IntNode) {
        val = prim.getIntValue();
    } else if (prim instanceof LongNode) {
        val = prim.getLongValue();
    } else {
        val = prim.getTextValue();
    }
    return val;
}
项目:gluu    文件:GluuGroupListSerializer.java   
private void writeStructure(String parent, Map.Entry<String, JsonNode> rootNodeEntry, JsonGenerator jsonGenerator) throws Exception {

        jsonGenerator.writeFieldName(rootNodeEntry.getKey());

        if (rootNodeEntry.getValue() instanceof ObjectNode) {

            jsonGenerator.writeStartObject();
            processNodes(rootNodeEntry.getKey(), rootNodeEntry.getValue(), jsonGenerator);  // Recursion
            jsonGenerator.writeEndObject();

        } else if (rootNodeEntry.getValue() instanceof ArrayNode) {

            ArrayNode arrayNode = (ArrayNode) rootNodeEntry.getValue();

            jsonGenerator.writeStartArray();

            if (arrayNode.size() > 0) {

                for (int i = 0; i < arrayNode.size(); i++) {

                    JsonNode arrayNodeElement = arrayNode.get(i);

                    if (arrayNodeElement.isObject()) {

                        jsonGenerator.writeStartObject();
                        processNodes(rootNodeEntry.getKey(), arrayNodeElement, jsonGenerator);  // Recursion
                        jsonGenerator.writeEndObject();

                    } else {
                        jsonGenerator.writeObject(arrayNodeElement);
                    }
                }
            }

            jsonGenerator.writeEndArray();

        } else {

            if (parent != null && parent.equalsIgnoreCase("meta")) {

                if (rootNodeEntry.getValue() instanceof LongNode && (rootNodeEntry.getKey().equalsIgnoreCase("created") || rootNodeEntry.getKey().equalsIgnoreCase("lastModified"))) {

                    DateTimeFormatter dateTimeFormatter = ISODateTimeFormat.dateTime().withZoneUTC();  // Date should be in UTC format

                    // In millis convert to string date
                    jsonGenerator.writeObject(dateTimeFormatter.print(Long.valueOf(rootNodeEntry.getValue().asText()).longValue()));

                } else {
                    jsonGenerator.writeObject(rootNodeEntry.getValue());
                }

            } else {
                jsonGenerator.writeObject(rootNodeEntry.getValue());
            }
        }
    }