@Override public Object callStaticMethod(Map context, Class aClass, String string, Object[] objects) throws MethodFailedException { Boolean exec = (Boolean) context.get(ReflectionContextState.DENY_METHOD_EXECUTION); boolean e = ((exec == null) ? false : exec.booleanValue()); if (!e) { return callStaticMethodWithDebugInfo(context, aClass, string, objects); } else { return null; } }
@Override public void setProperty(Map context, Object target, Object name, Object value) throws OgnlException { if (LOG.isDebugEnabled()) { LOG.debug("Entering setProperty("+context+","+target+","+name+","+value+")"); } Object key = getKey(context, name); Map map = (Map) target; map.put(key, getValue(context, value)); }
public void testCreateNullObjectsIsFalseByDefault() { ValueStack vs = ActionContext.getContext().getValueStack(); vs.push(new MapHolder(Collections.emptyMap())); assertNull(vs.findValue("map[key]")); }
public void testNullIsNotReturnedWhenCreateNullObjectsIsSpecified() { ValueStack vs = ActionContext.getContext().getValueStack(); vs.push(new MapHolder(Collections.emptyMap())); ReflectionContextState.setCreatingNullObjects(vs.getContext(), true); Object value = vs.findValue("map['key']"); assertNotNull(value); assertSame(Object.class, value.getClass()); }
public void testMapContentsAreReturned() { ValueStack vs = ActionContext.getContext().getValueStack(); vs.push(new MapHolder(Collections.singletonMap("key", "value"))); assertEquals("value", vs.findValue("map['key']")); }
Class[] argTypes = getArgTypes(objects); mc = new MethodCall(clazz, name, argTypes);
Map collMap = getSetMap(context, c, keyProperty, collClass); if (key.toString().equals(KEY_PROPERTY_FOR_CREATION)) { return getPropertyThroughIteration(context, c, keyProperty, realKey);
public void setProperty(Map context, Object target, Object name, Object value) throws OgnlException { ObjectProxy proxy = (ObjectProxy) target; setupContext(context, proxy); OgnlRuntime.getPropertyAccessor(proxy.getValue().getClass()).setProperty(context, target, name, value); }
@Override public void setProperty(Map context, Object target, Object name, Object value) throws OgnlException { Class lastClass = (Class) context.get(XWorkConverter.LAST_BEAN_CLASS_ACCESSED); String lastProperty = (String) context.get(XWorkConverter.LAST_BEAN_PROPERTY_ACCESSED); Class convertToClass = objectTypeDeterminer.getElementClass(lastClass, lastProperty, name); if (name instanceof String && value.getClass().isArray()) { // looks like the input game in the form of "someCollection.foo" and // we are expected to define the index values ourselves. // So let's do it: Collection c = (Collection) target; Object[] values = (Object[]) value; for (Object v : values) { try { Object o = objectFactory.buildBean(convertToClass, context); ognlUtil.setValue((String) name, context, o, v); c.add(o); } catch (Exception e) { throw new OgnlException("Error converting given String values for Collection.", e); } } // we don't want to do the normal collection property setting now, since we've already done the work // just return instead return; } Object realValue = getRealValue(context, value, convertToClass); super.setProperty(context, target, name, realValue); }
private Map getSetMap(Map context, Collection collection, String property, Class valueClass) throws OgnlException { if (LOG.isDebugEnabled()) { LOG.debug("getting set Map"); } String path = ReflectionContextState.getCurrentPropertyPath(context); Map map = ReflectionContextState.getSetMap(context, path); if (map == null) { if (LOG.isDebugEnabled()) { LOG.debug("creating set Map"); } map = new HashMap(); map.put(null, new SurrugateList(collection)); for (Object currTest : collection) { Object currKey = _accessor.getProperty(context, currTest, property); if (currKey != null) { map.put(currKey, currTest); } } ReflectionContextState.setSetMap(context, map, path); } return map; }
Object realValue = getRealValue(context, value, convertToClass);
boolean e = ((exec == null) ? false : exec.booleanValue()); if (!e) { return callMethodWithDebugInfo(context, object, string, objects); return callMethodWithDebugInfo(context, object, string, objects); } else { return null;
return _sAcc.getProperty(context, target, name); } else if (name instanceof String) { return super.getProperty(context, target, name);
public void testNullIsReturnedWhenCreateNullObjectsIsSpecifiedAsFalse() { ValueStack vs = ActionContext.getContext().getValueStack(); vs.push(new MapHolder(Collections.emptyMap())); ReflectionContextState.setCreatingNullObjects(vs.getContext(), false); assertNull(vs.findValue("map['key']")); }
public Object getProperty(Map context, Object target, Object name) throws OgnlException { ObjectProxy proxy = (ObjectProxy) target; setupContext(context, proxy); return OgnlRuntime.getPropertyAccessor(proxy.getValue().getClass()).getProperty(context, target, name); }