void onFinish() { if (i < parameters.length) { throw new ExpressionException("Too many parameters to bind expression. Expected: " + i + ", actual: " + parameters.length); } }
@Override protected Object evaluateNode(Object o) throws Exception { throw new ExpressionException("Uninitialized parameter: " + value + ", call 'expWithParameters' first."); }
protected Object evaluateNode(Object o) throws Exception { throw new ExpressionException( "Uninitialized parameter: " + value + ", call 'expWithParameters' first."); }
void onFinish() { if (i < positionalParams.size()) { throw new ExpressionException("Too many parameters to bind template. Expected: " + i + ", actual: " + positionalParams.size()); } } }
public static BigDecimal toBigDecimal(Object object) { if (object == null) { return null; } else if (object instanceof BigDecimal) { return (BigDecimal) object; } else if (object instanceof BigInteger) { return new BigDecimal((BigInteger) object); } else if (object instanceof Number) { return new BigDecimal(((Number) object).doubleValue()); } throw new ExpressionException("Can't convert to BigDecimal: " + object); }
public static BigDecimal toBigDecimal(Object object) { if (object == null) { return null; } else if (object instanceof BigDecimal) { return (BigDecimal) object; } else if (object instanceof BigInteger) { return new BigDecimal((BigInteger) object); } else if (object instanceof Number) { return new BigDecimal(((Number) object).doubleValue()); } throw new ExpressionException("Can't convert to BigDecimal: " + object); }
public void setValue(Object value) { if (value == null) { throw new ExpressionException("Null Parameter value"); } String name = value.toString().trim(); if (name.length() == 0) { throw new ExpressionException("Empty Parameter value"); } super.setValue(new ExpressionParameter(name)); } }
@Override public void setValue(Object value) { if (value == null) { throw new ExpressionException("Null Parameter value"); } String name = value.toString().trim(); if (name.length() == 0) { throw new ExpressionException("Empty Parameter value"); } super.setValue(new ExpressionParameter(name)); }
private ExpressionException invalidPathException(String message, String pathComponent) { StringBuilder buffer = new StringBuilder(); buffer .append(message) .append(": [") .append(currentEntity.getName()) .append('.') .append(pathComponent) .append("]."); return new ExpressionException(buffer.toString(), path, null); }
@Override public Object visit(ASTReference node, Object data) { // strip off leading "$" String paramName = node.getFirstToken().image.substring(1); // only consider the first instance of each named parameter if (!params.containsKey(paramName)) { if (i >= positionalParams.size()) { throw new ExpressionException("Too few parameters to bind template: " + positionalParams.size()); } params.put(paramName, positionalParams.get(i)); i++; } return data; }
@Override public void jjtSetParent(Node n) { // this is a check that we can't handle properly // in the grammar... do it here... // disallow non-aggregated condition parents... if (!(n instanceof AggregateConditionNode)) { String label = (n instanceof SimpleNode) ? ((SimpleNode) n).expName() : String.valueOf(n); throw new ExpressionException(expName() + ": invalid parent - " + label); } super.jjtSetParent(n); }
@Override public void jjtAddChild(Node n, int i) { // this is a check that we can't handle properly // in the grammar... do it here... // only allow conditional nodes...no scalars if (!(n instanceof ConditionNode) && !(n instanceof AggregateConditionNode)) { String label = (n instanceof SimpleNode) ? ((SimpleNode) n).expName() : String.valueOf(n); throw new ExpressionException(expName() + ": invalid child - " + label); } super.jjtAddChild(n, i); } }
public void jjtSetParent(Node n) { // this is a check that we can't handle properly // in the grammar... do it here... // disallow non-aggregated condition parents... if (!(n instanceof AggregateConditionNode)) { String label = (n instanceof SimpleNode) ? ((SimpleNode)n).expName() : String.valueOf(n); throw new ExpressionException(expName() + ": invalid parent - " + label); } super.jjtSetParent(n); } }
@Override public void jjtSetParent(Node n) { // this is a check that we can't handle properly // in the grammar... do it here... // disallow non-aggregated condition parents... if (!(n instanceof AggregateConditionNode)) { String label = (n instanceof SimpleNode) ? ((SimpleNode)n).expName() : String.valueOf(n); throw new ExpressionException(expName() + ": invalid parent - " + label); } super.jjtSetParent(n); }
public void jjtAddChild(Node n, int i) { // this is a check that we can't handle properly // in the grammar... do it here... // only allow conditional nodes...no scalars if (!(n instanceof ConditionNode) && !(n instanceof AggregateConditionNode)) { String label = (n instanceof SimpleNode) ? ((SimpleNode) n).expName() : String.valueOf(n); throw new ExpressionException(expName() + ": invalid child - " + label); } super.jjtAddChild(n, i); } }
public void jjtSetParent(Node n) { // this is a check that we can't handle properly // in the grammar... do it here... // disallow non-aggregated condition parents... if (!(n instanceof AggregateConditionNode)) { String label = (n instanceof SimpleNode) ? ((SimpleNode) n).expName() : String.valueOf(n); throw new ExpressionException(expName() + ": invalid parent - " + label); } super.jjtSetParent(n); }
@Override public Object evaluate(Object o) { // wrap in try/catch to provide unified exception processing try { return evaluateNode(o); } catch (Throwable th) { String string = this.toString(); throw new ExpressionException("Error evaluating expression '%s'", string, Util.unwindException(th), string); } }
@Override public Iterator<CayenneMapEntry> resolvePathComponents(Expression pathExp) throws ExpressionException { if (pathExp.getType() != Expression.DB_PATH) { throw new ExpressionException("Invalid expression type: '" + pathExp.expName() + "', DB_PATH is expected."); } return new PathIterator((String) pathExp.getOperand(0)); }
public Iterator resolvePathComponents(Expression pathExp) throws ExpressionException { if (pathExp.getType() != Expression.DB_PATH) { throw new ExpressionException("Invalid expression type: '" + pathExp.expName() + "', DB_PATH is expected."); } return new PathIterator((String) pathExp.getOperand(0)); }
@Override public Iterator<CayenneMapEntry> resolvePathComponents(Expression pathExp) throws ExpressionException { // resolve DB_PATH if we can if (pathExp.getType() == Expression.DB_PATH) { if (getDbEntity() == null) { throw new ExpressionException("Can't resolve DB_PATH '" + pathExp + "', DbEntity is not set."); } return getDbEntity().resolvePathComponents(pathExp); } if (pathExp.getType() == Expression.OBJ_PATH) { return new PathIterator((String) pathExp.getOperand(0)); } throw new ExpressionException("Invalid expression type: '" + pathExp.expName() + "', OBJ_PATH is expected."); }