Package org.codehaus.jackson.node

Examples of org.codehaus.jackson.node.ArrayNode


    public ObjectNode toJSON() {
        ObjectNode obj = new ObjectNode(JsonNodeFactory.instance);
        obj.put("id", id.toString());
        obj.put("senderId", senderId);

        ArrayNode array = obj.putArray("receiverIds");
        for (String receiverId : receiverIds)
            array.add(receiverId);

        if (eventId != null)
            obj.put("eventId", eventId);
        obj.put("messageId", messageId);
View Full Code Here


    public static JsonRepresentation newArray() {
        return newArray(0);
    }

    public static JsonRepresentation newArray(final int initialSize) {
        final ArrayNode arrayNode = new ArrayNode(JsonNodeFactory.instance);
        for (int i = 0; i < initialSize; i++) {
            arrayNode.addNull();
        }
        return new JsonRepresentation(arrayNode);
    }
View Full Code Here

    }

    public <T> Iterator<T> arrayIterator(final Class<T> requiredType) {
        ensureIsAnArrayAtLeastAsLargeAs(0);
        final Function<JsonNode, ?> transformer = representationInstantiatorFor(requiredType);
        final ArrayNode arrayNode = (ArrayNode) jsonNode;
        final Iterator<JsonNode> iterator = arrayNode.iterator();
        // necessary to do in two steps
        final Function<JsonNode, T> typedTransformer = asT(transformer);
        return Iterators.transform(iterator, typedTransformer);
    }
View Full Code Here

        ensureIsAnArrayAtLeastAsLargeAs(i+1);
        if (objectRepr.isArray()) {
            throw new IllegalArgumentException("Representation being set cannot be an array");
        }
        // can safely downcast because *this* representation is an array
        final ArrayNode arrayNode = (ArrayNode) jsonNode;
        arrayNode.set(i, objectRepr.asJsonNode());
        return this;
    }
View Full Code Here

        case 0:
            return NullNode.getInstance();
        case 1:
            return matching.get(0);
        default:
            final ArrayNode arrayNode = new ArrayNode(JsonNodeFactory.instance);
            arrayNode.addAll(matching);
            return arrayNode;
        }
    }
View Full Code Here

   
    // find array node, to append new config
    if (node.get(key) != null && !node.get(key).isArray()) {
      node.remove(key);
    }
    ArrayNode array = (ArrayNode) node.get(key);
    if (array == null) {           // if not, create one
      array = node.arrayNode();
      node.put(key, array);
     
    }
   
    if (! (array instanceof ArrayNode) ) {
      throw new MException(key + " is not an array");
    }
   
    // create new object node in array
    ObjectNode out = array.objectNode();
    array.add(out);
   
    return new JsonConfig(key, this, out);
  }
View Full Code Here

    public static JsonRepresentation newArray() {
        return newArray(0);
    }

    public static JsonRepresentation newArray(final int initialSize) {
        final ArrayNode arrayNode = new ArrayNode(JsonNodeFactory.instance);
        for (int i = 0; i < initialSize; i++) {
            arrayNode.addNull();
        }
        return new JsonRepresentation(arrayNode);
    }
View Full Code Here

    }

    public <T> Iterator<T> arrayIterator(final Class<T> requiredType) {
        ensureIsAnArrayAtLeastAsLargeAs(0);
        final Function<JsonNode, ?> transformer = representationInstantiatorFor(requiredType);
        final ArrayNode arrayNode = (ArrayNode) jsonNode;
        final Iterator<JsonNode> iterator = arrayNode.iterator();
        // necessary to do in two steps
        final Function<JsonNode, T> typedTransformer = asT(transformer);
        return Iterators.transform(iterator, typedTransformer);
    }
View Full Code Here

        ensureIsAnArrayAtLeastAsLargeAs(i+1);
        if (objectRepr.isArray()) {
            throw new IllegalArgumentException("Representation being set cannot be an array");
        }
        // can safely downcast because *this* representation is an array
        final ArrayNode arrayNode = (ArrayNode) jsonNode;
        arrayNode.set(i, objectRepr.asJsonNode());
        return this;
    }
View Full Code Here

        case 0:
            return NullNode.getInstance();
        case 1:
            return matching.get(0);
        default:
            final ArrayNode arrayNode = new ArrayNode(JsonNodeFactory.instance);
            arrayNode.addAll(matching);
            return arrayNode;
        }
    }
View Full Code Here

TOP

Related Classes of org.codehaus.jackson.node.ArrayNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.