Browse Source

TypedValue.NULL_TYPED_VALUE -> TypedValue.NULL

pull/23217/head
Juergen Hoeller 15 years ago
parent
commit
2ec39f5000
  1. 12
      org.springframework.expression/src/main/java/org/springframework/expression/TypedValue.java
  2. 2
      org.springframework.expression/src/main/java/org/springframework/expression/spel/ExpressionState.java
  3. 2
      org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/MethodReference.java
  4. 2
      org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/NullLiteral.java
  5. 2
      org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OpAnd.java
  6. 2
      org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OpOr.java
  7. 2
      org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorNot.java
  8. 2
      org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Projection.java
  9. 2
      org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/PropertyOrFieldReference.java
  10. 4
      org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Selection.java
  11. 2
      org.springframework.expression/src/main/java/org/springframework/expression/spel/standard/SpelExpression.java
  12. 2
      org.springframework.expression/src/main/java/org/springframework/expression/spel/support/StandardEvaluationContext.java
  13. 10
      org.springframework.expression/src/test/java/org/springframework/expression/spel/ExpressionStateTests.java

12
org.springframework.expression/src/main/java/org/springframework/expression/TypedValue.java

@ -28,13 +28,13 @@ import org.springframework.core.convert.TypeDescriptor; @@ -28,13 +28,13 @@ import org.springframework.core.convert.TypeDescriptor;
*/
public class TypedValue {
public static final TypedValue NULL_TYPED_VALUE = new TypedValue(null, TypeDescriptor.NULL);
public static final TypedValue NULL = new TypedValue(null, TypeDescriptor.NULL);
private final Object value;
private TypeDescriptor typeDescriptor;
/**
* Create a TypedValue for a simple object. The type descriptor is inferred
@ -43,9 +43,9 @@ public class TypedValue { @@ -43,9 +43,9 @@ public class TypedValue {
*/
public TypedValue(Object value) {
this.value = value;
this.typeDescriptor = null;// initialized when/if requested
this.typeDescriptor = null; // initialized when/if requested
}
/**
* Create a TypedValue for a particular value with a particular type descriptor.
* @param value the object value
@ -62,8 +62,8 @@ public class TypedValue { @@ -62,8 +62,8 @@ public class TypedValue {
}
public TypeDescriptor getTypeDescriptor() {
if (this.typeDescriptor==null) {
this.typeDescriptor = TypeDescriptor.forObject(value);
if (this.typeDescriptor == null) {
this.typeDescriptor = TypeDescriptor.forObject(this.value);
}
return this.typeDescriptor;
}

2
org.springframework.expression/src/main/java/org/springframework/expression/spel/ExpressionState.java

@ -121,7 +121,7 @@ public class ExpressionState { @@ -121,7 +121,7 @@ public class ExpressionState {
public TypedValue lookupVariable(String name) {
Object value = this.relatedContext.lookupVariable(name);
if (value == null) {
return TypedValue.NULL_TYPED_VALUE;
return TypedValue.NULL;
}
else {
return new TypedValue(value, TypeDescriptor.forObject(value));

2
org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/MethodReference.java

@ -63,7 +63,7 @@ public class MethodReference extends SpelNodeImpl { @@ -63,7 +63,7 @@ public class MethodReference extends SpelNodeImpl {
}
if (currentContext.getValue() == null) {
if (nullSafe) {
return TypedValue.NULL_TYPED_VALUE;
return TypedValue.NULL;
} else {
throw new SpelEvaluationException(getStartPosition(), SpelMessage.METHOD_CALL_ON_NULL_OBJECT_NOT_ALLOWED,
FormatHelper.formatMethodForMessage(name, getTypes(arguments)));

2
org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/NullLiteral.java

@ -30,7 +30,7 @@ public class NullLiteral extends Literal { @@ -30,7 +30,7 @@ public class NullLiteral extends Literal {
@Override
public TypedValue getLiteralValue() {
return TypedValue.NULL_TYPED_VALUE;
return TypedValue.NULL;
}
@Override

2
org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OpAnd.java

@ -70,7 +70,7 @@ public class OpAnd extends Operator { @@ -70,7 +70,7 @@ public class OpAnd extends Operator {
}
private void assertTypedValueNotNull(TypedValue typedValue) {
if (TypedValue.NULL_TYPED_VALUE.equals(typedValue)) {
if (TypedValue.NULL.equals(typedValue)) {
throw new SpelEvaluationException(SpelMessage.TYPE_CONVERSION_ERROR, "null", "boolean");
}
}

2
org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OpOr.java

@ -69,7 +69,7 @@ public class OpOr extends Operator { @@ -69,7 +69,7 @@ public class OpOr extends Operator {
}
private void assertTypedValueNotNull(TypedValue typedValue) {
if (TypedValue.NULL_TYPED_VALUE.equals(typedValue)) {
if (TypedValue.NULL.equals(typedValue)) {
throw new SpelEvaluationException(SpelMessage.TYPE_CONVERSION_ERROR, "null", "boolean");
}
}

2
org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/OperatorNot.java

@ -41,7 +41,7 @@ public class OperatorNot extends SpelNodeImpl { // Not is a unary operator so do @@ -41,7 +41,7 @@ public class OperatorNot extends SpelNodeImpl { // Not is a unary operator so do
public BooleanTypedValue getValueInternal(ExpressionState state) throws EvaluationException {
try {
TypedValue typedValue = children[0].getValueInternal(state);
if (TypedValue.NULL_TYPED_VALUE.equals(typedValue)) {
if (TypedValue.NULL.equals(typedValue)) {
throw new SpelEvaluationException(SpelMessage.TYPE_CONVERSION_ERROR, "null", "boolean");
}
boolean value = (Boolean) state.convertValue(typedValue, TypeDescriptor.valueOf(Boolean.class));

2
org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Projection.java

@ -109,7 +109,7 @@ public class Projection extends SpelNodeImpl { @@ -109,7 +109,7 @@ public class Projection extends SpelNodeImpl {
} else {
if (operand==null) {
if (nullSafe) {
return TypedValue.NULL_TYPED_VALUE;
return TypedValue.NULL;
} else {
throw new SpelEvaluationException(getStartPosition(),SpelMessage.PROJECTION_NOT_SUPPORTED_ON_TYPE, "null");
}

2
org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/PropertyOrFieldReference.java

@ -136,7 +136,7 @@ public class PropertyOrFieldReference extends SpelNodeImpl { @@ -136,7 +136,7 @@ public class PropertyOrFieldReference extends SpelNodeImpl {
Object targetObject = contextObject.getValue();
if (targetObject == null && nullSafe) {
return TypedValue.NULL_TYPED_VALUE;
return TypedValue.NULL;
}
PropertyAccessor accessorToUse = this.cachedReadAccessor;

4
org.springframework.expression/src/main/java/org/springframework/expression/spel/ast/Selection.java

@ -133,7 +133,7 @@ public class Selection extends SpelNodeImpl { @@ -133,7 +133,7 @@ public class Selection extends SpelNodeImpl {
}
}
if ((variant == FIRST || variant == LAST) && result.size() == 0) {
return TypedValue.NULL_TYPED_VALUE;
return TypedValue.NULL;
}
if (variant == LAST) {
return new TypedValue(result.get(result.size() - 1),TypeDescriptor.valueOf(op.getTypeDescriptor().getElementType()));
@ -150,7 +150,7 @@ public class Selection extends SpelNodeImpl { @@ -150,7 +150,7 @@ public class Selection extends SpelNodeImpl {
} else {
if (operand==null) {
if (nullSafe) {
return TypedValue.NULL_TYPED_VALUE;
return TypedValue.NULL;
} else {
throw new SpelEvaluationException(getStartPosition(), SpelMessage.INVALID_TYPE_FOR_SELECTION,
"null");

2
org.springframework.expression/src/main/java/org/springframework/expression/spel/standard/SpelExpression.java

@ -235,7 +235,7 @@ public class SpelExpression implements Expression { @@ -235,7 +235,7 @@ public class SpelExpression implements Expression {
private TypedValue toTypedValue(Object object) {
if (object == null) {
return TypedValue.NULL_TYPED_VALUE;
return TypedValue.NULL;
}
else {
return new TypedValue(object);

2
org.springframework.expression/src/main/java/org/springframework/expression/spel/support/StandardEvaluationContext.java

@ -76,7 +76,7 @@ public class StandardEvaluationContext implements EvaluationContext { @@ -76,7 +76,7 @@ public class StandardEvaluationContext implements EvaluationContext {
public void setRootObject(Object rootObject) {
if (this.rootObject == null) {
this.rootObject = TypedValue.NULL_TYPED_VALUE;
this.rootObject = TypedValue.NULL;
} else {
this.rootObject = new TypedValue(rootObject);//, TypeDescriptor.forObject(rootObject));
}

10
org.springframework.expression/src/test/java/org/springframework/expression/spel/ExpressionStateTests.java

@ -68,7 +68,7 @@ public class ExpressionStateTests extends ExpressionTestCase { @@ -68,7 +68,7 @@ public class ExpressionStateTests extends ExpressionTestCase {
public void testVariables() {
ExpressionState state = getState();
TypedValue typedValue = state.lookupVariable("foo");
Assert.assertEquals(TypedValue.NULL_TYPED_VALUE,typedValue);
Assert.assertEquals(TypedValue.NULL,typedValue);
state.setVariable("foo",34);
typedValue = state.lookupVariable("foo");
@ -85,11 +85,11 @@ public class ExpressionStateTests extends ExpressionTestCase { @@ -85,11 +85,11 @@ public class ExpressionStateTests extends ExpressionTestCase {
public void testNoVariableInteference() {
ExpressionState state = getState();
TypedValue typedValue = state.lookupVariable("foo");
Assert.assertEquals(TypedValue.NULL_TYPED_VALUE,typedValue);
Assert.assertEquals(TypedValue.NULL,typedValue);
state.setLocalVariable("foo",34);
typedValue = state.lookupVariable("foo");
Assert.assertEquals(TypedValue.NULL_TYPED_VALUE,typedValue);
Assert.assertEquals(TypedValue.NULL,typedValue);
state.setVariable("goo","hello");
Assert.assertNull(state.lookupLocalVariable("goo"));
@ -124,7 +124,7 @@ public class ExpressionStateTests extends ExpressionTestCase { @@ -124,7 +124,7 @@ public class ExpressionStateTests extends ExpressionTestCase {
// Assert.assertEquals(null, state.getRootContextObject().getValue());
state = new ExpressionState(new StandardEvaluationContext());
Assert.assertEquals(TypedValue.NULL_TYPED_VALUE,state.getRootContextObject());
Assert.assertEquals(TypedValue.NULL,state.getRootContextObject());
((StandardEvaluationContext)state.getEvaluationContext()).setRootObject(null,TypeDescriptor.NULL);
@ -156,7 +156,7 @@ public class ExpressionStateTests extends ExpressionTestCase { @@ -156,7 +156,7 @@ public class ExpressionStateTests extends ExpressionTestCase {
Assert.assertEquals(state.getRootContextObject().getValue(),state.getActiveContextObject().getValue());
state = new ExpressionState(new StandardEvaluationContext());
Assert.assertEquals(TypedValue.NULL_TYPED_VALUE,state.getActiveContextObject());
Assert.assertEquals(TypedValue.NULL,state.getActiveContextObject());
}
@Test

Loading…
Cancel
Save