Esempio n. 1
0
  /**
   * Handles the given {@link JsonNode} and writes the responses to the given {@link OutputStream}.
   *
   * @param node the {@link JsonNode}
   * @param ops the {@link OutputStream}
   * @throws IOException on error
   */
  protected void handleNode(JsonNode node, OutputStreamWrapper opsw) throws IOException {

    // handle objects
    if (node.isObject()) {
      handleObject(ObjectNode.class.cast(node), opsw);

      // handle arrays
    } else if (node.isArray()) {
      handleArray(ArrayNode.class.cast(node), opsw);

      // bail on bad data
    } else {
      throw new IllegalArgumentException("Invalid JsonNode type: " + node.getClass().getName());
    }
  }
Esempio n. 2
0
  /**
   * Handles the given {@link JsonNode} and writes the responses to the given {@link OutputStream}.
   *
   * @param node the {@link JsonNode}
   * @param ops the {@link OutputStream}
   * @throws JsonGenerationException
   * @throws JsonMappingException
   * @throws IOException
   */
  private void handleNode(JsonNode node, OutputStream ops)
      throws JsonGenerationException, JsonMappingException, IOException {

    // handle objects
    if (node.isObject()) {
      handleObject(ObjectNode.class.cast(node), ops);

      // handle arrays
    } else if (node.isArray()) {
      handleArray(ArrayNode.class.cast(node), ops);

      // bail on bad data
    } else {
      throw new IllegalArgumentException("Invalid JsonNode type: " + node.getClass().getName());
    }
  }