@Override public String toString() { StringBuilder sb = new StringBuilder(); for(AttributeNode.Item item : attribute.getItems()) { sb.append(item.getName()).append("."); } sb.deleteCharAt(sb.length() - 1); return sb.toString() + ":" + comparison.getOperator() + now; }
public OrderingSpecification getOrdering(int order) { Stack<OrderingItem> buf = new Stack<>(); for (NodeItem item : items) { if (!buf.isEmpty()) { while (buf.peek().operator > item.operator) { pickOrdering(buf); } } buf.push(new OrderingItem(item.operator, item.node.getOrdering(order))); } while (buf.size() > 1) { pickOrdering(buf); } return buf.pop().ordering; }
/** * Visits the expression tree. * * @param visitor The visitor to use. */ public void visit(Visitor visitor) { expression.accept(visitor); } }
/** * Adds an (operator, node) pair to this expression. * * @param operator The operator that combines the previous with the node given. * @param node The node to add to this. * @return This, to allow chaining. */ public LogicNode add(String operator, ExpressionNode node) { items.add(new LogicNode.NodeItem(stringToOperator(operator), node)); return this; }
public ArithmeticNode add(String operator, ExpressionNode node) { items.add(new NodeItem(stringToOperator(operator), node)); return this; }
/** * Returns the ordering specification, if any, implied by this document * selection expression. * * @param order The order of the */ public OrderingSpecification getOrdering(int order) { return expression.getOrdering(order); }
public OrderingSpecification getOrdering(int order) { if (lhs instanceof IdNode && rhs instanceof LiteralNode) { return getOrdering((IdNode)lhs, (LiteralNode)rhs, operator, order); } else if (rhs instanceof IdNode && lhs instanceof LiteralNode) { return getOrdering((IdNode)rhs, (LiteralNode)rhs, operator, order); } return null; }