Class OgnlContext
java.lang.Object
ognl.OgnlContext
-
Nested Class Summary
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ClassResolverprivate Evaluationprivate Nodeprivate Objectprivate static final booleanprivate static booleanprivate static booleanprivate static final Stringprivate booleanprivate static final Stringprivate booleanprivate static final Stringprivate Evaluationprivate intprivate Map<String, LocalReference> private final MemberAccessprivate static final Stringprivate Objectprivate static final Stringprivate Evaluationprivate static final Stringprivate static final Stringprivate booleanprivate final TypeConverter -
Constructor Summary
ConstructorsConstructorDescriptionOgnlContext(ClassResolver classResolver, TypeConverter typeConverter, MemberAccess memberAccess) Constructs a new OgnlContext with the given class resolver, type converter and member access.OgnlContext(MemberAccess memberAccess, ClassResolver classResolver, TypeConverter typeConverter, OgnlContext initialContext) Constructs a new OgnlContext with the given member access, class resolver, type converter and values. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLocalReference(String key, LocalReference reference) voidclear()booleancontainsKey(Object key) booleancontainsValue(Object value) entrySet()booleanClass<?> 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<?> booleanDeprecated.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.booleanDeprecated.since OGNL 3.4.0, useisTraceEvaluations()Get the values Map for this OgnlContext.inthashCode()intbooleanisEmpty()booleanReturns true if read methods of properties are ignored when accessing properties.booleanReturns true if the last evaluation that was done on this context is retained and available throughgetLastEvaluation().booleankeySet()Pops the current Evaluation off of the top of the stack.voidpushEvaluation(Evaluation value) Pushes a new Evaluation onto the stack.voidvoidsetCurrentAccessor(Class<?> type) voidsetCurrentEvaluation(Evaluation value) voidsetCurrentNode(Node value) voidsetCurrentObject(Object value) voidsetCurrentType(Class<?> type) voidsetIgnoreReadMethods(boolean value) Sets read methods of properties are ignored when accessing properties.voidsetKeepLastEvaluation(boolean value) Sets whether the last evaluation that was done on this context is retained and available throughgetLastEvaluation().voidsetLastEvaluation(Evaluation value) voidsetPreviousType(Class<?> type) voidvoidsetRootEvaluation(Evaluation value) voidsetTraceEvaluations(boolean value) voidSet (put) the provided value map content into the existing values Map for this OgnlContext.intsize()values()withValues(Map<String, Object> values) Similar tosetValues(Map)but returns the current instance ofOgnlContextMethods inherited from class Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
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:
-
IGNORE_READ_METHODS_CONTEXT_KEY
- See Also:
-
PROPERTY_KEY_PREFIX
- See Also:
-
DEFAULT_IGNORE_READ_METHODS
private static final boolean DEFAULT_IGNORE_READ_METHODS- See Also:
-
DEFAULT_TRACE_EVALUATIONS
private static boolean DEFAULT_TRACE_EVALUATIONS -
DEFAULT_KEEP_LAST_EVALUATION
private static boolean DEFAULT_KEEP_LAST_EVALUATION -
RESERVED_KEYS
-
root
-
currentObject
-
currentNode
-
traceEvaluations
private boolean traceEvaluations -
rootEvaluation
-
currentEvaluation
-
lastEvaluation
-
keepLastEvaluation
private boolean keepLastEvaluation -
ignoreReadMethods
private boolean ignoreReadMethods -
internalContext
-
classResolver
-
typeConverter
-
memberAccess
-
typeStack
-
accessorStack
-
localReferenceCounter
private int localReferenceCounter -
localReferenceMap
-
-
Constructor Details
-
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, OgnlContext initialContext) 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.initialContext- the initial context of values to provide for a new OgnlContext.
-
-
Method Details
-
setValues
-
withValues
Similar tosetValues(Map)but returns the current instance ofOgnlContext- Parameters:
values- a Map of values- Returns:
- the current instance of
OgnlContext
-
getValues
-
getClassResolver
-
getTypeConverter
-
getMemberAccess
-
setRoot
-
getRoot
-
getTraceEvaluations
Deprecated.since OGNL 3.4.0, useisTraceEvaluations() -
isTraceEvaluations
public boolean isTraceEvaluations() -
setTraceEvaluations
public void setTraceEvaluations(boolean value) -
getLastEvaluation
-
setLastEvaluation
-
getKeepLastEvaluation
Deprecated.since OGNL 3.4.0, useisKeepLastEvaluation() -
isKeepLastEvaluation
public boolean isKeepLastEvaluation()Returns true if the last evaluation that was done on this context is retained and available throughgetLastEvaluation(). 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 throughgetLastEvaluation(). The default is true.- Parameters:
value- true if the last evaluation for this context should be retained and available throughgetLastEvaluation(), false otherwise.
-
isIgnoreReadMethods
public boolean isIgnoreReadMethods()Returns true if read methods of properties are ignored when accessing properties. The default is false.- Returns:
- true if read methods of properties are ignored when accessing properties, false otherwise.
-
setIgnoreReadMethods
public void setIgnoreReadMethods(boolean value) Sets read methods of properties are ignored when accessing properties. The default is false.- Parameters:
value- true if read methods of properties are ignored when accessing properties, false otherwise.
-
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.- Returns:
- the current Evaluation from the top of the stack (being evaluated).
-
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.- Returns:
- the root Evaluation from the stack (the root expression node).
-
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.- 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
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().- Parameters:
value- the Evaluation to push onto the stack.
-
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
-
getLocalReferences
-
size
-
isEmpty
-
containsKey
- Specified by:
containsKeyin interfaceMap<String,Object>
-
containsValue
- Specified by:
containsValuein interfaceMap<String,Object>
-
get
-
put
-
remove
-
putAll
-
clear
-
keySet
-
values
-
entrySet
-
equals
-
hashCode
-
isKeepLastEvaluation()