private BooleanExpression asBooleanExpression(Expression value) throws ParseException { if (value instanceof BooleanExpression) { return (BooleanExpression) value; } if (value instanceof PropertyExpression) { return UnaryExpression.createBooleanCast( value ); } throw new ParseException("Expression will not result in a boolean value: " + value); }
@SuppressWarnings({ "rawtypes", "unchecked" }) public static BooleanExpression createInFilter(Expression left, List elements) { if (!(left instanceof PropertyExpression)) { throw new RuntimeException("Expected a property for In expression, got: " + left); } return UnaryExpression.createInExpression((PropertyExpression)left, elements, false); }
jj_consume_token(38); left = unaryExpr(); left = UnaryExpression.createNegate(left); break; case NOT: jj_consume_token(NOT); left = unaryExpr(); left = UnaryExpression.createNOT( asBooleanExpression(left) ); break; case XPATH: jj_consume_token(XPATH); s = stringLitteral(); left = UnaryExpression.createXPath( s ); break; case XQUERY: jj_consume_token(XQUERY); s = stringLitteral(); left = UnaryExpression.createXQuery( s ); break; default:
/** * Finds the CacheExpression that has been associated with an expression. If * it is the first time the Expression is being added to the Cache, a new * CacheExpression is created and associated with the expression. <p/> This * method updates the reference counters on the CacheExpression to know when * it is no longer needed. */ private CacheExpression addToCache(Expression expr) { CacheExpression n = cachedExpressions.get(expr); if (n == null) { n = new CacheExpression(expr); cachedExpressions.put(expr, n); if (expr instanceof UnaryExpression) { // Cache the sub expressions too UnaryExpression un = (UnaryExpression)expr; un.setRight(addToCache(un.getRight())); } else if (expr instanceof BinaryExpression) { // Cache the sub expressions too. BinaryExpression bn = (BinaryExpression)expr; bn.setRight(addToCache(bn.getRight())); bn.setLeft(addToCache(bn.getLeft())); } } n.refCount++; return n; }
public static BooleanExpression createNotLike(Expression left, String right, String escape) { return UnaryExpression.createNOT(createLike(left, right, escape)); }
/** * TODO: more efficient hashCode() * * @see java.lang.Object#hashCode() */ public int hashCode() { return toString().hashCode(); }
/** * @see java.lang.Object#toString() */ public String toString() { return "(" + getExpressionSymbol() + " " + right.toString() + ")"; }
/** * Removes an expression from the cache. Updates the reference counters on * the CacheExpression object. When the refernce counter goes to zero, the * entry int the Expression to CacheExpression map is removed. * * @param cn */ private void removeFromCache(CacheExpression cn) { cn.refCount--; Expression realExpr = cn.getRight(); if (cn.refCount == 0) { cachedExpressions.remove(realExpr); } if (realExpr instanceof UnaryExpression) { UnaryExpression un = (UnaryExpression)realExpr; removeFromCache((CacheExpression)un.getRight()); } if (realExpr instanceof BinaryExpression) { BinaryExpression bn = (BinaryExpression)realExpr; removeFromCache((CacheExpression)bn.getRight()); } }
/** * Finds the CacheExpression that has been associated with an expression. If * it is the first time the Expression is being added to the Cache, a new * CacheExpression is created and associated with the expression. <p/> This * method updates the reference counters on the CacheExpression to know when * it is no longer needed. */ private CacheExpression addToCache(Expression expr) { CacheExpression n = cachedExpressions.get(expr); if (n == null) { n = new CacheExpression(expr); cachedExpressions.put(expr, n); if (expr instanceof UnaryExpression) { // Cache the sub expressions too UnaryExpression un = (UnaryExpression)expr; un.setRight(addToCache(un.getRight())); } else if (expr instanceof BinaryExpression) { // Cache the sub expressions too. BinaryExpression bn = (BinaryExpression)expr; bn.setRight(addToCache(bn.getRight())); bn.setLeft(addToCache(bn.getLeft())); } } n.refCount++; return n; }
public static BooleanExpression createNotEqual(Expression left, Expression right) { return UnaryExpression.createNOT(createEqual(left, right)); }
/** * TODO: more efficient hashCode() * * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object o) { if (o == null || !this.getClass().equals(o.getClass())) { return false; } return toString().equals(o.toString()); }
/** * @see java.lang.Object#toString() */ public String toString() { return "(" + getExpressionSymbol() + " " + right.toString() + ")"; }
/** * Removes an expression from the cache. Updates the reference counters on * the CacheExpression object. When the refernce counter goes to zero, the * entry int the Expression to CacheExpression map is removed. * * @param cn */ private void removeFromCache(CacheExpression cn) { cn.refCount--; Expression realExpr = cn.getRight(); if (cn.refCount == 0) { cachedExpressions.remove(realExpr); } if (realExpr instanceof UnaryExpression) { UnaryExpression un = (UnaryExpression)realExpr; removeFromCache((CacheExpression)un.getRight()); } if (realExpr instanceof BinaryExpression) { BinaryExpression bn = (BinaryExpression)realExpr; removeFromCache((CacheExpression)bn.getRight()); } }
jj_consume_token(38); left = unaryExpr(); left = UnaryExpression.createNegate(left); break; case NOT: jj_consume_token(NOT); left = unaryExpr(); left = UnaryExpression.createNOT( asBooleanExpression(left) ); break; case XPATH: jj_consume_token(XPATH); s = stringLitteral(); left = UnaryExpression.createXPath( s ); break; case XQUERY: jj_consume_token(XQUERY); s = stringLitteral(); left = UnaryExpression.createXQuery( s ); break; case TRUE:
/** * Finds the CacheExpression that has been associated with an expression. If * it is the first time the Expression is being added to the Cache, a new * CacheExpression is created and associated with the expression. <p/> This * method updates the reference counters on the CacheExpression to know when * it is no longer needed. */ private CacheExpression addToCache(Expression expr) { CacheExpression n = cachedExpressions.get(expr); if (n == null) { n = new CacheExpression(expr); cachedExpressions.put(expr, n); if (expr instanceof UnaryExpression) { // Cache the sub expressions too UnaryExpression un = (UnaryExpression)expr; un.setRight(addToCache(un.getRight())); } else if (expr instanceof BinaryExpression) { // Cache the sub expressions too. BinaryExpression bn = (BinaryExpression)expr; bn.setRight(addToCache(bn.getRight())); bn.setLeft(addToCache(bn.getLeft())); } } n.refCount++; return n; }
public static BooleanExpression createIsNotNull(Expression left) { return UnaryExpression.createNOT(doCreateEqual(left, ConstantExpression.NULL)); }
@SuppressWarnings({ "rawtypes", "unchecked" }) public static BooleanExpression createNotInFilter(Expression left, List elements) { if (!(left instanceof PropertyExpression)) { throw new RuntimeException("Expected a property for In expression, got: " + left); } return UnaryExpression.createInExpression((PropertyExpression)left, elements, true); }
/** * TODO: more efficient hashCode() * * @see java.lang.Object#hashCode() */ public int hashCode() { return toString().hashCode(); }
/** * @see java.lang.Object#toString() */ public String toString() { return "(" + getExpressionSymbol() + " " + right.toString() + ")"; }
private BooleanExpression asBooleanExpression(Expression value) throws ParseException { if (value instanceof BooleanExpression) { return (BooleanExpression) value; } if (value instanceof PropertyExpression) { return UnaryExpression.createBooleanCast( value ); } throw new ParseException("Expression will not result in a boolean value: " + value); }