Package org.codehaus.jackson

Examples of org.codehaus.jackson.JsonNode


  private void convertTetheredCable(final JsonNode obj) {
    final Iterator<JsonNode> nodes = obj.path("Connector").iterator();
    while (nodes.hasNext()) {
      final ObjectNode node = (ObjectNode) nodes.next();
      final JsonNode current = node.path("TetheredCable");
      if (!current.isMissingNode() && !current.isNull()) {
        final int value = Integer.parseInt(current.asText());
        node.put("TetheredCable", value);
      }
      if (current.isNull()) {
        node.remove("TetheredCable");
      }
    }
  }
View Full Code Here


  private void convertChargeMode(final JsonNode obj) {
    final Iterator<JsonNode> nodes = obj.path("Connector").iterator();
    while (nodes.hasNext()) {
      final ObjectNode node = (ObjectNode) nodes.next();
      final JsonNode current = node.path("ChargeMode");
      if (!current.isMissingNode() && !current.isNull()) {
        final int value = Integer.parseInt(current.asText());
        node.put("ChargeMode", value);
      }
      if (current.isNull()) {
        node.remove("ChargeMode");
      }
    }
  }
View Full Code Here

    }
  }

  private void convertLatitude(final JsonNode obj) {
    final ObjectNode node = (ObjectNode) obj.path("ChargeDeviceLocation");
    final JsonNode current = node.path("Latitude");
    if (!current.isMissingNode() && !current.isNull()) {
      final double value = Double.parseDouble(current.asText());
      node.put("Latitude", value);
    }
    if (current.isNull()) {
      node.remove("Latitude");
    }
  }
View Full Code Here

    }
  }

  private void convertLongitude(final JsonNode obj) {
    final ObjectNode node = (ObjectNode) obj.path("ChargeDeviceLocation");
    final JsonNode current = node.path("Longitude");
    if (!current.isMissingNode() && !current.isNull()) {
      final double value = Double.parseDouble(current.asText());
      node.put("Longitude", value);
    }
    if (current.isNull()) {
      node.remove("Longitude");
    }
  }
View Full Code Here

    }
  }

  private void convertDeviceControllerWebsite(final JsonNode obj) {
    final ObjectNode node = (ObjectNode) obj.path("DeviceController");
    final JsonNode current = node.path("Website");
    if (!current.isMissingNode() && !current.isNull()) {
      node.put("Website", this.createValueDatatype("uri", current.asText()));
    }
    if (current.isNull()) {
      node.remove("Website");
    }
  }
View Full Code Here

    }
  }

  private void convertDeviceOwnerWebsite(final JsonNode obj) {
    final ObjectNode node = (ObjectNode) obj.path("DeviceOwner");
    final JsonNode current = node.path("Website");
    if (!current.isMissingNode() && !current.isNull()) {
      node.put("Website", this.createValueDatatype("uri", current.asText()));
    }
    if (current.isNull()) {
      node.remove("Website");
    }
  }
View Full Code Here

  }

  @Override
  int[] parse() throws ParseException {
    final int[] range = new int[2];
    final JsonNode value = node.path(RANGE_PROPERTY);

    if (!(value.isArray() && (value.size() == 2))) {
      throw new ParseException("Invalid value for property '" + RANGE_PROPERTY + "'");
    }

    final Iterator<JsonNode> it = value.iterator();
    JsonNode e;
    for (int i = 0; i < 2; i++) {
      e = it.next();
      if (!e.isInt()) {
        throw new ParseException("Invalid property '" + RANGE_PROPERTY + "': range value is not an integer");
      }
      range[i] = e.asInt();
    }

    return range;
  }
View Full Code Here

    return BOOLEAN_PROPERTY;
  }

  @Override
  BooleanQueryNode parse() throws ParseException {
    final JsonNode value = node.path(BOOLEAN_PROPERTY);
    if (!value.isArray()) {
      throw new ParseException("Invalid property '" + BOOLEAN_PROPERTY + "': value is not an array");
    }

    final BooleanQueryNode booleanNode = new BooleanQueryNode();

    final Iterator<JsonNode> elements = value.getElements();
    while (elements.hasNext()) {
      final JsonNode element = elements.next();

      // parse occur
      final OccurPropertyParser occurParser = new OccurPropertyParser(element, field);
      Modifier mod = null;
      if (occurParser.isPropertyDefined()) {
        mod = occurParser.parse();
      }

      // check if there is either a node or a twig property and parse it
      QueryNode queryNode = null;
      if (element.has(NodePropertyParser.NODE_PROPERTY)) {
        final NodePropertyParser nodeParser = new NodePropertyParser(element, field);
        queryNode = nodeParser.parse();
      }
      if (element.has(TwigPropertyParser.TWIG_PROPERTY)) {
        final TwigPropertyParser twigParser = new TwigPropertyParser(element, field);
        queryNode = twigParser.parse();
      }

      // check if either a node or twig property has been defined
View Full Code Here

    return OCCUR_PROPERTY;
  }

  @Override
  Modifier parse() throws ParseException {
    final JsonNode value = node.path(OCCUR_PROPERTY);

    if (!value.isTextual()) {
      throw new ParseException("Invalid property'" + OCCUR_PROPERTY + "': value is not textual");
    }

    try {
      final Occur occur = Occur.valueOf(value.asText());
      switch (occur) {
        case MUST:
          return Modifier.MOD_REQ;

        case SHOULD:
          return Modifier.MOD_NONE;

        case MUST_NOT:
          return Modifier.MOD_NOT;

        default:
          throw new ParseException("Invalid value '" + value.asText() + "' for property '" + OCCUR_PROPERTY + "'");
      }
    }
    catch (final IllegalArgumentException e) {
      throw new ParseException("Invalid value '" + value.asText() + "' for property '" + OCCUR_PROPERTY + "'", e);
    }
  }
View Full Code Here

  @Override
  NodeQueryNode parse() throws ParseException {
    final NodeQueryNode queryNode = new NodeQueryNode();
    queryNode.setField(field);

    final JsonNode objectNode = node.path(this.getProperty());

    final QueryPropertyParser queryParser = new QueryPropertyParser(objectNode, field);
    if (queryParser.isPropertyDefined()) {
      queryNode.setValue(queryParser.parse());
    }
View Full Code Here

TOP

Related Classes of org.codehaus.jackson.JsonNode

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.