Package org.apache.commons.ognl
Class OgnlContext
java.lang.Object
org.apache.commons.ognl.OgnlContext
This class defines the execution context for an OGNL expression
-
Nested Class Summary
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
private ClassResolver
static final String
private Evaluation
private Node
private Object
static final DefaultClassResolver
static final MemberAccess
static final TypeConverter
private static boolean
private static boolean
static final String
private boolean
static final String
private Evaluation
private int
private Map<String,
LocalReference> static final String
private MemberAccess
private static final String
private Object
static final String
private Evaluation
static final String
static final String
private boolean
static final String
private TypeConverter
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new OgnlContext with the default class resolver, type converter and member access.OgnlContext
(Map<String, Object> values) OgnlContext
(ClassResolver classResolver, TypeConverter typeConverter, MemberAccess memberAccess) Constructs a new OgnlContext with the given class resolver, type converter and member access.OgnlContext
(ClassResolver classResolver, TypeConverter typeConverter, MemberAccess memberAccess, Map<String, Object> values) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addLocalReference
(String key, LocalReference reference) void
clear()
boolean
containsKey
(Object key) boolean
containsValue
(Object value) entrySet()
boolean
Class<?>
Gets the current Evaluation from the top of the stack.Class<?>
Gets the current class type being evaluated on the stack, as set bysetCurrentType(Class)
.getEvaluation
(int relativeIndex) Returns the Evaluation at the relative index given.Class<?>
Class<?>
boolean
Returns true if the last evaluation that was done on this context is retained and available throughgetLastEvaluation()
.Class<?>
Class<?>
Represents the last known object type on the evaluation stack, will be the value of the last knowngetCurrentType()
.getRoot()
Gets the root of the evaluation stack.boolean
int
hashCode()
int
boolean
isEmpty()
keySet()
Pops the current Evaluation off of the top of the stack.void
pushEvaluation
(Evaluation value) Pushes a new Evaluation onto the stack.void
void
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.void
setClassResolver
(ClassResolver value) void
setCurrentAccessor
(Class<?> type) void
setCurrentEvaluation
(Evaluation value) void
setCurrentNode
(Node value) void
setCurrentObject
(Object value) void
setCurrentType
(Class<?> type) void
setKeepLastEvaluation
(boolean value) Sets whether the last evaluation that was done on this context is retained and available throughgetLastEvaluation()
.void
setLastEvaluation
(Evaluation value) void
setMemberAccess
(MemberAccess value) void
setPreviousType
(Class<?> type) void
void
setRootEvaluation
(Evaluation value) void
setTraceEvaluations
(boolean value) void
setTypeConverter
(TypeConverter value) void
int
size()
values()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
CONTEXT_CONTEXT_KEY
- See Also:
-
ROOT_CONTEXT_KEY
- See Also:
-
THIS_CONTEXT_KEY
- See Also:
-
TRACE_EVALUATIONS_CONTEXT_KEY
- See Also:
-
LAST_EVALUATION_CONTEXT_KEY
- See Also:
-
KEEP_LAST_EVALUATION_CONTEXT_KEY
- See Also:
-
CLASS_RESOLVER_CONTEXT_KEY
- See Also:
-
TYPE_CONVERTER_CONTEXT_KEY
- See Also:
-
MEMBER_ACCESS_CONTEXT_KEY
- See Also:
-
PROPERTY_KEY_PREFIX
- See Also:
-
defaultTraceEvaluations
private static boolean defaultTraceEvaluations -
defaultKeepLastEvaluation
private static boolean defaultKeepLastEvaluation -
DEFAULT_CLASS_RESOLVER
-
DEFAULT_TYPE_CONVERTER
-
DEFAULT_MEMBER_ACCESS
-
RESERVED_KEYS
-
root
-
currentObject
-
currentNode
-
traceEvaluations
private boolean traceEvaluations -
rootEvaluation
-
currentEvaluation
-
lastEvaluation
-
keepLastEvaluation
private boolean keepLastEvaluation -
values
-
classResolver
-
typeConverter
-
memberAccess
-
typeStack
-
accessorStack
-
localReferenceCounter
private int localReferenceCounter -
localReferenceMap
-
-
Constructor Details
-
OgnlContext
public OgnlContext()Constructs a new OgnlContext with the default class resolver, type converter and member access. -
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. -
OgnlContext
-
OgnlContext
public OgnlContext(ClassResolver classResolver, TypeConverter typeConverter, MemberAccess memberAccess, Map<String, Object> values)
-
-
Method Details
-
setValues
-
getValues
-
setClassResolver
-
getClassResolver
-
setTypeConverter
-
getTypeConverter
-
setMemberAccess
-
getMemberAccess
-
setRoot
-
getRoot
-
getTraceEvaluations
public boolean getTraceEvaluations() -
setTraceEvaluations
public void setTraceEvaluations(boolean value) -
getLastEvaluation
-
setLastEvaluation
-
recycleLastEvaluation
public void recycleLastEvaluation()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 throughgetLastEvaluation()
. The default is true. -
setKeepLastEvaluation
public void setKeepLastEvaluation(boolean value) Sets whether the last evaluation that was done on this context is retained and available throughgetLastEvaluation()
. The default is true. -
setCurrentObject
-
getCurrentObject
-
setCurrentAccessor
-
getCurrentAccessor
-
getPreviousAccessor
-
getFirstAccessor
-
getCurrentType
Gets the current class type being evaluated on the stack, as set bysetCurrentType(Class)
.- Returns:
- The current object type, may be null.
-
setCurrentType
-
getPreviousType
Represents the last known object type on the evaluation stack, will be the value of the last knowngetCurrentType()
.- Returns:
- The previous type of object on the stack, may be null.
-
setPreviousType
-
getFirstType
-
setCurrentNode
-
getCurrentNode
-
getCurrentEvaluation
Gets the current Evaluation from the top of the stack. This is the Evaluation that is in process of evaluating. -
setCurrentEvaluation
-
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. -
setRootEvaluation
-
getEvaluation
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. -
pushEvaluation
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 viapopEvaluation()
. -
popEvaluation
Pops the current Evaluation off of the top of the stack. This is done after a node has completed its evaluation. -
incrementLocalReferenceCounter
public int incrementLocalReferenceCounter() -
addLocalReference
-
getLocalReferences
-
size
public int size() -
isEmpty
public boolean isEmpty() -
containsKey
- Specified by:
containsKey
in interfaceMap<String,
Object>
-
containsValue
- Specified by:
containsValue
in interfaceMap<String,
Object>
-
get
-
put
-
remove
-
putAll
-
clear
public void clear() -
keySet
-
values
-
entrySet
-
equals
-
hashCode
public int hashCode()
-