1 19 20 package org.apache.cayenne.exp.parser; 21 22 import org.apache.cayenne.exp.Expression; 23 import org.apache.cayenne.exp.ExpressionException; 24 import org.apache.cayenne.exp.ExpressionParameter; 25 26 32 public class ASTNamedParameter extends ASTScalar { 33 ASTNamedParameter(int id) { 34 super(id); 35 } 36 37 public ASTNamedParameter() { 38 super(ExpressionParserTreeConstants.JJTNAMEDPARAMETER); 39 } 40 41 public ASTNamedParameter(Object value) { 42 super(ExpressionParserTreeConstants.JJTNAMEDPARAMETER); 43 setValue(value); 44 } 45 46 protected Object evaluateNode(Object o) throws Exception { 47 throw new ExpressionException( 48 "Uninitialized parameter: " + value + ", call 'expWithParameters' first."); 49 } 50 51 54 public Expression shallowCopy() { 55 ASTNamedParameter copy = new ASTNamedParameter(id); 56 copy.value = value; 57 return copy; 58 } 59 60 public void setValue(Object value) { 61 if (value == null) { 62 throw new ExpressionException("Null Parameter value"); 63 } 64 65 String name = value.toString().trim(); 66 if (name.length() == 0) { 67 throw new ExpressionException("Empty Parameter value"); 68 } 69 70 super.setValue(new ExpressionParameter(name)); 71 } 72 } 73 | Popular Tags |