public QueryNode parse(final CharSequence query, final CharSequence field)
throws QueryNodeParseException {
try {
final JsonNode node = mapper.readTree(query.toString());
final String fieldname = this.getFirstFieldName(node);
final TopLevelQueryNode topNode = new TopLevelQueryNode();
// check for node property
if (fieldname.equals(NodePropertyParser.NODE_PROPERTY)) {
final NodePropertyParser nodeParser = new NodePropertyParser(node, field);
topNode.add(nodeParser.parse());
return topNode;
}
// check for twig property
if (fieldname.equals(TwigPropertyParser.TWIG_PROPERTY)) {
final TwigPropertyParser twigParser = new TwigPropertyParser(node, field);
topNode.add(twigParser.parse());
return topNode;
}
// check for boolean property
if (fieldname.equals(BooleanPropertyParser.BOOLEAN_PROPERTY)) {
final BooleanPropertyParser booleanParser = new BooleanPropertyParser(node, field);
topNode.add(booleanParser.parse());
return topNode;
}
throw new ParseException("Invalid JSON query: unknown property '" + fieldname + "'");
}
catch (final IOException e) {