Package org.apache.commons.ognl
Class OgnlContext
- java.lang.Object
-
- org.apache.commons.ognl.OgnlContext
-
-
Field Summary
Fields Modifier and Type Field Description static String
CLASS_RESOLVER_CONTEXT_KEY
static String
CONTEXT_CONTEXT_KEY
static DefaultClassResolver
DEFAULT_CLASS_RESOLVER
static MemberAccess
DEFAULT_MEMBER_ACCESS
static TypeConverter
DEFAULT_TYPE_CONVERTER
static String
KEEP_LAST_EVALUATION_CONTEXT_KEY
static String
LAST_EVALUATION_CONTEXT_KEY
static String
MEMBER_ACCESS_CONTEXT_KEY
static String
ROOT_CONTEXT_KEY
static String
THIS_CONTEXT_KEY
static String
TRACE_EVALUATIONS_CONTEXT_KEY
static String
TYPE_CONVERTER_CONTEXT_KEY
-
Constructor Summary
Constructors Constructor Description OgnlContext()
Constructs 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addLocalReference(String key, LocalReference reference)
void
clear()
boolean
containsKey(Object key)
boolean
containsValue(Object value)
Set<Map.Entry<String,Object>>
entrySet()
boolean
equals(Object o)
Object
get(Object key)
ClassResolver
getClassResolver()
Class<?>
getCurrentAccessor()
Evaluation
getCurrentEvaluation()
Gets the current Evaluation from the top of the stack.Node
getCurrentNode()
Object
getCurrentObject()
Class<?>
getCurrentType()
Gets the current class type being evaluated on the stack, as set bysetCurrentType(Class)
.Evaluation
getEvaluation(int relativeIndex)
Returns the Evaluation at the relative index given.Class<?>
getFirstAccessor()
Class<?>
getFirstType()
boolean
getKeepLastEvaluation()
Returns true if the last evaluation that was done on this context is retained and available throughgetLastEvaluation()
.Evaluation
getLastEvaluation()
Map<String,LocalReference>
getLocalReferences()
MemberAccess
getMemberAccess()
Class<?>
getPreviousAccessor()
Class<?>
getPreviousType()
Represents the last known object type on the evaluation stack, will be the value of the last knowngetCurrentType()
.Object
getRoot()
Evaluation
getRootEvaluation()
Gets the root of the evaluation stack.boolean
getTraceEvaluations()
TypeConverter
getTypeConverter()
Map<String,Object>
getValues()
int
hashCode()
int
incrementLocalReferenceCounter()
boolean
isEmpty()
Set<String>
keySet()
Evaluation
popEvaluation()
Pops the current Evaluation off of the top of the stack.void
pushEvaluation(Evaluation value)
Pushes a new Evaluation onto the stack.Object
put(String key, Object value)
void
putAll(Map<? extends String,?> t)
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.Object
remove(Object key)
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
setRoot(Object value)
void
setRootEvaluation(Evaluation value)
void
setTraceEvaluations(boolean value)
void
setTypeConverter(TypeConverter value)
void
setValues(Map<String,Object> value)
int
size()
Collection<Object>
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 Detail
-
CONTEXT_CONTEXT_KEY
public static final String CONTEXT_CONTEXT_KEY
- See Also:
- Constant Field Values
-
ROOT_CONTEXT_KEY
public static final String ROOT_CONTEXT_KEY
- See Also:
- Constant Field Values
-
THIS_CONTEXT_KEY
public static final String THIS_CONTEXT_KEY
- See Also:
- Constant Field Values
-
TRACE_EVALUATIONS_CONTEXT_KEY
public static final String TRACE_EVALUATIONS_CONTEXT_KEY
- See Also:
- Constant Field Values
-
LAST_EVALUATION_CONTEXT_KEY
public static final String LAST_EVALUATION_CONTEXT_KEY
- See Also:
- Constant Field Values
-
KEEP_LAST_EVALUATION_CONTEXT_KEY
public static final String KEEP_LAST_EVALUATION_CONTEXT_KEY
- See Also:
- Constant Field Values
-
CLASS_RESOLVER_CONTEXT_KEY
public static final String CLASS_RESOLVER_CONTEXT_KEY
- See Also:
- Constant Field Values
-
TYPE_CONVERTER_CONTEXT_KEY
public static final String TYPE_CONVERTER_CONTEXT_KEY
- See Also:
- Constant Field Values
-
MEMBER_ACCESS_CONTEXT_KEY
public static final String MEMBER_ACCESS_CONTEXT_KEY
- See Also:
- Constant Field Values
-
DEFAULT_CLASS_RESOLVER
public static final DefaultClassResolver DEFAULT_CLASS_RESOLVER
-
DEFAULT_TYPE_CONVERTER
public static final TypeConverter DEFAULT_TYPE_CONVERTER
-
DEFAULT_MEMBER_ACCESS
public static final MemberAccess DEFAULT_MEMBER_ACCESS
-
-
Constructor Detail
-
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
public OgnlContext(ClassResolver classResolver, TypeConverter typeConverter, MemberAccess memberAccess, Map<String,Object> values)
-
-
Method Detail
-
setClassResolver
public void setClassResolver(ClassResolver value)
-
getClassResolver
public ClassResolver getClassResolver()
-
setTypeConverter
public void setTypeConverter(TypeConverter value)
-
getTypeConverter
public TypeConverter getTypeConverter()
-
setMemberAccess
public void setMemberAccess(MemberAccess value)
-
getMemberAccess
public MemberAccess getMemberAccess()
-
setRoot
public void setRoot(Object value)
-
getRoot
public Object getRoot()
-
getTraceEvaluations
public boolean getTraceEvaluations()
-
setTraceEvaluations
public void setTraceEvaluations(boolean value)
-
getLastEvaluation
public Evaluation getLastEvaluation()
-
setLastEvaluation
public void setLastEvaluation(Evaluation value)
-
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
public void setCurrentObject(Object value)
-
getCurrentObject
public Object getCurrentObject()
-
setCurrentAccessor
public void setCurrentAccessor(Class<?> type)
-
getCurrentAccessor
public Class<?> getCurrentAccessor()
-
getPreviousAccessor
public Class<?> getPreviousAccessor()
-
getFirstAccessor
public Class<?> getFirstAccessor()
-
getCurrentType
public Class<?> getCurrentType()
Gets the current class type being evaluated on the stack, as set bysetCurrentType(Class)
.- Returns:
- The current object type, may be null.
-
setCurrentType
public void setCurrentType(Class<?> type)
-
getPreviousType
public Class<?> 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
public void setPreviousType(Class<?> type)
-
getFirstType
public 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.
-
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.
-
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.
-
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 viapopEvaluation()
.
-
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.
-
incrementLocalReferenceCounter
public int incrementLocalReferenceCounter()
-
addLocalReference
public void addLocalReference(String key, LocalReference reference)
-
getLocalReferences
public Map<String,LocalReference> getLocalReferences()
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKey
in interfaceMap<String,Object>
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValue
in interfaceMap<String,Object>
-
equals
public boolean equals(Object o)
-
-