public NowQueryExpression(AttributeNode attribute, ComparisonNode comparison, ArithmeticNode arithmetic) { this.attribute = attribute; this.comparison = comparison; this.now = (arithmetic != null ? new NowQueryNode(arithmetic) : new NowQueryNode(0)); }
public Map<String, String> getQueryMap() { Map<String, String> ret = new HashMap<String, String>(); for (NowQueryExpression expression : expressionMap.values()) { ret.put(expression.getDocumentType(), expression.toString()); } return ret; }
public void visit(ComparisonNode node) { if (state != null) { throw new IllegalArgumentException("Comparison cannot be done within now expression"); } if (!hasNow(node)) { return; } state = new BuildState(); node.getLHS().accept(this); node.getRHS().accept(this); if (!">".equals(node.getOperator())) { throw new IllegalArgumentException("Comparison operator '" + node.getOperator() + "' is not supported"); } if (!(node.getLHS() instanceof AttributeNode)) { throw new IllegalArgumentException("Left hand side of comparison must be a document field"); } state.comparison = node; if (state.attribute != null && state.comparison != null && (state.arithmetic != null || state.now != null)) { NowQueryExpression expression = new NowQueryExpression(state.attribute, state.comparison, state.arithmetic); expressionMap.put(expression.getDocumentType(), expression); state = null; } }
public DocumentSelectionConverter(String selection) throws ParseException, UnsupportedOperationException, IllegalArgumentException { this.selector = new DocumentSelector(selection); NowCheckVisitor nowChecker = new NowCheckVisitor(); selector.visit(nowChecker); if (nowChecker.requiresConversion()) { SelectionExpressionConverter converter = new SelectionExpressionConverter(); selector.visit(converter); this.queryExpressionMap = converter.getQueryMap(); } else { this.queryExpressionMap = null; } }