void onFinish() { if (i < parameters.length) { throw new ExpressionException("Too many parameters to bind expression. Expected: " + i + ", actual: " + parameters.length); } }
private String buildValidationMessage(ExpressionException e, String prefix) { StringBuffer buffer = new StringBuffer(prefix); if (e.getExpressionString() != null) { buffer.append(": '").append(e.getExpressionString()).append("'"); } buffer.append("."); return buffer.toString(); }
throw new ValidationException(eex.getUnlabeledMessage());
value1 = exp.evaluate(o1); } catch (ExpressionException e) { if (pathExceptionSuppressed && e.getCause() instanceof org.apache.cayenne.reflect.UnresolvablePathException) { value2 = exp.evaluate(o2); } catch (ExpressionException e) { if (pathExceptionSuppressed && e.getCause() instanceof org.apache.cayenne.reflect.UnresolvablePathException) {
@Override protected Object evaluateNode(Object o) throws Exception { throw new ExpressionException("Uninitialized parameter: " + value + ", call 'expWithParameters' first."); }
"ObjAttribute '%s' has invalid DB path: %s", attribute.getName(), e.getExpressionString()); return;
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); }
/** * Creates a new expression for the type requested. If type is unknown, * ExpressionException is thrown. */ public static Expression expressionOfType(int type) { if (type < 0 || type >= typeLookup.length) { throw new ExpressionException("Bad expression type: " + type); } if (typeLookup[type] == null) { throw new ExpressionException("Bad expression type: " + type); } // expected this if (SimpleNode.class.isAssignableFrom(typeLookup[type])) { try { return (Expression) typeLookup[type].newInstance(); } catch (Exception ex) { throw new ExpressionException("Error creating expression", ex); } } throw new ExpressionException("Bad expression type: " + type); }
/** * Creates a new expression for the type requested. If type is unknown, * ExpressionException is thrown. */ public static Expression expressionOfType(int type) { if (type < 0 || type >= typeLookup.length) { throw new ExpressionException("Bad expression type: " + type); } if (typeLookup[type] == null) { throw new ExpressionException("Bad expression type: " + type); } // expected this if (SimpleNode.class.isAssignableFrom(typeLookup[type])) { try { return (Expression) typeLookup[type].newInstance(); } catch (Exception ex) { throw new ExpressionException("Error creating expression", ex); } } throw new ExpressionException("Bad expression type: " + type); }
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; }
/** * Creates a transformed copy of this expression, applying transformation * provided by Transformer to all its nodes. Null transformer will result in * an identical deep copy of this expression. * <p> * To force a node and its children to be pruned from the copy, Transformer * should return Expression.PRUNED_NODE. Otherwise an expectation is that if * a node is an Expression it must be transformed to null or another * Expression. Any other object type would result in a ExpressionException. * * @since 1.1 */ public Expression transform(Transformer transformer) { Object transformed = transformExpression(transformer); if (transformed == PRUNED_NODE || transformed == null) { return null; } else if (transformed instanceof Expression) { return (Expression) transformed; } throw new ExpressionException("Invalid transformed expression: " + transformed); }
/** * Creates a transformed copy of this expression, applying transformation provided by * Transformer to all its nodes. Null transformer will result in an identical deep * copy of this expression. * <p> * To force a node and its children to be pruned from the copy, Transformer should * return Expression.PRUNED_NODE. Otherwise an expectation is that if a node is an * Expression it must be transformed to null or another Expression. Any other object * type would result in a ExpressionException. * * @since 1.1 */ public Expression transform(Transformer transformer) { Object transformed = transformExpression(transformer); if (transformed == PRUNED_NODE || transformed == null) { return null; } else if (transformed instanceof Expression) { return (Expression) transformed; } throw new ExpressionException("Invalid transformed expression: " + transformed); }
private Object nextValue(String name) { if (seen == null) { seen = new HashMap<>(); } Object p; if (seen.containsKey(name)) { p = seen.get(name); } else { if (i >= parameters.length) { throw new ExpressionException("Too few parameters to bind expression: " + parameters.length); } p = parameters[i++]; seen.put(name, p); } // wrap lists (for now); also support null parameters // TODO: andrus 8/14/2007 - shouldn't we also wrap non-null // object values in ASTScalars? return (p != null) ? ExpressionFactory.wrapPathOperand(p) : new ASTScalar(null); }
/** * Parses string, converting it to Expression. If string does not represent a * semantically correct expression, an ExpressionException is thrown. * * @since 1.1 */ // TODO: cache expression strings, since this operation is pretty slow public static Expression fromString(String expressionString) { if (expressionString == null) { throw new NullPointerException("Null expression string."); } Reader reader = new StringReader(expressionString); try { return new ExpressionParser(reader).expression(); } catch (ParseException ex) { throw new ExpressionException(ex.getMessage(), ex); } catch (Throwable th) { // another common error is TokenManagerError throw new ExpressionException(th.getMessage(), th); } }