Package ognl
Class OgnlContext
- java.lang.Object
-
- ognl.OgnlContext
-
- All Implemented Interfaces:
java.util.Map
public class OgnlContext extends java.lang.Object implements java.util.MapThis class defines the execution context for an OGNL expression- Author:
- Luke Blanshard (blanshlu@netscape.net), Drew Davidson (drew@ognl.org)
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCLASS_RESOLVER_CONTEXT_KEYstatic java.lang.StringCONTEXT_CONTEXT_KEYstatic ClassResolverDEFAULT_CLASS_RESOLVERstatic MemberAccessDEFAULT_MEMBER_ACCESSstatic TypeConverterDEFAULT_TYPE_CONVERTERstatic java.lang.StringKEEP_LAST_EVALUATION_CONTEXT_KEYstatic java.lang.StringLAST_EVALUATION_CONTEXT_KEYstatic java.lang.StringMEMBER_ACCESS_CONTEXT_KEYstatic java.lang.StringROOT_CONTEXT_KEYstatic java.lang.StringTHIS_CONTEXT_KEYstatic java.lang.StringTRACE_EVALUATIONS_CONTEXT_KEYstatic java.lang.StringTYPE_CONVERTER_CONTEXT_KEY
-
Constructor Summary
Constructors Constructor Description OgnlContext()Constructs a new OgnlContext with the default class resolver, type converter and member access.OgnlContext(java.util.Map 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, java.util.Map values)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddLocalReference(java.lang.String key, LocalReference reference)voidclear()booleancontainsKey(java.lang.Object key)booleancontainsValue(java.lang.Object value)java.util.SetentrySet()booleanequals(java.lang.Object o)java.lang.Objectget(java.lang.Object key)ClassResolvergetClassResolver()java.lang.ClassgetCurrentAccessor()EvaluationgetCurrentEvaluation()Gets the current Evaluation from the top of the stack.NodegetCurrentNode()java.lang.ObjectgetCurrentObject()java.lang.ClassgetCurrentType()Gets the current class type being evaluated on the stack, as set bysetCurrentType(Class).EvaluationgetEvaluation(int relativeIndex)Returns the Evaluation at the relative index given.java.lang.ClassgetFirstAccessor()java.lang.ClassgetFirstType()booleangetKeepLastEvaluation()Returns true if the last evaluation that was done on this context is retained and available throughgetLastEvaluation().EvaluationgetLastEvaluation()java.util.MapgetLocalReferences()MemberAccessgetMemberAccess()java.lang.ClassgetPreviousAccessor()java.lang.ClassgetPreviousType()Represents the last known object type on the evaluation stack, will be the value of the last knowngetCurrentType().java.lang.ObjectgetRoot()EvaluationgetRootEvaluation()Gets the root of the evaluation stack.booleangetTraceEvaluations()TypeConvertergetTypeConverter()java.util.MapgetValues()inthashCode()intincrementLocalReferenceCounter()booleanisEmpty()java.util.SetkeySet()EvaluationpopEvaluation()Pops the current Evaluation off of the top of the stack.voidpushEvaluation(Evaluation value)Pushes a new Evaluation onto the stack.java.lang.Objectput(java.lang.Object key, java.lang.Object value)voidputAll(java.util.Map t)voidrecycleLastEvaluation()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.java.lang.Objectremove(java.lang.Object key)voidsetClassResolver(ClassResolver value)voidsetCurrentAccessor(java.lang.Class type)voidsetCurrentEvaluation(Evaluation value)voidsetCurrentNode(Node value)voidsetCurrentObject(java.lang.Object value)voidsetCurrentType(java.lang.Class type)voidsetKeepLastEvaluation(boolean value)Sets whether the last evaluation that was done on this context is retained and available throughgetLastEvaluation().voidsetLastEvaluation(Evaluation value)voidsetMemberAccess(MemberAccess value)voidsetPreviousType(java.lang.Class type)voidsetRoot(java.lang.Object value)voidsetRootEvaluation(Evaluation value)voidsetTraceEvaluations(boolean value)voidsetTypeConverter(TypeConverter value)voidsetValues(java.util.Map value)intsize()java.util.Collectionvalues()
-
-
-
Field Detail
-
CONTEXT_CONTEXT_KEY
public static final java.lang.String CONTEXT_CONTEXT_KEY
- See Also:
- Constant Field Values
-
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
-
CLASS_RESOLVER_CONTEXT_KEY
public static final java.lang.String CLASS_RESOLVER_CONTEXT_KEY
- See Also:
- Constant Field Values
-
TYPE_CONVERTER_CONTEXT_KEY
public static final java.lang.String TYPE_CONVERTER_CONTEXT_KEY
- See Also:
- Constant Field Values
-
MEMBER_ACCESS_CONTEXT_KEY
public static final java.lang.String MEMBER_ACCESS_CONTEXT_KEY
- See Also:
- Constant Field Values
-
DEFAULT_CLASS_RESOLVER
public static final ClassResolver 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(java.util.Map values)
-
OgnlContext
public OgnlContext(ClassResolver classResolver, TypeConverter typeConverter, MemberAccess memberAccess, java.util.Map values)
-
-
Method Detail
-
setValues
public void setValues(java.util.Map value)
-
getValues
public java.util.Map getValues()
-
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(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
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(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 bysetCurrentType(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 knowngetCurrentType().- 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.
-
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(java.lang.String key, LocalReference reference)
-
getLocalReferences
public java.util.Map getLocalReferences()
-
size
public int size()
- Specified by:
sizein interfacejava.util.Map
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfacejava.util.Map
-
containsKey
public boolean containsKey(java.lang.Object key)
- Specified by:
containsKeyin interfacejava.util.Map
-
containsValue
public boolean containsValue(java.lang.Object value)
- Specified by:
containsValuein interfacejava.util.Map
-
get
public java.lang.Object get(java.lang.Object key)
- Specified by:
getin interfacejava.util.Map
-
put
public java.lang.Object put(java.lang.Object key, java.lang.Object value)- Specified by:
putin interfacejava.util.Map
-
remove
public java.lang.Object remove(java.lang.Object key)
- Specified by:
removein interfacejava.util.Map
-
putAll
public void putAll(java.util.Map t)
- Specified by:
putAllin interfacejava.util.Map
-
clear
public void clear()
- Specified by:
clearin interfacejava.util.Map
-
keySet
public java.util.Set keySet()
- Specified by:
keySetin interfacejava.util.Map
-
values
public java.util.Collection values()
- Specified by:
valuesin interfacejava.util.Map
-
entrySet
public java.util.Set entrySet()
- Specified by:
entrySetin interfacejava.util.Map
-
equals
public boolean equals(java.lang.Object o)
- Specified by:
equalsin interfacejava.util.Map- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Specified by:
hashCodein interfacejava.util.Map- Overrides:
hashCodein classjava.lang.Object
-
-