@Override public Object get(Object key) { if (!containsKey(key)) throw new EvaluationException("Referring to undefined variable '" + key + "']"); return super.get(key); } }
|| ASTRootVarRef.class.isInstance(expression) || context.getCurrentAccessor() == Class.class || (context.get(ExpressionCompiler.PRE_CAST) != null && ((String) context.get(ExpressionCompiler.PRE_CAST)).startsWith("new")) || ASTStaticField.class.isInstance(expression) || ASTStaticMethod.class.isInstance(expression)
private Type extractGenericType(OgnlContext ctx, Object target) { Type genericType; if (ctx.getRoot() != target) { Evaluation eval = ctx.getCurrentEvaluation(); Evaluation previous = eval.getPrevious(); String fieldName = previous.getNode().toString(); Object origin = previous.getSource(); Proxifier proxifier = (Proxifier) ctx.get("proxifier"); Method getter = new ReflectionBasedNullHandler(proxifier).findGetter(origin, StringUtils.capitalize(fieldName)); genericType = getter.getGenericReturnType(); } else { genericType = (Type) ctx.get("rootType"); } return genericType; }
if (ASTMethod.class.isInstance(_children[i])) pre = (String)context.get("_currentChain");
public String toGetSourceString(OgnlContext context, Object target) Object value = context.get(_name);
@Before public void setup() { this.context = mock(OgnlContext.class); this.evaluation = mock(Evaluation.class); this.node = mock(SimpleNode.class); this.instance = new Data(); this.typeConverter = mock(TypeConverter.class); final EmptyElementsRemoval removal = new EmptyElementsRemoval() { @Override public void removeExtraElements() { // does nothing } }; final Proxifier proxifier = new JavassistProxifier(new ReflectionInstanceCreator()); accessor = new ArrayAccessor(); when(context.get("removal")).thenReturn(removal); when(context.get("proxifier")).thenReturn(proxifier); when(context.getCurrentEvaluation()).thenReturn(evaluation); when(evaluation.getPrevious()).thenReturn(evaluation); when(evaluation.getNode()).thenReturn(node); when(node.toString()).thenReturn("values"); when(evaluation.getSource()).thenReturn(instance); when(context.getTypeConverter()).thenReturn(typeConverter); }
protected Object getValueBody(OgnlContext context, Object source) throws OgnlException { return context.get(_name); }
@Before public void setup() { MockitoAnnotations.initMocks(this); this.instance = new ArrayList<String>(); when(context.getRoot()).thenReturn(instance); when(context.get("rootType")).thenReturn(Types.listOf(String.class)); when(converters.to(String.class)).thenReturn((Converter) new StringConverter()); this.accessor = new ListAccessor(converters); }
public String toGetSourceString(OgnlContext context, Object target) Object value = context.get(_name);
protected boolean lastChild(OgnlContext context) { return _parent == null || context.get("_lastChild") != null; }
throw new UnsupportedCompilationException("Can only compile boolean expressions with two children."); String pre = (String)context.get("_currentChain"); if (pre == null) pre = "";
protected Object getValueBody(OgnlContext context, Object source) throws OgnlException { return context.get(_name); }
protected boolean lastChild(OgnlContext context) { return _parent == null || context.get("_lastChild") != null; }
protected Object getValueBody( OgnlContext context, Object source ) throws OgnlException { return context.get(name); }
public Object getVariable(String variableName) { assertStartsWithHash(variableName); String rawVariableName = variableName.substring(1); return ognlContext.get(rawVariableName); } }
public Object getVariable(String variableName) { assertStartsWithHash(variableName); String rawVariableName = variableName.substring(1); return ognlContext.get(rawVariableName); } }
/** * Used by {@link #castExpression(ognl.OgnlContext, ognl.Node, String)} to store the cast java * source string in to the current {@link OgnlContext}. This will either add to the existing * string present if it already exists or create a new instance and store it using the static key * of {@link #PRE_CAST}. * * @param context * The current execution context. * @param cast * The java source string to store in to the context. */ public static void addCastString(OgnlContext context, String cast) { String value = (String) context.get(PRE_CAST); if (value != null) value = cast + value; else value = cast; context.put(PRE_CAST, value); }
/** * Used by {@link #castExpression(ognl.OgnlContext, ognl.Node, String)} to store the cast java * source string in to the current {@link OgnlContext}. This will either add to the existing * string present if it already exists or create a new instance and store it using the static key * of {@link #PRE_CAST}. * * @param context * The current execution context. * @param cast * The java source string to store in to the context. */ public static void addCastString(OgnlContext context, String cast) { String value = (String) context.get(PRE_CAST); if (value != null) value = cast + value; else value = cast; context.put(PRE_CAST, value); }
@Override public Object get(Object key) { if (!containsKey(key)) throw new EvaluationException("Referring to undefined variable '" + key + "']"); return super.get(key); } }
Type getListType(Object target, Evaluation evaluation, OgnlContext ctx) { // creating instance Object listHolder = evaluation.getSource(); String listPropertyName = evaluation.getNode().toString(); Proxifier proxifier = (Proxifier) ctx.get("proxifier"); Method listSetter = new ReflectionBasedNullHandler(proxifier).findSetter(listHolder, StringUtils.capitalize(listPropertyName), target.getClass()); Type[] types = listSetter.getGenericParameterTypes(); Type type = types[0]; if (!(type instanceof ParameterizedType)) { throw new VRaptorException("Vraptor does not support non-generic collection at " + listSetter.getName()); } return type; }