/// /// Returns an Evaluation that contains the node, source and whether it /// is a set operation. If there are no Evaluation objects in the /// pool one is created and returned. /// public Evaluation create(SimpleNode node, object source, bool setOperation) { lock (this) { Evaluation result; if (size > 0) { result = (Evaluation)evaluations [size - 1]; evaluations.RemoveAt(size - 1); result.init(node, source, setOperation); size--; recovered++; } else { result = new Evaluation(node, source, setOperation); created++; } return(result); } }
public object getValue(OgnlContext context, object source) { if (context.getTraceEvaluations()) { EvaluationPool pool = OgnlRuntime.getEvaluationPool(); object result = null; Exception evalException = null; Evaluation evaluation = pool.create(this, source); context.pushEvaluation(evaluation); try { result = evaluateGetValueBody(context, source); } catch (OgnlException ex) { evalException = ex; throw ex; } catch (Exception ex) { evalException = ex; throw ex; } finally { Evaluation eval = context.popEvaluation(); eval.setResult(result); if (evalException != null) { eval.setException(evalException); } if ((evalException == null) && (context.getRootEvaluation() == null) && !context.getKeepLastEvaluation()) { pool.recycleAll(eval); } } return(result); } else { return(evaluateGetValueBody(context, source)); } }
///<summary> /// Adds a child to the list of children of this evaluation. The /// parent of the child is set to the receiver and the children /// references are modified in the receiver to reflect the new child. /// The lastChild of the receiver is set to the child, and the /// firstChild is set also if child is the first (or only) child. ///</summary> public void addChild(Evaluation child) { if (firstChild == null) { firstChild = lastChild = child; } else { if (firstChild == lastChild) { firstChild.next = child; lastChild = child; lastChild.previous = firstChild; } else { child.previous = lastChild; lastChild.next = child; lastChild = child; } } child.parent = this; }
public void setValue(OgnlContext context, object target, object value) { if (context.getTraceEvaluations()) { EvaluationPool pool = OgnlRuntime.getEvaluationPool(); Exception evalException = null; Evaluation evaluation = pool.create(this, target, true); context.pushEvaluation(evaluation); try { evaluateSetValueBody(context, target, value); } catch (OgnlException ex) { evalException = ex; ex.setEvaluation(evaluation); throw ex; } catch (Exception ex) { evalException = ex; throw ex; } finally { Evaluation eval = context.popEvaluation(); if (evalException != null) { eval.setException(evalException); } if ((evalException == null) && (context.getRootEvaluation() == null) && !context.getKeepLastEvaluation()) { pool.recycleAll(eval); } } } else { evaluateSetValueBody(context, target, value); } }
public object this [object key] { get { object result; if (RESERVED_KEYS.Contains(key)) { if (key.Equals(OgnlContext.THIS_CONTEXT_KEY)) { result = getCurrentObject(); } else { if (key.Equals(OgnlContext.ROOT_CONTEXT_KEY)) { result = getRoot(); } else { if (key.Equals(OgnlContext.CONTEXT_CONTEXT_KEY)) { result = this; } else { if (key.Equals(OgnlContext.TRACE_EVALUATIONS_CONTEXT_KEY)) { result = getTraceEvaluations() ? true : false; } else { if (key.Equals(OgnlContext.LAST_EVALUATION_CONTEXT_KEY)) { result = getLastEvaluation(); } else { if (key.Equals(OgnlContext.KEEP_LAST_EVALUATION_CONTEXT_KEY)) { result = getKeepLastEvaluation() ? true : false; } else { if (key.Equals(OgnlContext.CLASS_RESOLVER_CONTEXT_KEY)) { result = getClassResolver(); } else { if (key.Equals(OgnlContext.TYPE_CONVERTER_CONTEXT_KEY)) { result = getTypeConverter(); } else { if (key.Equals(OgnlContext.MEMBER_ACCESS_CONTEXT_KEY)) { result = getMemberAccess(); } else { throw new ArgumentException("unknown reserved key '" + key + "'"); } } } } } } } } } } else { result = values [key]; } return(result); } set { object result; if (RESERVED_KEYS.Contains(key)) { if (key.Equals(OgnlContext.THIS_CONTEXT_KEY)) { result = getCurrentObject(); setCurrentObject(value); } else { if (key.Equals(OgnlContext.ROOT_CONTEXT_KEY)) { result = getRoot(); setRoot(value); } else { if (key.Equals(OgnlContext.CONTEXT_CONTEXT_KEY)) { throw new ArgumentException("can't change " + OgnlContext.CONTEXT_CONTEXT_KEY + " in context"); } else { if (key.Equals(OgnlContext.TRACE_EVALUATIONS_CONTEXT_KEY)) { result = getTraceEvaluations() ? true : false; setTraceEvaluations(OgnlOps.booleanValue(value)); } else { if (key.Equals(OgnlContext.LAST_EVALUATION_CONTEXT_KEY)) { result = getLastEvaluation(); lastEvaluation = (Evaluation)value; } else { if (key.Equals(OgnlContext.KEEP_LAST_EVALUATION_CONTEXT_KEY)) { result = getKeepLastEvaluation() ? true : false; setKeepLastEvaluation(OgnlOps.booleanValue(value)); } else { if (key.Equals(OgnlContext.CLASS_RESOLVER_CONTEXT_KEY)) { result = getClassResolver(); setClassResolver((ClassResolver)value); } else { if (key.Equals(OgnlContext.TYPE_CONVERTER_CONTEXT_KEY)) { result = getTypeConverter(); setTypeConverter((TypeConverter)value); } else { if (key.Equals(OgnlContext.MEMBER_ACCESS_CONTEXT_KEY)) { result = getMemberAccess(); setMemberAccess((MemberAccess)value); } else { throw new ArgumentException("unknown reserved key '" + key + "'"); } } } } } } } } } } else { // result = values.Add(key, value); } // return result; } }
public void setRootEvaluation(Evaluation value) { rootEvaluation = value; }
public void setCurrentEvaluation(Evaluation value) { currentEvaluation = value; }
///<summary> /// This method can be called when the last evaluation has been used /// and can be returned for reuse in the free pool maintained by the /// runtime. This is not a necessary step, but is useful for keeping /// memory usage down. This will recycle the last evaluation and then /// set the last evaluation to null. ///</summary> public void recycleLastEvaluation() { OgnlRuntime.getEvaluationPool().recycleAll(lastEvaluation); lastEvaluation = null; }
public void setLastEvaluation(Evaluation value) { lastEvaluation = value; }
///<summary> /// Sets the Evaluation that was current when this exception was thrown. ///</summary> public void setEvaluation(Evaluation value) { evaluation = value; }