public Object convertValue(Map context, Object target, Member member, String propertyName, Object value, Class toType) { return typeConverter.convertValue(context, target, member, propertyName, value, toType); } }
public static Object getConvertedType(OgnlContext context, Object target, Member member, String propertyName, Object value, Class type) { return context.getTypeConverter().convertValue(context, target, member, propertyName, value, type); }
public static Object getConvertedType(OgnlContext context, Object target, Member member, String propertyName, Object value, Class type) { return context.getTypeConverter().convertValue(context, target, member, propertyName, value, type); }
public static Object getConvertedType( OgnlContext context, Object target, Member member, String propertyName, Object value, Class type) { return context.getTypeConverter().convertValue(context, target, member, propertyName, value, type); }
public static <T> T convertValue(Object value, Class<T> toType) { OgnlContext ognlContext = ElementsThreadLocals.getOgnlContext(); TypeConverter typeConverter = ognlContext.getTypeConverter(); return (T) typeConverter.convertValue( ognlContext, null, null, null, value, toType); }
public static <T> T convertValue(Object value, Class<T> toType) { OgnlContext ognlContext = ElementsThreadLocals.getOgnlContext(); TypeConverter typeConverter = ognlContext.getTypeConverter(); return (T) typeConverter.convertValue( ognlContext, null, null, null, value, toType); }
@Override @SuppressWarnings({ "rawtypes" }) public Object convertValue(Map paramContext, Object target, Member member, String propertyName, Object fromValue, Class toType) { Object toValue; Class< ? > type = toType; if ( ( fromValue instanceof String ) && TypeConversion.supports(type)) { toValue = TypeConversion.parse(( String ) fromValue, type); } else { toValue = defaultTypeConverter.convertValue(paramContext, target, member, propertyName, fromValue, type); } return toValue; }
/** * Gets the value represented by the given pre-compiled expression on the specified root * object. * * @param expression * The pre-compiled expression, as found in {@link Node#getAccessor()}. * @param context * The ognl context. * @param root * The object to retrieve the expression value from. * @param resultType * The desired object type that the return value should be converted to using the {@link #getTypeConverter(java.util.Map)} }. * @return * The value. */ public static Object getValue(ExpressionAccessor expression, OgnlContext context, Object root, Class resultType) { return getTypeConverter(context).convertValue(context, root, null, null, expression.get(context, root), resultType); }
return conv.convertValue(context, target, member, propertyName, value, toType);
return conv.convertValue(context, target, member, propertyName, value, toType);
converter.convertValue(context, target, null, name.toString(), value, target.getClass().getComponentType()); if (isNumber)
/** * Gets the value represented by the given pre-compiled expression on the specified root * object. * * @param expression * The pre-compiled expression, as found in {@link Node#getAccessor()}. * @param context * The ognl context. * @param root * The object to retrieve the expression value from. * @param resultType * The desired object type that the return value should be converted to using the {@link #getTypeConverter(java.util.Map)} }. * @return * The value. */ public static Object getValue(ExpressionAccessor expression, OgnlContext context, Object root, Class resultType) { return getTypeConverter(context).convertValue(context, root, null, null, expression.get(context, root), resultType); }
Object convertedValue; convertedValue = converter.convertValue(context, target, null, name.toString(), value, target.getClass().getComponentType()); if (isNumber) { int i = ((Number)index).intValue();
converter.convertValue(context, target, null, name.toString(), value, target.getClass().getComponentType()); if (isNumber)
@Test @Ignore("Mocks with mockito don't work") public void settingShouldNullifyUpToIndexAndIgnoreRemoval() throws Exception { final Long[] l = new Long[] {}; when(context.getRoot()).thenReturn(instance); when(typeConverter.convertValue(anyMap(), any(), (Member) any(Member.class), anyString(), any(), any(Class.class))).thenReturn(22L); accessor.setProperty(context, l, 1, 22L); assertThat(instance.simpleNode[0], is(nullValue())); assertThat(instance.simpleNode[1], is(equalTo(22L))); }
/** * Evaluates the given OGNL expression tree to extract a value from the given root * object. The default context is set for the given context and root via * <CODE>addDefaultContext()</CODE>. * * @param tree the OGNL expression tree to evaluate, as returned by parseExpression() * @param context the naming context for the evaluation * @param root the root object for the OGNL expression * @param resultType the converted type of the resultant object, using the context's type converter * @return the result of evaluating the expression * @throws MethodFailedException if the expression called a method which failed * @throws NoSuchPropertyException if the expression referred to a nonexistent property * @throws InappropriateExpressionException if the expression can't be used in this context * @throws OgnlException if there is a pathological environmental problem */ public static Object getValue( Object tree, Map context, Object root, Class resultType ) throws OgnlException { Object result; OgnlContext ognlContext = (OgnlContext)addDefaultContext(root, context); result = ((Node)tree).getValue( ognlContext, root ); if (resultType != null) { result = getTypeConverter( context ).convertValue( context, root, null, null, result, resultType); } return result; }
@Test public void shouldNotInstantiateIfLastTerm() throws OgnlException, NoSuchMethodException { final TypeConverter typeConverter = mock(TypeConverter.class); final House house = new House(); final Mouse tom = new Mouse(); Method method = House.class.getDeclaredMethod("setMouse", Mouse.class); when(typeConverter.convertValue(context, house, method, "mouse", "22", Mouse.class)).thenReturn(tom); Ognl.setTypeConverter(context, typeConverter); Ognl.setValue("mouse", context, house, "22"); assertThat(house.getMouse(), is(equalTo(tom))); }
Array.set(result, i, o); } else { Array.set(result, i, converter.convertValue(context, null, null, null, o, componentClass));
Array.set(result, i, o); } else { Array.set(result, i, converter.convertValue(context, null, null, null, o, componentClass));
Array.set(result, i, o); } else { Array.set(result, i, converter.convertValue(context, null, null, null, o, componentClass));