Package org.sindice.siren.qparser.json.nodes

Examples of org.sindice.siren.qparser.json.nodes.NodeQueryNode


    this.keywordParser = keywordParser;
  }

  @Override
  public NodeQuery build(final QueryNode queryNode) throws QueryNodeException {
    final NodeQueryNode node = (NodeQueryNode) queryNode;
    final String field = node.getField().toString();
    final String expr = node.getValue().toString();
    final NodeQuery query = (NodeQuery) keywordParser.parse(expr, field);
    // check if the node has a level constraint
    if (node.getTag(LevelPropertyParser.LEVEL_PROPERTY) != null) {
      query.setLevelConstraint((Integer) node.getTag(LevelPropertyParser.LEVEL_PROPERTY));
    }
    // check if the node has a node range constraint
    if (node.getTag(RangePropertyParser.RANGE_PROPERTY) != null) {
      final int[] range = (int[]) node.getTag(RangePropertyParser.RANGE_PROPERTY);
      query.setNodeConstraint(range[0], range[1]);
    }
    return query;
  }
View Full Code Here


    return NODE_PROPERTY;
  }

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

    final LevelPropertyParser levelParser = new LevelPropertyParser(objectNode, field);
    levelParser.setOptional(true);
    if (levelParser.isPropertyDefined()) {
      queryNode.setTag(levelParser.getProperty(), levelParser.parse());
    }

    final RangePropertyParser rangeParser = new RangePropertyParser(objectNode, field);
    rangeParser.setOptional(true);
    if (rangeParser.isPropertyDefined()) {
      queryNode.setTag(rangeParser.getProperty(), rangeParser.parse());
    }

    return queryNode;
  }
View Full Code Here

TOP

Related Classes of org.sindice.siren.qparser.json.nodes.NodeQueryNode

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.