private void processNode(QueryNode node) { if (node instanceof AndQueryNode || node instanceof OrQueryNode) { if (!this.latestNodeVerified && !this.queryNodeList.isEmpty()) { this.queryNodeList.add(applyModifier(this.queryNodeList .remove(this.queryNodeList.size() - 1), node)); this.latestNodeVerified = true; } } else if (!(node instanceof BooleanQueryNode)) { this.queryNodeList.add(applyModifier(node, node.getParent())); this.latestNodeVerified = false; } }
private void readTree(QueryNode node) { if (node instanceof BooleanQueryNode) { List<QueryNode> children = node.getChildren(); if (children != null && children.size() > 0) { for (int i = 0; i < children.size() - 1; i++) { readTree(children.get(i)); } processNode(node); readTree(children.get(children.size() - 1)); } else { processNode(node); } } else { processNode(node); } }
@Override public QueryNode process(QueryNode queryTree) throws QueryNodeException { Operator defaultOperator = getQueryConfigHandler().get(ConfigurationKeys.DEFAULT_OPERATOR); if (defaultOperator == null) { throw new IllegalArgumentException( "DEFAULT_OPERATOR should be set on the QueryConfigHandler"); } this.usingAnd = StandardQueryConfigHandler.Operator.AND == defaultOperator; if (queryTree instanceof GroupQueryNode) { queryTree = ((GroupQueryNode) queryTree).getChild(); } this.queryNodeList = new ArrayList<>(); this.latestNodeVerified = false; readTree(queryTree); List<QueryNode> actualQueryNodeList = this.queryNodeList; for (int i = 0; i < actualQueryNodeList.size(); i++) { QueryNode node = actualQueryNodeList.get(i); if (node instanceof GroupQueryNode) { actualQueryNodeList.set(i, process(node)); } } this.usingAnd = false; if (queryTree instanceof BooleanQueryNode) { queryTree.set(actualQueryNodeList); return queryTree; } else { return new BooleanQueryNode(actualQueryNodeList); } }
@Override public QueryNode process(QueryNode queryTree) throws QueryNodeException { Operator defaultOperator = getQueryConfigHandler().get(ConfigurationKeys.DEFAULT_OPERATOR); if (defaultOperator == null) { throw new IllegalArgumentException( "DEFAULT_OPERATOR should be set on the QueryConfigHandler"); } this.usingAnd = StandardQueryConfigHandler.Operator.AND == defaultOperator; if (queryTree instanceof GroupQueryNode) { queryTree = ((GroupQueryNode) queryTree).getChild(); } this.queryNodeList = new ArrayList<>(); this.latestNodeVerified = false; readTree(queryTree); List<QueryNode> actualQueryNodeList = this.queryNodeList; for (int i = 0; i < actualQueryNodeList.size(); i++) { QueryNode node = actualQueryNodeList.get(i); if (node instanceof GroupQueryNode) { actualQueryNodeList.set(i, process(node)); } } this.usingAnd = false; if (queryTree instanceof BooleanQueryNode) { queryTree.set(actualQueryNodeList); return queryTree; } else { return new BooleanQueryNode(actualQueryNodeList); } }
private void readTree(QueryNode node) { if (node instanceof BooleanQueryNode) { List<QueryNode> children = node.getChildren(); if (children != null && children.size() > 0) { for (int i = 0; i < children.size() - 1; i++) { readTree(children.get(i)); } processNode(node); readTree(children.get(children.size() - 1)); } else { processNode(node); } } else { processNode(node); } }
private void processNode(QueryNode node) { if (node instanceof AndQueryNode || node instanceof OrQueryNode) { if (!this.latestNodeVerified && !this.queryNodeList.isEmpty()) { this.queryNodeList.add(applyModifier(this.queryNodeList .remove(this.queryNodeList.size() - 1), node)); this.latestNodeVerified = true; } } else if (!(node instanceof BooleanQueryNode)) { this.queryNodeList.add(applyModifier(node, node.getParent())); this.latestNodeVerified = false; } }