public TypedValue lookupVariable(String name) { Object value = this.relatedContext.lookupVariable(name); return (value != null ? new TypedValue(value) : TypedValue.NULL); }
public Class<?> findType(String type) throws EvaluationException { return this.relatedContext.getTypeLocator().findType(type); }
/** * Specify a default root object to resolve against. * <p>Default is none, expecting an object argument at evaluation time. * @see org.springframework.expression.Expression#getValue(EvaluationContext) * @see org.springframework.expression.Expression#getValue(EvaluationContext, Object) */ public Builder withRootObject(Object rootObject) { this.rootObject = new TypedValue(rootObject); return this; }
@Test(expected = EvaluationException.class) public void testAndWithNullValueOnLeft() { parser.parseExpression("null and true").getValue(); }
/** * Set the expression to evaluate. */ public void setExpression(String expression) { this.expression = this.expressionParser.parseExpression(expression); }
@Nullable public Object convertValue(TypedValue value, TypeDescriptor targetTypeDescriptor) throws EvaluationException { Object val = value.getValue(); return this.relatedContext.getTypeConverter().convertValue( val, TypeDescriptor.forObject(val), targetTypeDescriptor); }
@Override public String toString() { return "TypedValue: '" + this.value + "' of [" + getTypeDescriptor() + "]"; }
/** * Return the exception message. * As of Spring 4.0, this method returns the same result as {@link #toDetailedString()}. * @see #getSimpleMessage() * @see java.lang.Throwable#getMessage() */ @Override public String getMessage() { return toDetailedString(); }
@Test(expected = EvaluationException.class) public void testOrWithNullValueOnLeft() { parser.parseExpression("null or false").getValue(); }
public IntLiteral(String payload, int startPos, int endPos, int value) { super(payload, startPos, endPos); this.value = new TypedValue(value); this.exitTypeDescriptor = "I"; }
@Test(expected = EvaluationException.class) public void testTernaryOperatorWithNullValue() { parser.parseExpression("null ? 0 : 1").getValue(); }
public RealLiteral(String payload, int startPos, int endPos, double value) { super(payload, startPos, endPos); this.value = new TypedValue(value); this.exitTypeDescriptor = "D"; }
@Test(expected = EvaluationException.class) public void testOrWithNullValueOnRight() { parser.parseExpression("false or null").getValue(); }
public FloatLiteral(String payload, int startPos, int endPos, float value) { super(payload, startPos, endPos); this.value = new TypedValue(value); this.exitTypeDescriptor = "F"; }
@Test(expected = EvaluationException.class) public void testAndWithNullValueOnRight() { parser.parseExpression("true and null").getValue(); }
/** * Specify a typed root object to resolve against. * <p>Default is none, expecting an object argument at evaluation time. * @see org.springframework.expression.Expression#getValue(EvaluationContext) * @see org.springframework.expression.Expression#getValue(EvaluationContext, Object) */ public Builder withTypedRootObject(Object rootObject, TypeDescriptor typeDescriptor) { this.rootObject = new TypedValue(rootObject, typeDescriptor); return this; }
public LongLiteral(String payload, int startPos, int endPos, long value) { super(payload, startPos, endPos); this.value = new TypedValue(value); this.exitTypeDescriptor = "J"; }
/** * Create a {@code StandardEvaluationContext} with the given root object. * @param rootObject the root object to use * @see #setRootObject */ public StandardEvaluationContext(Object rootObject) { this.rootObject = new TypedValue(rootObject); }
public Identifier(String payload, int startPos, int endPos) { super(startPos, endPos); this.id = new TypedValue(payload); }
@Override public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException { return new TypedValue(activePerson); }