Package org.apache.velocity.example
Class TreeMapContext
- java.lang.Object
-
- org.apache.velocity.context.AbstractContext
-
- org.apache.velocity.example.TreeMapContext
-
- All Implemented Interfaces:
Context
,InternalEventContext
public class TreeMapContext extends AbstractContext
Example context impl that uses a TreeMap Not much point other than to show how easy it is. This is unsupported, example code.- Version:
- $Id$
- Author:
- Geir Magnusson Jr.
-
-
Constructor Summary
Constructors Constructor Description TreeMapContext()
TreeMapContext(Context inner)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EventCartridge
attachEventCartridge(EventCartridge ec)
int
getCurrentMacroCallDepth()
get the current macro call depthString
getCurrentMacroName()
get the current macro nameResource
getCurrentResource()
String
getCurrentTemplateName()
get the current template nameEventCartridge
getEventCartridge()
List<Template>
getMacroLibraries()
String[]
getMacroNameStack()
get the current macro name stackString[]
getTemplateNameStack()
get the current template name stackIntrospectionCacheData
icacheGet(Object key)
returns an IntrospectionCache Data (@see IntrospectionCacheData) object if exists for the keyvoid
icachePut(Object key, IntrospectionCacheData o)
places an IntrospectionCache Data (@see IntrospectionCacheData) element in the cache for specified keyboolean
internalContainsKey(String key)
Implement to determine if a key is in the storage.Object
internalGet(String key)
Implement to return a value from the context storage.String[]
internalGetKeys()
Implement to return an object array of key strings from your storage.Object
internalPut(String key, Object value)
Implement to put a value into the context storage.Object
internalRemove(String key)
Implement to remove an item from your storage.void
popCurrentMacroName()
remove the current macro name from stackvoid
popCurrentTemplateName()
remove the current template name from stackvoid
pushCurrentMacroName(String s)
set the current macro name on top of stackvoid
pushCurrentTemplateName(String s)
set the current template name on top of stackvoid
setCurrentResource(Resource r)
void
setMacroLibraries(List<Template> macroLibraries)
-
Methods inherited from class org.apache.velocity.context.AbstractContext
containsKey, get, getChainedContext, getKeys, put, remove
-
-
-
-
Constructor Detail
-
TreeMapContext
public TreeMapContext()
-
TreeMapContext
public TreeMapContext(Context inner)
-
-
Method Detail
-
internalGet
public Object internalGet(String key)
Description copied from class:AbstractContext
Implement to return a value from the context storage.
The implementation of this method is required for proper operation of a Context implementation in general Velocity use.- Specified by:
internalGet
in classAbstractContext
- Parameters:
key
- key whose associated value is to be returned- Returns:
- object stored in the context
-
internalPut
public Object internalPut(String key, Object value)
Description copied from class:AbstractContext
Implement to put a value into the context storage.
The implementation of this method is required for proper operation of a Context implementation in general Velocity use.- Specified by:
internalPut
in classAbstractContext
- Parameters:
key
- key with which to associate the valuevalue
- value to be associated with the key- Returns:
- previously stored value if exists, or null
-
internalContainsKey
public boolean internalContainsKey(String key)
Description copied from class:AbstractContext
Implement to determine if a key is in the storage.
Currently, this method is not used internally by the Velocity engine.- Specified by:
internalContainsKey
in classAbstractContext
- Parameters:
key
- key to test for existence- Returns:
- true if found, false if not
-
internalGetKeys
public String[] internalGetKeys()
Description copied from class:AbstractContext
Implement to return an object array of key strings from your storage.
Currently, this method is not used internally by the Velocity engine.- Specified by:
internalGetKeys
in classAbstractContext
- Returns:
- array of keys
-
internalRemove
public Object internalRemove(String key)
Description copied from class:AbstractContext
Implement to remove an item from your storage.
Currently, this method is not used internally by the Velocity engine.- Specified by:
internalRemove
in classAbstractContext
- Parameters:
key
- key to remove- Returns:
- object removed if exists, else null
-
pushCurrentTemplateName
public void pushCurrentTemplateName(String s)
set the current template name on top of stack- Parameters:
s
- current template name
-
popCurrentTemplateName
public void popCurrentTemplateName()
remove the current template name from stack
-
getCurrentTemplateName
public String getCurrentTemplateName()
get the current template name- Returns:
- String current template name
-
getTemplateNameStack
public String[] getTemplateNameStack()
get the current template name stack- Returns:
- String[] with the template name stack contents.
-
pushCurrentMacroName
public void pushCurrentMacroName(String s)
set the current macro name on top of stack- Parameters:
s
- current macro name
-
popCurrentMacroName
public void popCurrentMacroName()
remove the current macro name from stack
-
getCurrentMacroName
public String getCurrentMacroName()
get the current macro name- Returns:
- String current macro name
-
getCurrentMacroCallDepth
public int getCurrentMacroCallDepth()
get the current macro call depth- Returns:
- int current macro call depth
-
getMacroNameStack
public String[] getMacroNameStack()
get the current macro name stack- Returns:
- String[] with the macro name stack contents.
-
icacheGet
public IntrospectionCacheData icacheGet(Object key)
returns an IntrospectionCache Data (@see IntrospectionCacheData) object if exists for the key- Parameters:
key
- key to find in cache- Returns:
- cache object
-
icachePut
public void icachePut(Object key, IntrospectionCacheData o)
places an IntrospectionCache Data (@see IntrospectionCacheData) element in the cache for specified key- Parameters:
key
- keyo
- IntrospectionCacheData object to place in cache
-
setCurrentResource
public void setCurrentResource(Resource r)
- See Also:
InternalHousekeepingContext.setCurrentResource(org.apache.velocity.runtime.resource.Resource)
-
getCurrentResource
public Resource getCurrentResource()
- See Also:
InternalHousekeepingContext.getCurrentResource()
-
setMacroLibraries
public void setMacroLibraries(List<Template> macroLibraries)
- See Also:
InternalHousekeepingContext.setMacroLibraries(List)
-
getMacroLibraries
public List<Template> getMacroLibraries()
- See Also:
InternalHousekeepingContext.getMacroLibraries()
-
attachEventCartridge
public EventCartridge attachEventCartridge(EventCartridge ec)
- Specified by:
attachEventCartridge
in interfaceInternalEventContext
- Returns:
- The old EventCartridge.
- See Also:
InternalEventContext.attachEventCartridge(org.apache.velocity.app.event.EventCartridge)
-
getEventCartridge
public EventCartridge getEventCartridge()
- Specified by:
getEventCartridge
in interfaceInternalEventContext
- Returns:
- The current EventCartridge.
- See Also:
InternalEventContext.getEventCartridge()
-
-