1 56 package org.objectstyle.cayenne.exp.parser; 57 58 import org.objectstyle.cayenne.exp.Expression; 59 import org.objectstyle.cayenne.exp.ExpressionException; 60 import org.objectstyle.cayenne.exp.ExpressionParameter; 61 62 68 public class ASTNamedParameter extends ASTScalar { 69 ASTNamedParameter(int id) { 70 super(id); 71 } 72 73 public ASTNamedParameter() { 74 super(ExpressionParserTreeConstants.JJTNAMEDPARAMETER); 75 } 76 77 public ASTNamedParameter(Object value) { 78 super(ExpressionParserTreeConstants.JJTNAMEDPARAMETER); 79 setValue(value); 80 } 81 82 protected Object evaluateNode(Object o) throws Exception { 83 throw new ExpressionException( 84 "Uninitialized parameter: " + value + ", call 'expWithParameters' first."); 85 } 86 87 90 public Expression shallowCopy() { 91 ASTNamedParameter copy = new ASTNamedParameter(id); 92 copy.value = value; 93 return copy; 94 } 95 96 public void setValue(Object value) { 97 if (value == null) { 98 throw new ExpressionException("Null Parameter value"); 99 } 100 101 String name = value.toString().trim(); 102 if (name.length() == 0) { 103 throw new ExpressionException("Empty Parameter value"); 104 } 105 106 super.setValue(new ExpressionParameter(name)); 107 } 108 } 109 | Popular Tags |