public void copy(Object from, Object to, Map<String, Object> context) { copy(from, to, context, null, null); }
protected Map createDefaultContext(Object root) { return createDefaultContext(root, null); }
public PropertyDescriptor[] getPropertyDescriptors(Object source) throws IntrospectionException { return ognlUtil.getPropertyDescriptors(source); } }
public void setProperties(Map<String, ?> props, Object o, Map<String, Object> context) { ognlUtil.setProperties(props, o, context); }
TypeConverter conv = getTypeConverterFromContext(context); final Map contextFrom = createDefaultContext(from, null); Ognl.setTypeConverter(contextFrom, conv); final Map contextTo = createDefaultContext(to, null); Ognl.setTypeConverter(contextTo, conv); fromPds = getPropertyDescriptors(from); toPds = getPropertyDescriptors(to); } catch (IntrospectionException e) { if (LOG.isErrorEnabled()) { if ((toPd != null) && (toPd.getWriteMethod() != null)) { try { compileAndExecute(fromPd.getName(), context, new OgnlTask<Object>() { public Void execute(Object expr) throws OgnlException { Object value = Ognl.getValue(expr, contextFrom, from);
final Map sourceMap = createDefaultContext(source, null); PropertyDescriptor[] propertyDescriptors = getPropertyDescriptors(source); for (PropertyDescriptor propertyDescriptor : propertyDescriptors) { final String propertyName = propertyDescriptor.getDisplayName(); Method readMethod = propertyDescriptor.getReadMethod(); if (readMethod != null) { final Object value = compileAndExecute(propertyName, null, new OgnlTask<Object>() { public Object execute(Object expr) throws OgnlException { return Ognl.getValue(expr, sourceMap, source);
/** * Sets the properties on the object using the default context. * * @param properties the property map to set on the object * @param o the object to set the properties into * @param throwPropertyExceptions boolean which tells whether it should throw exceptions for * problems setting the properties */ public void setProperties(Map<String, ?> properties, Object o, boolean throwPropertyExceptions) { Map context = createDefaultContext(o, null); setProperties(properties, o, context, throwPropertyExceptions); }
private Object getValue(String expr, Class asType) throws OgnlException { return ognlUtil.getValue(expr, context, root, asType); }
public Object getValue(final String name, final Map<String, Object> context, final Object root, final Class resultType) throws OgnlException { return compileAndExecute(name, context, new OgnlTask<Object>() { public Object execute(Object tree) throws OgnlException { return Ognl.getValue(tree, context, root, resultType); } }); }
public Object compile(String expression) throws OgnlException { return compile(expression, null); }
private <T> Object compileAndExecute(String expression, Map<String, Object> context, OgnlTask<T> task) throws OgnlException { Object tree; if (enableExpressionCache) { tree = expressions.get(expression); if (tree == null) { tree = Ognl.parseExpression(expression); checkEnableEvalExpression(tree, context); } } else { tree = Ognl.parseExpression(expression); checkEnableEvalExpression(tree, context); } final T exec = task.execute(tree); // if cache is enabled and it's a valid expression, puts it in if(enableExpressionCache) { expressions.putIfAbsent(expression, tree); } return exec; }
private <T> Object compileAndExecuteMethod(String expression, Map<String, Object> context, OgnlTask<T> task) throws OgnlException { Object tree; if (enableExpressionCache) { tree = expressions.get(expression); if (tree == null) { tree = Ognl.parseExpression(expression); checkSimpleMethod(tree, context); } } else { tree = Ognl.parseExpression(expression); checkSimpleMethod(tree, context); } final T exec = task.execute(tree); // if cache is enabled and it's a valid expression, puts it in if(enableExpressionCache) { expressions.putIfAbsent(expression, tree); } return exec; }
methodResult = ognlUtil.callMethod(methodName + "()", getStack().getContext(), action); } catch (MethodFailedException e) { try { String altMethodName = "do" + methodName.substring(0, 1).toUpperCase() + methodName.substring(1) + "()"; methodResult = ognlUtil.callMethod(altMethodName, getStack().getContext(), action); } catch (MethodFailedException e1) {
public void setProperties(Map<String, ?> props, Object o, Map<String, Object> context, boolean throwPropertyExceptions) throws ReflectionException{ ognlUtil.setProperties(props, o, context, throwPropertyExceptions); }
private Object getValueUsingOgnl(String expr) throws OgnlException { try { return ognlUtil.getValue(expr, context, root); } finally { context.remove(THROW_EXCEPTION_ON_FAILURE); } }
public Object compile(String expression, Map<String, Object> context) throws OgnlException { return compileAndExecute(expression,context,new OgnlTask<Object>() { public Object execute(Object tree) throws OgnlException { return tree; } }); }
public void setProperties(Map<String, ?> properties, Object o) { setProperties(properties, o, false); }
/** * Copies the properties in the object "from" and sets them in the object "to" * using specified type converter, or {@link com.opensymphony.xwork2.conversion.impl.XWorkConverter} if none * is specified. * * @param from the source object * @param to the target object * @param context the action context we're running under */ public void copy(Object from, Object to, Map<String, Object> context) { copy(from, to, context, null, null); }
public Object getValue(String expression, Map<String, Object> context, Object root) throws ReflectionException { try { return ognlUtil.getValue(expression, context, root); } catch (OgnlException e) { throw new ReflectionException(e); } }
public PropertyDescriptor[] getPropertyDescriptors(Object source) throws IntrospectionException { return ognlUtil.getPropertyDescriptors(source); } }