Java Code Examples for org.codehaus.jackson.JsonNode#getIntValue()

The following examples show how to use org.codehaus.jackson.JsonNode#getIntValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GenericEntityDeserializer.java    From secure-data-service with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 2
Source File: JsonUtils.java    From Cubert with Apache License 2.0 5 votes vote down vote up
public static Object asObject(JsonNode node)
{
    if (node.isTextual())
        return node.getTextValue();
    else if (node.isInt())
        return node.getIntValue();
    else if (node.isFloatingPointNumber())
        return node.getDoubleValue();
    else if (node.isBoolean())
        return node.getBooleanValue();

    return null;
}
 
Example 3
Source File: Lineage.java    From Cubert with Apache License 2.0 5 votes vote down vote up
private static String findIndexedColumn(ObjectNode sourceOp, ArrayNode argsNode)
{
    BlockSchema sourceSchema = new BlockSchema(sourceOp.get("schema"));
    for (JsonNode arg : argsNode)
    {
      if (!arg.isNumber())
        return null;
      String colName =
        sourceSchema.getColumnNames()[arg.getIntValue()];
        return colName;
    }
    return null;

}
 
Example 4
Source File: ThreadPoolManager.java    From Cubert with Apache License 2.0 5 votes vote down vote up
private void setupGraph(JsonNode programNode)
{
    // need a list of jobNames in order to print the dependency graph jobs in
    // sequential order
    List<String> jobNames = new ArrayList<String>(programNode.path("jobs").size());

    for (JsonNode job : programNode.path("jobs"))
    {
        // get the name of the job
        String jobName = job.get("name").getTextValue();

        jobNames.add(jobName);

        // get the parents of the job
        List<String> parents = new ArrayList<String>();
        ArrayNode dependencies = (ArrayNode) job.get("dependsOn");
        JsonNode indexOfJob;
        for (JsonNode dependency : dependencies)
        {
            int index = dependency.getIntValue();
            indexOfJob = ((ArrayNode) programNode.get("jobs")).get(index);
            parents.add(indexOfJob.get("name").getTextValue());
        }

        // add the name, parents of the job, and the actual JsonNode job
        graph.addNode(jobName, parents, job);
    }
    // set the children field for parent job nodes
    graph.setChildren();

    // print graph
    System.out.println(graph.prettyPrint(jobNames));
}
 
Example 5
Source File: SamzaObjectMapper.java    From samza with Apache License 2.0 4 votes vote down vote up
@Override
public Partition deserialize(JsonParser jsonParser, DeserializationContext context) throws IOException, JsonProcessingException {
  ObjectCodec oc = jsonParser.getCodec();
  JsonNode node = oc.readTree(jsonParser);
  return new Partition(node.getIntValue());
}