/** * Wrap value into ASTScalar * @since 4.0 */ static Expression wrapScalarValue(Object value) { return new ASTScalar(value); }
protected Object unwrapChild(Node child) { return (child instanceof ASTScalar) ? ((ASTScalar) child).getValue() : child; }
public ASTScalar(Object value) { super(ExpressionParserTreeConstants.JJTSCALAR); setValue(value); }
case SINGLE_QUOTED_STRING: jj_consume_token(SINGLE_QUOTED_STRING); ASTScalar jjtn001 = new ASTScalar(JJTSCALAR); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); jjtree.closeNodeScope(jjtn001, 0); jjtc001 = false; jjtn001.setValue(token_source.literalValue); } finally { if (jjtc001) { case DOUBLE_QUOTED_STRING: jj_consume_token(DOUBLE_QUOTED_STRING); ASTScalar jjtn002 = new ASTScalar(JJTSCALAR); boolean jjtc002 = true; jjtree.openNodeScope(jjtn002); jjtree.closeNodeScope(jjtn002, 0); jjtc002 = false; jjtn002.setValue(token_source.literalValue); } finally { if (jjtc002) { case INT_LITERAL: jj_consume_token(INT_LITERAL); ASTScalar jjtn003 = new ASTScalar(JJTSCALAR); boolean jjtc003 = true; jjtree.openNodeScope(jjtn003);
/** * @since 4.0 */ @Override public void appendAsEJBQL(List<Object> parameterAccumulator, Appendable out, String rootId) throws IOException { if (value != null) { String valueString = value.toString(); if (valueString.length() > 1 && valueString.charAt(0) == '$') { out.append(':'); out.append(valueString.substring(1)); return; } } super.appendAsEJBQL(parameterAccumulator, out, rootId); } }
case SINGLE_QUOTED_STRING: jj_consume_token(SINGLE_QUOTED_STRING); ASTScalar jjtn001 = new ASTScalar(JJTSCALAR); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); jjtree.closeNodeScope(jjtn001, 0); jjtc001 = false; jjtn001.setValue(token_source.literalValue); } finally { if (jjtc001) { case DOUBLE_QUOTED_STRING: jj_consume_token(DOUBLE_QUOTED_STRING); ASTScalar jjtn002 = new ASTScalar(JJTSCALAR); boolean jjtc002 = true; jjtree.openNodeScope(jjtn002); jjtree.closeNodeScope(jjtn002, 0); jjtc002 = false; jjtn002.setValue(token_source.literalValue); } finally { if (jjtc002) {
/** * Creates a copy of this expression node, without copying children. */ @Override public Expression shallowCopy() { ASTScalar copy = new ASTScalar(id); copy.value = value; return copy; }
case SINGLE_QUOTED_STRING: jj_consume_token(SINGLE_QUOTED_STRING); ASTScalar jjtn001 = new ASTScalar(JJTSCALAR); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); jjtree.closeNodeScope(jjtn001, 0); jjtc001 = false; jjtn001.setValue(token_source.literalValue); } finally { if (jjtc001) { case DOUBLE_QUOTED_STRING: jj_consume_token(DOUBLE_QUOTED_STRING); ASTScalar jjtn002 = new ASTScalar(JJTSCALAR); boolean jjtc002 = true; jjtree.openNodeScope(jjtn002); jjtree.closeNodeScope(jjtn002, 0); jjtc002 = false; jjtn002.setValue(token_source.literalValue); } finally { if (jjtc002) { case INT_LITERAL: jj_consume_token(INT_LITERAL); ASTScalar jjtn003 = new ASTScalar(JJTSCALAR); boolean jjtc003 = true; jjtree.openNodeScope(jjtn003);
protected Object unwrapChild(Node child) { return (child instanceof ASTScalar) ? ((ASTScalar) child).getValue() : child; }
public ASTScalar(Object value) { super(ExpressionParserTreeConstants.JJTSCALAR); setValue(value); }
/** * Creates a copy of this expression node, without copying children. */ public Expression shallowCopy() { ASTScalar copy = new ASTScalar(id); copy.value = value; return copy; }
case SINGLE_QUOTED_STRING: jj_consume_token(SINGLE_QUOTED_STRING); ASTScalar jjtn001 = new ASTScalar(JJTSCALAR); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); jjtree.closeNodeScope(jjtn001, 0); jjtc001 = false; jjtn001.setValue(token_source.literalValue); } finally { if (jjtc001) { case DOUBLE_QUOTED_STRING: jj_consume_token(DOUBLE_QUOTED_STRING); ASTScalar jjtn002 = new ASTScalar(JJTSCALAR); boolean jjtc002 = true; jjtree.openNodeScope(jjtn002); jjtree.closeNodeScope(jjtn002, 0); jjtc002 = false; jjtn002.setValue(token_source.literalValue); } finally { if (jjtc002) { ASTScalar jjtn003 = new ASTScalar(JJTSCALAR); boolean jjtc003 = true; jjtree.openNodeScope(jjtn003);
@Override protected String getEJBQLExpressionOperator(int index) { if (jjtGetChild(1) instanceof ASTScalar && ((ASTScalar) jjtGetChild(1)).getValue() == null) { //for ejbql, we need "is not null" instead of "!= null" return "is not"; } return "<>"; }
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)); } }
protected Node wrapChild(Object child) { // when child is null, there's no way of telling whether this is a scalar or not... fuzzy... // maybe we should stop using this method - it is too generic return (child instanceof Node || child == null) ? (Node) child : new ASTScalar(child); }
case TRUE: jj_consume_token(TRUE); ASTScalar jjtn001 = new ASTScalar(JJTSCALAR); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); jjtree.closeNodeScope(jjtn001, 0); jjtc001 = false; jjtn001.setValue(true); } finally { if (jjtc001) { case FALSE: jj_consume_token(FALSE); ASTScalar jjtn002 = new ASTScalar(JJTSCALAR); boolean jjtc002 = true; jjtree.openNodeScope(jjtn002); jjtree.closeNodeScope(jjtn002, 0); jjtc002 = false; jjtn002.setValue(false); } finally { if (jjtc002) {
@Override protected void appendChildrenAsEJBQL(List<Object> parameterAccumulator, Appendable out, String rootId) throws IOException { // with like, first expression is always path, second is a literal, // which must be uppercased out.append("upper("); ((SimpleNode) children[0]).appendAsEJBQL(parameterAccumulator, out, rootId); out.append(") "); out.append(getEJBQLExpressionOperator(0)); out.append(" "); Object literal = ((ASTScalar) children[1]).getValue(); if (!(literal instanceof String)) { throw new ExpressionException("Literal value should be a string"); } SimpleNode.encodeScalarAsEJBQL(parameterAccumulator, out, ((String) literal).toUpperCase()); } }
@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)); }
protected Node wrapChild(Object child) { return (child instanceof Node || child == null) ? (Node) child : new ASTScalar(child); }
case INT_LITERAL: jj_consume_token(INT_LITERAL); ASTScalar jjtn001 = new ASTScalar(JJTSCALAR); boolean jjtc001 = true; jjtree.openNodeScope(jjtn001); jjtree.closeNodeScope(jjtn001, 0); jjtc001 = false; jjtn001.setValue(token_source.literalValue); } finally { if (jjtc001) { case FLOAT_LITERAL: jj_consume_token(FLOAT_LITERAL); ASTScalar jjtn002 = new ASTScalar(JJTSCALAR); boolean jjtc002 = true; jjtree.openNodeScope(jjtn002); jjtree.closeNodeScope(jjtn002, 0); jjtc002 = false; jjtn002.setValue(token_source.literalValue); } finally { if (jjtc002) {