Package ognl

Class OgnlContext

  • All Implemented Interfaces:
    java.util.Map

    public class OgnlContext
    extends java.lang.Object
    implements java.util.Map
    This class defines the execution context for an OGNL expression
    • Field Detail

      • ROOT_CONTEXT_KEY

        public static final java.lang.String ROOT_CONTEXT_KEY
        See Also:
        Constant Field Values
      • THIS_CONTEXT_KEY

        public static final java.lang.String THIS_CONTEXT_KEY
        See Also:
        Constant Field Values
      • TRACE_EVALUATIONS_CONTEXT_KEY

        public static final java.lang.String TRACE_EVALUATIONS_CONTEXT_KEY
        See Also:
        Constant Field Values
      • LAST_EVALUATION_CONTEXT_KEY

        public static final java.lang.String LAST_EVALUATION_CONTEXT_KEY
        See Also:
        Constant Field Values
      • KEEP_LAST_EVALUATION_CONTEXT_KEY

        public static final java.lang.String KEEP_LAST_EVALUATION_CONTEXT_KEY
        See Also:
        Constant Field Values
      • TYPE_CONVERTER_CONTEXT_KEY

        @Deprecated
        public static final java.lang.String TYPE_CONVERTER_CONTEXT_KEY
        Deprecated.
        See Also:
        Constant Field Values
      • PROPERTY_KEY_PREFIX

        private static final java.lang.String PROPERTY_KEY_PREFIX
        See Also:
        Constant Field Values
      • DEFAULT_TRACE_EVALUATIONS

        private static boolean DEFAULT_TRACE_EVALUATIONS
      • DEFAULT_KEEP_LAST_EVALUATION

        private static boolean DEFAULT_KEEP_LAST_EVALUATION
      • RESERVED_KEYS

        private static final java.util.Map<java.lang.Object,​java.lang.Object> RESERVED_KEYS
      • _root

        private java.lang.Object _root
      • _currentObject

        private java.lang.Object _currentObject
      • _currentNode

        private Node _currentNode
      • _traceEvaluations

        private boolean _traceEvaluations
      • _rootEvaluation

        private Evaluation _rootEvaluation
      • _currentEvaluation

        private Evaluation _currentEvaluation
      • _lastEvaluation

        private Evaluation _lastEvaluation
      • _keepLastEvaluation

        private boolean _keepLastEvaluation
      • _values

        private final java.util.Map _values
      • _typeStack

        private final java.util.List<java.lang.Class<?>> _typeStack
      • _accessorStack

        private final java.util.List<java.lang.Class<?>> _accessorStack
      • _localReferenceCounter

        private int _localReferenceCounter
      • _localReferenceMap

        private java.util.Map<java.lang.String,​LocalReference> _localReferenceMap
    • Constructor Detail

      • OgnlContext

        public OgnlContext​(ClassResolver classResolver,
                           TypeConverter typeConverter,
                           MemberAccess memberAccess)
        Constructs a new OgnlContext with the given class resolver, type converter and member access. If any of these parameters is null the default will be used, except memberAccess which must be non-null.
        Parameters:
        classResolver - the ClassResolver for a new OgnlContext.
        typeConverter - the TypeConverter for a new OgnlContext.
        memberAccess - the MemberAccess for a new OgnlContext. Must be non-null.
      • OgnlContext

        public OgnlContext​(MemberAccess memberAccess,
                           ClassResolver classResolver,
                           TypeConverter typeConverter,
                           java.util.Map values)
        Constructs a new OgnlContext with the given member access, class resolver, type converter and values. If any of these parameters is null the default will be used, except memberAccess which must be non-null.
        Parameters:
        memberAccess - the MemberAccess for a new OgnlContext. Must be non-null.
        classResolver - the ClassResolver for a new OgnlContext.
        typeConverter - the TypeConverter for a new OgnlContext.
        values - the Map of values to provide for a new OgnlContext.
    • Method Detail

      • setValues

        public void setValues​(java.util.Map value)
        Set (put) the provided value map content into the existing values Map for this OgnlContext.
        Parameters:
        value - a Map of additional values to put into this OgnlContext.
      • getValues

        public java.util.Map getValues()
        Get the values Map for this OgnlContext.
        Returns:
        Map of values for this OgnlContext.
      • setClassResolver

        @Deprecated
        public void setClassResolver​(ClassResolver ignore)
        Deprecated.
      • setTypeConverter

        @Deprecated
        public void setTypeConverter​(TypeConverter ignore)
        Deprecated.
      • setMemberAccess

        @Deprecated
        public void setMemberAccess​(MemberAccess ignore)
        Deprecated.
      • setRoot

        public void setRoot​(java.lang.Object value)
      • getRoot

        public java.lang.Object getRoot()
      • getTraceEvaluations

        public boolean getTraceEvaluations()
      • setTraceEvaluations

        public void setTraceEvaluations​(boolean value)
      • getLastEvaluation

        public Evaluation getLastEvaluation()
      • setLastEvaluation

        public void setLastEvaluation​(Evaluation value)
      • recycleLastEvaluation

        @Deprecated
        public void recycleLastEvaluation()
        Deprecated.
        since 3.2
        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.
      • getKeepLastEvaluation

        public boolean getKeepLastEvaluation()
        Returns true if the last evaluation that was done on this context is retained and available through getLastEvaluation(). The default is true.
        Returns:
        true if the last evaluation for this context is retained and available through getLastEvaluation(), false otherwise.
      • setKeepLastEvaluation

        public void setKeepLastEvaluation​(boolean value)
        Sets whether the last evaluation that was done on this context is retained and available through getLastEvaluation(). The default is true.
        Parameters:
        value - true if the last evaluation for this context should be retained and available through getLastEvaluation(), false otherwise.
      • setCurrentObject

        public void setCurrentObject​(java.lang.Object value)
      • getCurrentObject

        public java.lang.Object getCurrentObject()
      • setCurrentAccessor

        public void setCurrentAccessor​(java.lang.Class type)
      • getCurrentAccessor

        public java.lang.Class getCurrentAccessor()
      • getPreviousAccessor

        public java.lang.Class getPreviousAccessor()
      • getFirstAccessor

        public java.lang.Class getFirstAccessor()
      • getCurrentType

        public java.lang.Class getCurrentType()
        Gets the current class type being evaluated on the stack, as set by setCurrentType(Class).
        Returns:
        The current object type, may be null.
      • setCurrentType

        public void setCurrentType​(java.lang.Class type)
      • getPreviousType

        public java.lang.Class getPreviousType()
        Represents the last known object type on the evaluation stack, will be the value of the last known getCurrentType().
        Returns:
        The previous type of object on the stack, may be null.
      • setPreviousType

        public void setPreviousType​(java.lang.Class type)
      • getFirstType

        public java.lang.Class getFirstType()
      • setCurrentNode

        public void setCurrentNode​(Node value)
      • getCurrentNode

        public Node getCurrentNode()
      • getCurrentEvaluation

        public Evaluation getCurrentEvaluation()
        Gets the current Evaluation from the top of the stack. This is the Evaluation that is in process of evaluating.
        Returns:
        the current Evaluation from the top of the stack (being evaluated).
      • setCurrentEvaluation

        public void setCurrentEvaluation​(Evaluation value)
      • getRootEvaluation

        public Evaluation getRootEvaluation()
        Gets the root of the evaluation stack. This Evaluation contains the node representing the root expression and the source is the root source object.
        Returns:
        the root Evaluation from the stack (the root expression node).
      • setRootEvaluation

        public void setRootEvaluation​(Evaluation value)
      • getEvaluation

        public Evaluation getEvaluation​(int relativeIndex)
        Returns the Evaluation at the relative index given. This should be zero or a negative number as a relative reference back up the evaluation stack. Therefore getEvaluation(0) returns the current Evaluation.
        Parameters:
        relativeIndex - the relative index for the Evaluation to retrieve from the stack (with 0 being the current Evaluation). relativeIndex should be <= 0.
        Returns:
        the Evaluation at relativeIndex, or null if relativeIndex is > 0.
      • pushEvaluation

        public void pushEvaluation​(Evaluation value)
        Pushes a new Evaluation onto the stack. This is done before a node evaluates. When evaluation is complete it should be popped from the stack via popEvaluation().
        Parameters:
        value - the Evaluation to push onto the stack.
      • popEvaluation

        public Evaluation popEvaluation()
        Pops the current Evaluation off of the top of the stack. This is done after a node has completed its evaluation.
        Returns:
        the Evaluation popped from the top of the stack.
      • incrementLocalReferenceCounter

        public int incrementLocalReferenceCounter()
      • addLocalReference

        public void addLocalReference​(java.lang.String key,
                                      LocalReference reference)
      • getLocalReferences

        public java.util.Map getLocalReferences()
      • size

        public int size()
        Specified by:
        size in interface java.util.Map
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Map
      • containsKey

        public boolean containsKey​(java.lang.Object key)
        Specified by:
        containsKey in interface java.util.Map
      • containsValue

        public boolean containsValue​(java.lang.Object value)
        Specified by:
        containsValue in interface java.util.Map
      • get

        public java.lang.Object get​(java.lang.Object key)
        Specified by:
        get in interface java.util.Map
      • put

        public java.lang.Object put​(java.lang.Object key,
                                    java.lang.Object value)
        Specified by:
        put in interface java.util.Map
      • remove

        public java.lang.Object remove​(java.lang.Object key)
        Specified by:
        remove in interface java.util.Map
      • putAll

        public void putAll​(java.util.Map t)
        Specified by:
        putAll in interface java.util.Map
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Map
      • keySet

        public java.util.Set keySet()
        Specified by:
        keySet in interface java.util.Map
      • values

        public java.util.Collection values()
        Specified by:
        values in interface java.util.Map
      • entrySet

        public java.util.Set entrySet()
        Specified by:
        entrySet in interface java.util.Map
      • equals

        public boolean equals​(java.lang.Object o)
        Specified by:
        equals in interface java.util.Map
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface java.util.Map
        Overrides:
        hashCode in class java.lang.Object