/** * Creates a new expression that joins this object with other expressions, * using specified join type. It is very useful for incrementally building * chained expressions, like long AND or OR statements. * * @since 4.0 */ public Expression joinExp(int type, Expression exp, Expression... expressions) { Expression join = ExpressionFactory.expressionOfType(type); join.setOperand(0, this); join.setOperand(1, exp); for (int i = 0; i < expressions.length; i++) { Expression expressionInArray = expressions[i]; join.setOperand(2 + i, expressionInArray); } join.flattenTree(); return join; }
/** * Creates a new expression that joins this object with another expression, using * specified join type. It is very useful for incrementally building chained * expressions, like long AND or OR statements. */ public Expression joinExp(int type, Expression exp) { Expression join = ExpressionFactory.expressionOfType(type); join.setOperand(0, this); join.setOperand(1, exp); join.flattenTree(); return join; }
public Expression notExp() { Expression exp = ExpressionFactory.expressionOfType(Expression.NOT); exp.setOperand(0, this); return exp; }
public Expression notExp() { Expression exp = ExpressionFactory.expressionOfType(Expression.NOT); exp.setOperand(0, this); return exp; }
public Expression notExp() { Expression exp = ExpressionFactory.expressionOfType(Expression.NOT); exp.setOperand(0, this); return exp; }
public Expression notExp() { Expression exp = ExpressionFactory.expressionOfType(Expression.NOT); exp.setOperand(0, this); return exp; }
private static Expression join(int type, Expression... expressions) { int len = expressions != null ? expressions.length : 0; if (len == 0) { return null; } Expression currentExp = expressions[0]; if (len == 1) { return currentExp; } Expression exp = expressionOfType(type); for (int i = 0; i < len; i++) { exp.setOperand(i, expressions[i]); } return exp; }
/** * Creates an expression that matches any of the key-values pairs in * <code>map</code>. * <p> * For each pair <code>pairType</code> operator is used to build a binary * expression. Key is considered to be a DB_PATH expression. OR is used to * join pair binary expressions. */ public static Expression matchAnyDbExp(Map<String, ?> map, int pairType) { List<Expression> pairs = new ArrayList<>(map.size()); for (Map.Entry<String, ?> entry : map.entrySet()) { Expression exp = expressionOfType(pairType); exp.setOperand(0, new ASTDbPath(entry.getKey())); exp.setOperand(1, wrapPathOperand(entry.getValue())); pairs.add(exp); } return joinExp(Expression.OR, pairs); }
/** * Creates an expression that matches any of the key-values pairs in the * <code>map</code>. * <p> * For each pair <code>pairType</code> operator is used to build a binary * expression. Key is considered to be a OBJ_PATH expression. OR is used to * join pair binary expressions. */ public static Expression matchAnyExp(Map<String, ?> map, int pairType) { List<Expression> pairs = new ArrayList<>(map.size()); for (Map.Entry<String, ?> entry : map.entrySet()) { Expression exp = expressionOfType(pairType); exp.setOperand(0, new ASTObjPath(entry.getKey())); exp.setOperand(1, wrapPathOperand(entry.getValue())); pairs.add(exp); } return joinExp(Expression.OR, pairs); }
/** * Creates an expression that matches all key-values pairs in * <code>map</code>. * <p> * For each pair <code>pairType</code> operator is used to build a binary * expression. Key is considered to be a DB_PATH expression. AND is used to * join pair binary expressions. */ public static Expression matchAllDbExp(Map<String, ?> map, int pairType) { List<Expression> pairs = new ArrayList<>(map.size()); for (Map.Entry<String, ?> entry : map.entrySet()) { Expression exp = expressionOfType(pairType); exp.setOperand(0, new ASTDbPath(entry.getKey())); exp.setOperand(1, wrapPathOperand(entry.getValue())); pairs.add(exp); } return joinExp(Expression.AND, pairs); }
/** * Creates an expression that matches any of the key-values pairs in <code>map</code>. * <p> * For each pair <code>pairType</code> operator is used to build a binary * expression. Key is considered to be a DB_PATH expression. Therefore all keys must * be java.lang.String objects, or ClassCastException is thrown. OR is used to join * pair binary expressions. */ public static Expression matchAnyDbExp(Map map, int pairType) { List pairs = new ArrayList(); Iterator it = map.entrySet().iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); Expression exp = expressionOfType(pairType); exp.setOperand(0, new ASTDbPath(entry.getKey())); exp.setOperand(1, wrapPathOperand(entry.getValue())); pairs.add(exp); } return joinExp(Expression.OR, pairs); }
/** * Creates an expression that matches all key-values pairs in <code>map</code>. * <p> * For each pair <code>pairType</code> operator is used to build a binary * expression. Key is considered to be a DB_PATH expression. Therefore all keys must * be java.lang.String objects, or ClassCastException is thrown. AND is used to join * pair binary expressions. */ public static Expression matchAllDbExp(Map map, int pairType) { List pairs = new ArrayList(); Iterator it = map.entrySet().iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); Expression exp = expressionOfType(pairType); exp.setOperand(0, new ASTDbPath(entry.getKey())); exp.setOperand(1, wrapPathOperand(entry.getValue())); pairs.add(exp); } return joinExp(Expression.AND, pairs); }
/** * Creates an expression that matches all key-values pairs in * <code>map</code>. * <p> * For each pair <code>pairType</code> operator is used to build a binary * expression. Key is considered to be a OBJ_PATH expression. AND is used to * join pair binary expressions. */ public static Expression matchAllExp(Map<String, ?> map, int pairType) { List<Expression> pairs = new ArrayList<>(map.size()); for (Map.Entry<String, ?> entry : map.entrySet()) { Expression exp = expressionOfType(pairType); exp.setOperand(0, new ASTObjPath(entry.getKey())); exp.setOperand(1, wrapPathOperand(entry.getValue())); pairs.add(exp); } return joinExp(Expression.AND, pairs); }
/** * Creates an expression that matches all key-values pairs in <code>map</code>. * <p> * For each pair <code>pairType</code> operator is used to build a binary * expression. Key is considered to be a OBJ_PATH expression. Therefore all keys must * be java.lang.String objects, or ClassCastException is thrown. AND is used to join * pair binary expressions. */ public static Expression matchAllExp(Map map, int pairType) { List pairs = new ArrayList(); Iterator it = map.entrySet().iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); Expression exp = expressionOfType(pairType); exp.setOperand(0, new ASTObjPath(entry.getKey())); exp.setOperand(1, wrapPathOperand(entry.getValue())); pairs.add(exp); } return joinExp(Expression.AND, pairs); }
@Override public void finishedChild(Expression parentNode, int childIndex, boolean hasMoreChildren) { Object childNode = parentNode.getOperand(childIndex); if (childNode instanceof ASTObjPath) { // validate and replace if needed ... note that we can only // replace non-root nodes during the traversal. Root node is // validated and replaced explicitly by the caller. ASTPath replacement = pathCache.getPathDescriptor(entity, (ASTObjPath) childNode).getPathExp(); if (replacement != childNode) { parentNode.setOperand(childIndex, replacement); } } }
public Object transform(Object input) { if (!(input instanceof Expression)) { return input; } Expression expression = (Expression) input; if (expression.getType() != Expression.OBJ_PATH) { return input; } // convert obj_path to db_path String converted = toDbPath(createPathIterator((String) expression.getOperand(0))); Expression exp = ExpressionFactory.expressionOfType(Expression.DB_PATH); exp.setOperand(0, converted); return exp; } }
public Object transform(Object input) { if (!(input instanceof Expression)) { return input; } Expression expression = (Expression) input; if (expression.getType() != Expression.DB_PATH) { return input; } String path = (String) expression.getOperand(0); String converted = translatePath(path); Expression transformed = ExpressionFactory .expressionOfType(Expression.DB_PATH); transformed.setOperand(0, converted); return transformed; }
public Object transform(Object input) { if (!(input instanceof Expression)) { return input; } Expression expression = (Expression) input; if (expression.getType() != Expression.OBJ_PATH) { return input; } // convert obj_path to db_path String converted = toDbPath(resolvePathComponents(expression)); Expression exp = ExpressionFactory.expressionOfType(Expression.DB_PATH); exp.setOperand(0, converted); return exp; } }
public Object transform(Object input) { if (!(input instanceof Expression)) { return input; } Expression expression = (Expression) input; if (expression.getType() != Expression.DB_PATH) { return input; } String path = (String) expression.getOperand(0); String converted = translatePath(path); Expression transformed = ExpressionFactory.expressionOfType(Expression.DB_PATH); transformed.setOperand(0, converted); return transformed; }
@Override public void finishedChild(Expression node, int childIndex, boolean hasMoreChildren) { Object child = node.getOperand(childIndex); if (child instanceof ExpressionParameter) { node.setOperand(childIndex, nextValue(((ExpressionParameter) child).getName())); } // normally Object[] is an ASTList child else if (child instanceof Object[]) { Object[] array = (Object[]) child; for (int i = 0; i < array.length; i++) { if (array[i] instanceof ExpressionParameter) { array[i] = nextValue(((ExpressionParameter) array[i]).getName()); } } } }