Interface VelocityContext
-
public interface VelocityContext
Context used to provide named objects to Velocity templates as they are they are used to render output. Objects stored in context are available to templates as they are rendered using variable references like '$variable'. See http://velocity.apache.org/ for more information on using Velocity.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
containsKey(java.lang.Object key)
Indicates whether a named object exists in this context for a given key.java.lang.Object
get(java.lang.String key)
Gets the named object associated with a given key.java.lang.Object[]
getKeys()
Obtains an array of all keys for this context.boolean
isPermitOverrides()
Indicates whether a call toput
will update this context if a value already exists in the context by the specified key.java.lang.Object
put(java.lang.String key, java.lang.Object value)
Adds a named object to this context.java.lang.Object
remove(java.lang.Object key)
Removes the value associated with the specified key from the context.
-
-
-
Method Detail
-
isPermitOverrides
boolean isPermitOverrides()
Indicates whether a call toput
will update this context if a value already exists in the context by the specified key.- Returns:
- boolean where true indicates overrides are permitted.
-
put
java.lang.Object put(java.lang.String key, java.lang.Object value)
Adds a named object to this context. If overrides are not permitted and an object already exists in this context for the given key this method will throw a runtime exception. Following a successful call to this method, the object will be available to templates using a reference like '$key'.- Parameters:
key
- The key with which to store the object in context. Keys prefixed with a '_' are reserved for internal use. Attempting to set a named object using a key prefixed with '_' will throw a runtime exception. Likewise attempting to put a named object in this context with a previously used key in which overrides are not permitted with throw a runtime exception.value
- The context value.- Returns:
- The old object or null if there was no old object.
-
get
java.lang.Object get(java.lang.String key)
Gets the named object associated with a given key.- Parameters:
key
- associated with the named object.- Returns:
- The associated named object within this context or
null
if no object exists for the given key.
-
containsKey
boolean containsKey(java.lang.Object key)
Indicates whether a named object exists in this context for a given key.- Parameters:
key
- to use for checking whether an associated object exists in this context.- Returns:
- boolean where true indicates a named object exists for the given key.
-
getKeys
java.lang.Object[] getKeys()
Obtains an array of all keys for this context.- Returns:
- array of all keys for this context.
-
remove
java.lang.Object remove(java.lang.Object key)
Removes the value associated with the specified key from the context.- Parameters:
key
- The name of the value to remove.- Returns:
- The value the key was mapped to, or
null
the key was not previously associated with any named object in this context.
-
-