public Map<String,Object> getExpressionObjects() { if (!this.computedBaseContextVariables) { // Base context variables are computed lazily so that subclasses have // the chance to override the basic computing behaviour. // The boolean flag is modified first so that if this method is called by // error during the implementation of "computeExpressionObjects()" it does // not result in an infinite loop. this.computedBaseContextVariables = true; this.expressionObjects = computeExpressionObjects(); } return this.expressionObjects; }
private Object createSelectedEvaluationRoot() { if (hasSelectionTarget()) { return getSelectionTarget(); } return this.evaluationRoot; }
public Object getSelectionTarget() { if (hasLocalVariable(EVAL_SELECTION_TARGET_LOCAL_VARIABLE_NAME)) { return getLocalVariable(EVAL_SELECTION_TARGET_LOCAL_VARIABLE_NAME); } if (getContext().getVariables().containsKey(EVAL_SELECTION_TARGET_LOCAL_VARIABLE_NAME)) { return getContext().getVariables().get(EVAL_SELECTION_TARGET_LOCAL_VARIABLE_NAME); } return null; }
public boolean hasSelectionTarget() { return hasLocalVariable(EVAL_SELECTION_TARGET_LOCAL_VARIABLE_NAME) || getContext().getVariables().containsKey(EVAL_SELECTION_TARGET_LOCAL_VARIABLE_NAME); }
protected AbstractProcessingContext( final IContext context, final Map<String,Object> localVariables, final Object selectionTarget, final boolean selectionTargetSet) { super(); Validate.notNull(context, "Context cannot be null"); this.context = context; this.localVariables = (localVariables != null? new HashMap<String,Object>(localVariables) : (selectionTargetSet? new HashMap<String, Object>(2, 1.0f) : null)); if (selectionTargetSet) { this.localVariables.put(EVAL_SELECTION_TARGET_LOCAL_VARIABLE_NAME, selectionTarget); } this.evaluationRoot = createEvaluationRoot(); this.selectionEvaluationRoot = createSelectedEvaluationRoot(); }
@Override protected Map<String, Object> computeExpressionObjects() { if (this.dialects == null) { return super.computeExpressionObjects(); } final Map<String,Object> variables = super.computeExpressionObjects(); for (final IExpressionEnhancingDialect dialect : this.dialects) { final Map<String,Object> dialectVariables = dialect.getAdditionalExpressionObjects(this); if (dialectVariables != null) { variables.putAll(dialectVariables); } } return variables; }