/** * Creates a copy of this expression node, without copying children. */ @Override public Expression shallowCopy() { return new ASTList(id); }
@Override public void jjtClose() { super.jjtClose(); // For backwards compatibility set a List value wrapping the nodes. // or maybe we should rewrite the parser spec to insert children // directly into internal collection? int size = jjtGetNumChildren(); Object[] listValue = new Object[size]; for (int i = 0; i < size; i++) { listValue[i] = unwrapChild(jjtGetChild(i)); } setValues(listValue); // clean children - we are not supposed to use them anymore children = null; }
/** * Initializes a list expression with a Java Collection */ public ASTList(Collection<?> objects) { super(ExpressionParserTreeConstants.JJTLIST); setValues(objects); }
public void encodeAsString(PrintWriter pw) { pw.print('('); if ((values != null) && (values.length > 0)) { for (int i = 0; i < values.length; ++i) { if (i > 0) { pw.print(getExpressionOperator(i)); pw.print(' '); } if (values[i] instanceof Expression) { ((Expression) values[i]).encodeAsString(pw); } else { encodeScalarAsString(pw, values[i]); } } } pw.print(')'); }
/** * @since 4.0 */ @Override public void appendAsString(Appendable out) throws IOException { out.append('('); if ((values != null) && (values.length > 0)) { for (int i = 0; i < values.length; ++i) { if (i > 0) { out.append(getExpressionOperator(i)); out.append(' '); } if (values[i] instanceof Expression) { ((Expression) values[i]).appendAsString(out); } else { appendScalarAsString(out, values[i], '\"'); } } } out.append(')'); }
Object[] values = (Object[]) ((ASTList) operand).getOperand(0); for (Object value : values) { if (value instanceof ExpressionParameter) {
/** * Sets an internal collection of values. Value argument can be an Object[], * a Collection or an iterator. */ protected void setValues(Object value) { if (value == null) { this.values = null; } else if (value instanceof Object[]) { int size = ((Object[]) value).length; this.values = new Object[size]; System.arraycopy((Object[]) value, 0, this.values, 0, size); } else if (value instanceof Collection) { Collection<?> c = (Collection<?>) value; this.values = c.toArray(new Object[c.size()]); } else if (value instanceof Iterator) { List<Object> values = new ArrayList<>(); Iterator<?> it = (Iterator<?>) value; while (it.hasNext()) { values.add(it.next()); } this.values = values.toArray(); } else { throw new IllegalArgumentException("Invalid value class '" + value.getClass().getName() + "', expected null, Object[], Collection, Iterator"); } convertValues(); }
/** * Initializes a list expression with a Java Iterator. */ public ASTList(Iterator<?> objects) { super(ExpressionParserTreeConstants.JJTLIST); setValues(objects); }
Object[] values = (Object[]) ((ASTList) operand).getOperand(0); for (Object value : values) { if (value instanceof ExpressionParameter) {
public void jjtClose() { super.jjtClose(); // For backwards compatibility set a List value wrapping the nodes. // or maybe we should rewrite the parser spec to insert children // directly into internal collection? int size = jjtGetNumChildren(); Object[] listValue = new Object[size]; for (int i = 0; i < size; i++) { listValue[i] = unwrapChild(jjtGetChild(i)); } setValues(listValue); // clean children - we are not supposed to use them anymore children = null; } }
/** * Creates a copy of this expression node, without copying children. */ public Expression shallowCopy() { return new ASTList(id); }
/** * Initializes a list expression with an Object[]. */ public ASTList(Object[] objects) { super(ExpressionParserTreeConstants.JJTLIST); setValues(objects); }
/** * Applies a few default rules for adding operands to expressions. In * particular wraps all lists into LIST expressions. Applied only in path * expressions. */ protected static Object wrapPathOperand(Object op) { if (op instanceof Collection<?>) { return new ASTList((Collection<?>) op); } else if (op instanceof Object[]) { return new ASTList((Object[]) op); } else { return op; } }
/** * Initializes a list expression with a Java Collection */ public ASTList(Collection objects) { super(ExpressionParserTreeConstants.JJTLIST); setValues(objects); }
/** * Applies a few default rules for adding operands to expressions. In particular wraps * all lists into LIST expressions. Applied only in path expressions. */ protected static Object wrapPathOperand(Object op) { if (op instanceof Collection) { return new ASTList((Collection) op); } else if (op instanceof Object[]) { return new ASTList((Object[]) op); } else { return op; } }
/** * Initializes a list expression with an Object[]. */ public ASTList(Object[] objects) { super(ExpressionParserTreeConstants.JJTLIST); setValues(objects); }
/** * @since 4.0 * @see ExpressionFactory#notInExp(String, Object[]) */ static Expression notInExp(Expression exp, Object... values) { if (values.length == 0) { return new ASTTrue(); } if(!(exp instanceof SimpleNode)) { throw new IllegalArgumentException("exp should be instance of SimpleNode"); } return new ASTNotIn((SimpleNode)exp, new ASTList(values)); }
/** * Initializes a list expression with a Java Iterator. */ public ASTList(Iterator objects) { super(ExpressionParserTreeConstants.JJTLIST); setValues(objects); }
/** * @since 4.0 * @see ExpressionFactory#inExp(String, Collection) */ static Expression inExp(Expression exp, Collection<?> values) { if (values.isEmpty()) { return new ASTFalse(); } if(!(exp instanceof SimpleNode)) { throw new IllegalArgumentException("exp should be instance of SimpleNode"); } return new ASTIn((SimpleNode)exp, new ASTList(values)); }
public void setOperand(int index, Object value) { if (index != 0) { throw new ArrayIndexOutOfBoundsException(index); } setValues(value); }