Package org.codehaus.jackson.node

Examples of org.codehaus.jackson.node.ArrayNode


        }
        ObjectNode objectNode = createSchemaNode("string", true);
        if (typeHint != null) {
            JavaType type = provider.constructType(typeHint);
            if (type.isEnumType()) {
                ArrayNode enumNode = objectNode.putArray("enum");
                for (SerializedString value : _values.values()) {
                    enumNode.add(value.getValue());
                }
            }
        }
        return objectNode;
    }
View Full Code Here


        return object;
    }

    private Object toArray(JsonNode node)
    {
        ArrayNode arrayNode = (ArrayNode) node;
        Object[] array = new Object[arrayNode.size()];
        Iterator<JsonNode> elements = arrayNode.getElements();
        for (int i = 0; i < array.length; i++)
        {
            array[i] = toObject(elements.next());
        }
        return array;
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();
        final Function<JsonNode, T> typedTransformer = asT(transformer); // necessary
                                                                         // to
                                                                         // do
                                                                         // in
                                                                         // two
View Full Code Here

        ensureIsAnArrayAtLeastAsLargeAs(i);
        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());
    }
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

  public Collection<String> listServers() {
    return handleResponse(resource(SERVERS_LIST), null, new ResponseHandler<Collection<String>>() {
      public Collection<String> onResponse(ClientResponse r) throws Exception {
        List<String> result = new ArrayList<String>();

        ArrayNode arrayNode = (ArrayNode) ((ObjectNode) OBJECT_MAPPER.readTree(r.getEntityInputStream())).get("servers");

        for (int i = 0; i < arrayNode.size(); i++) {
          result.add(arrayNode.get(i).asText());
        }

        return result;
      }
    });
View Full Code Here

    private void f_jackson() throws Exception {
        long startNano = System.nanoTime();
        for (int i = 0; i < COUNT; ++i) {
            ObjectMapper mapper = new ObjectMapper();
            ArrayNode node = (ArrayNode) mapper.readTree(text);
            JsonNode head = node.get(0);
            JsonNode body = node.get(1);
        }
        long nano = System.nanoTime() - startNano;
        System.out.println(NumberFormat.getInstance().format(nano));
    }
View Full Code Here

    @Override
    public void writeTo(Collection<IndexerDefinition> indices, Class<?> type,
                        Type genericType, Annotation[] annotations, MediaType mediaType,
                        MultivaluedMap<String, Object> httpHeaders, OutputStream outputStream)
            throws IOException, WebApplicationException {
        ArrayNode array = JsonNodeFactory.instance.arrayNode();
        IndexerDefinitionJsonSerDeser converter = IndexerDefinitionJsonSerDeser.INSTANCE;

        for (IndexerDefinition index : indices) {
            array.add(converter.toJson(index));
        }

        ObjectMapper objectMapper = new ObjectMapper();
        IOUtils.write(objectMapper.writeValueAsBytes(array), outputStream);
    }
View Full Code Here

            throw new RuntimeException("Error serializing indexer definition to JSON.", e);
        }
    }

    private String[] getStringArrayProperty(ObjectNode node, String property) {
        ArrayNode arrayNode = JsonUtil.getArray(node, property, null);
        if (arrayNode == null)
            return null;
        else {
            List<String> strings = new ArrayList<String>();
            for (JsonNode jsonNode : 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.