Browse Source
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@925 50f2f4bb-b051-0410-bef5-90022cba6387pull/1/head
66 changed files with 749 additions and 382 deletions
@ -0,0 +1,61 @@
@@ -0,0 +1,61 @@
|
||||
/* |
||||
* Copyright 2002-2009 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.springframework.expression; |
||||
|
||||
import org.springframework.core.convert.TypeDescriptor; |
||||
|
||||
/** |
||||
* Encapsulates an object and a type descriptor that describes it. |
||||
* The type descriptor can hold generic information that would |
||||
* not be accessible through a simple getClass() call on the object. |
||||
* |
||||
* @author Andy Clement |
||||
* @since 3.0 |
||||
*/ |
||||
public class TypedValue { |
||||
|
||||
private Object value; |
||||
private TypeDescriptor typeDescriptor; |
||||
|
||||
/** |
||||
* Create a TypedValue for a simple object. The type descriptor is inferred |
||||
* from the object, so no generic information is preserved. |
||||
* @param value the object value |
||||
*/ |
||||
public TypedValue(Object value) { |
||||
this.value = value; |
||||
this.typeDescriptor = TypeDescriptor.forObject(value); |
||||
} |
||||
|
||||
/** |
||||
* Create a TypedValue for a particular value with a particular type descriptor. |
||||
* @param value the object value |
||||
* @param typeDescriptor a type descriptor describing the type of the value |
||||
*/ |
||||
public TypedValue(Object value, TypeDescriptor typeDescriptor) { |
||||
this.value = value; |
||||
this.typeDescriptor = typeDescriptor; |
||||
} |
||||
|
||||
public Object getValue() { |
||||
return this.value; |
||||
} |
||||
|
||||
public TypeDescriptor getTypeDescriptor() { |
||||
return this.typeDescriptor; |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,38 @@
@@ -0,0 +1,38 @@
|
||||
/* |
||||
* Copyright 2002-2009 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.springframework.expression.spel.ast; |
||||
|
||||
import org.springframework.core.convert.TypeDescriptor; |
||||
|
||||
/** |
||||
* @author Andy Clement |
||||
* @since 3.0 |
||||
*/ |
||||
public interface CommonTypeDescriptors { |
||||
// TODO push into TypeDescriptor?
|
||||
static TypeDescriptor BOOLEAN_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Boolean.class); |
||||
static TypeDescriptor INTEGER_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Integer.class); |
||||
static TypeDescriptor CHARACTER_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Character.class); |
||||
static TypeDescriptor LONG_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Long.class); |
||||
static TypeDescriptor SHORT_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Short.class); |
||||
static TypeDescriptor BYTE_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Byte.class); |
||||
static TypeDescriptor FLOAT_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Float.class); |
||||
static TypeDescriptor DOUBLE_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Double.class); |
||||
static TypeDescriptor STRING_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(String.class); |
||||
static TypeDescriptor CLASS_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Class.class); |
||||
static TypeDescriptor OBJECT_TYPE_DESCRIPTOR = TypeDescriptor.valueOf(Object.class); |
||||
|
||||
} |
||||
@ -0,0 +1,41 @@
@@ -0,0 +1,41 @@
|
||||
/* |
||||
* Copyright 2002-2009 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.springframework.expression.spel.support; |
||||
|
||||
import org.springframework.expression.TypedValue; |
||||
import org.springframework.expression.spel.ast.SpelNodeImpl; |
||||
|
||||
/** |
||||
* @author Andy Clement |
||||
* @since 3.0 |
||||
*/ |
||||
public class BooleanTypedValue extends TypedValue { |
||||
|
||||
public static final BooleanTypedValue True = new BooleanTypedValue(true); |
||||
public static final BooleanTypedValue False = new BooleanTypedValue(false); |
||||
|
||||
private BooleanTypedValue(boolean b) { |
||||
super(b,SpelNodeImpl.BOOLEAN_TYPE_DESCRIPTOR); |
||||
} |
||||
|
||||
public static BooleanTypedValue forValue(boolean b) { |
||||
if (b) { |
||||
return True; |
||||
} else { |
||||
return False; |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue