Java Code Examples for org.springframework.expression.TypeConverter#convertValue()
The following examples show how to use
org.springframework.expression.TypeConverter#convertValue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Indexer.java From spring-analysis-note with MIT License | 5 votes |
@SuppressWarnings("unchecked") private <T> T convertValue(TypeConverter converter, @Nullable Object value, Class<T> targetType) { T result = (T) converter.convertValue( value, TypeDescriptor.forObject(value), TypeDescriptor.valueOf(targetType)); if (result == null) { throw new IllegalStateException("Null conversion result for index [" + value + "]"); } return result; }
Example 2
Source File: ConstructorReference.java From spring-analysis-note with MIT License | 5 votes |
private void populateReferenceTypeArray(ExpressionState state, Object newArray, TypeConverter typeConverter, InlineList initializer, Class<?> componentType) { TypeDescriptor toTypeDescriptor = TypeDescriptor.valueOf(componentType); Object[] newObjectArray = (Object[]) newArray; for (int i = 0; i < newObjectArray.length; i++) { SpelNode elementNode = initializer.getChild(i); Object arrayEntry = elementNode.getValue(state); newObjectArray[i] = typeConverter.convertValue(arrayEntry, TypeDescriptor.forObject(arrayEntry), toTypeDescriptor); } }
Example 3
Source File: ConstructorReference.java From spring4-understanding with Apache License 2.0 | 5 votes |
private void populateReferenceTypeArray(ExpressionState state, Object newArray, TypeConverter typeConverter, InlineList initializer, Class<?> componentType) { TypeDescriptor toTypeDescriptor = TypeDescriptor.valueOf(componentType); Object[] newObjectArray = (Object[]) newArray; for (int i = 0; i < newObjectArray.length; i++) { SpelNode elementNode = initializer.getChild(i); Object arrayEntry = elementNode.getValue(state); newObjectArray[i] = typeConverter.convertValue(arrayEntry, TypeDescriptor.forObject(arrayEntry), toTypeDescriptor); } }
Example 4
Source File: ConstructorReference.java From java-technology-stack with MIT License | 5 votes |
private void populateReferenceTypeArray(ExpressionState state, Object newArray, TypeConverter typeConverter, InlineList initializer, Class<?> componentType) { TypeDescriptor toTypeDescriptor = TypeDescriptor.valueOf(componentType); Object[] newObjectArray = (Object[]) newArray; for (int i = 0; i < newObjectArray.length; i++) { SpelNode elementNode = initializer.getChild(i); Object arrayEntry = elementNode.getValue(state); newObjectArray[i] = typeConverter.convertValue(arrayEntry, TypeDescriptor.forObject(arrayEntry), toTypeDescriptor); } }
Example 5
Source File: Indexer.java From java-technology-stack with MIT License | 5 votes |
@SuppressWarnings("unchecked") private <T> T convertValue(TypeConverter converter, @Nullable Object value, Class<T> targetType) { T result = (T) converter.convertValue( value, TypeDescriptor.forObject(value), TypeDescriptor.valueOf(targetType)); if (result == null) { throw new IllegalStateException("Null conversion result for index [" + value + "]"); } return result; }
Example 6
Source File: ExpressionUtils.java From java-technology-stack with MIT License | 5 votes |
@SuppressWarnings("unchecked") private static <T> T convertValue(TypeConverter typeConverter, TypedValue typedValue, Class<T> targetType) { Object result = typeConverter.convertValue(typedValue.getValue(), typedValue.getTypeDescriptor(), TypeDescriptor.valueOf(targetType)); if (result == null) { throw new IllegalStateException("Null conversion result for value [" + typedValue.getValue() + "]"); } return (T) result; }
Example 7
Source File: ConstructorReference.java From lams with GNU General Public License v2.0 | 5 votes |
private void populateReferenceTypeArray(ExpressionState state, Object newArray, TypeConverter typeConverter, InlineList initializer, Class<?> componentType) { TypeDescriptor toTypeDescriptor = TypeDescriptor.valueOf(componentType); Object[] newObjectArray = (Object[]) newArray; for (int i = 0; i < newObjectArray.length; i++) { SpelNode elementNode = initializer.getChild(i); Object arrayEntry = elementNode.getValue(state); newObjectArray[i] = typeConverter.convertValue(arrayEntry, TypeDescriptor.forObject(arrayEntry), toTypeDescriptor); } }
Example 8
Source File: ExpressionUtils.java From spring4-understanding with Apache License 2.0 | 4 votes |
/** * Attempt to convert a typed value to a short using the supplied type converter. */ public static short toShort(TypeConverter typeConverter, TypedValue typedValue) { return (Short) typeConverter.convertValue(typedValue.getValue(), typedValue.getTypeDescriptor(), TypeDescriptor.valueOf(Short.class)); }
Example 9
Source File: ExpressionUtils.java From lams with GNU General Public License v2.0 | 4 votes |
/** * Attempt to convert a typed value to a byte using the supplied type converter. */ public static byte toByte(TypeConverter typeConverter, TypedValue typedValue) { return (Byte) typeConverter.convertValue(typedValue.getValue(), typedValue.getTypeDescriptor(), TypeDescriptor.valueOf(Byte.class)); }
Example 10
Source File: ExpressionUtils.java From lams with GNU General Public License v2.0 | 4 votes |
/** * Attempt to convert a typed value to a float using the supplied type converter. */ public static float toFloat(TypeConverter typeConverter, TypedValue typedValue) { return (Float) typeConverter.convertValue(typedValue.getValue(), typedValue.getTypeDescriptor(), TypeDescriptor.valueOf(Float.class)); }
Example 11
Source File: ExpressionUtils.java From lams with GNU General Public License v2.0 | 4 votes |
/** * Attempt to convert a typed value to a short using the supplied type converter. */ public static short toShort(TypeConverter typeConverter, TypedValue typedValue) { return (Short) typeConverter.convertValue(typedValue.getValue(), typedValue.getTypeDescriptor(), TypeDescriptor.valueOf(Short.class)); }
Example 12
Source File: ExpressionUtils.java From spring4-understanding with Apache License 2.0 | 4 votes |
/** * Attempt to convert a typed value to a byte using the supplied type converter. */ public static byte toByte(TypeConverter typeConverter, TypedValue typedValue) { return (Byte) typeConverter.convertValue(typedValue.getValue(), typedValue.getTypeDescriptor(), TypeDescriptor.valueOf(Byte.class)); }
Example 13
Source File: ExpressionUtils.java From lams with GNU General Public License v2.0 | 4 votes |
/** * Attempt to convert a typed value to a long using the supplied type converter. */ public static long toLong(TypeConverter typeConverter, TypedValue typedValue) { return (Long) typeConverter.convertValue(typedValue.getValue(), typedValue.getTypeDescriptor(), TypeDescriptor.valueOf(Long.class)); }
Example 14
Source File: ExpressionUtils.java From lams with GNU General Public License v2.0 | 4 votes |
/** * Attempt to convert a typed value to a double using the supplied type converter. */ public static double toDouble(TypeConverter typeConverter, TypedValue typedValue) { return (Double) typeConverter.convertValue(typedValue.getValue(), typedValue.getTypeDescriptor(), TypeDescriptor.valueOf(Double.class)); }
Example 15
Source File: ExpressionUtils.java From spring4-understanding with Apache License 2.0 | 4 votes |
/** * Attempt to convert a typed value to a char using the supplied type converter. */ public static char toChar(TypeConverter typeConverter, TypedValue typedValue) { return (Character) typeConverter.convertValue(typedValue.getValue(), typedValue.getTypeDescriptor(), TypeDescriptor.valueOf(Character.class)); }
Example 16
Source File: ExpressionUtils.java From lams with GNU General Public License v2.0 | 4 votes |
/** * Attempt to convert a typed value to an int using the supplied type converter. */ public static int toInt(TypeConverter typeConverter, TypedValue typedValue) { return (Integer) typeConverter.convertValue(typedValue.getValue(), typedValue.getTypeDescriptor(), TypeDescriptor.valueOf(Integer.class)); }
Example 17
Source File: ExpressionUtils.java From spring4-understanding with Apache License 2.0 | 4 votes |
/** * Attempt to convert a typed value to a double using the supplied type converter. */ public static double toDouble(TypeConverter typeConverter, TypedValue typedValue) { return (Double) typeConverter.convertValue(typedValue.getValue(), typedValue.getTypeDescriptor(), TypeDescriptor.valueOf(Double.class)); }
Example 18
Source File: ExpressionUtils.java From spring4-understanding with Apache License 2.0 | 4 votes |
/** * Attempt to convert a typed value to a long using the supplied type converter. */ public static long toLong(TypeConverter typeConverter, TypedValue typedValue) { return (Long) typeConverter.convertValue(typedValue.getValue(), typedValue.getTypeDescriptor(), TypeDescriptor.valueOf(Long.class)); }
Example 19
Source File: StandardComponentsTests.java From spring-analysis-note with MIT License | 4 votes |
@Test public void testStandardTypeConverter() throws EvaluationException { TypeConverter tc = new StandardTypeConverter(); tc.convertValue(3, TypeDescriptor.forObject(3), TypeDescriptor.valueOf(Double.class)); }
Example 20
Source File: ExpressionUtils.java From spring4-understanding with Apache License 2.0 | 4 votes |
/** * Attempt to convert a typed value to a boolean using the supplied type converter. */ public static boolean toBoolean(TypeConverter typeConverter, TypedValue typedValue) { return (Boolean) typeConverter.convertValue(typedValue.getValue(), typedValue.getTypeDescriptor(), TypeDescriptor.valueOf(Boolean.class)); }