类 ContextTool
java.lang.Object
org.apache.velocity.tools.generic.SafeConfig
org.apache.velocity.tools.generic.ContextTool
- 所有已实现的接口:
Serializable
@DefaultKey("context")
@InvalidScope({"application","session"})
public class ContextTool
extends SafeConfig
implements Serializable
Tool for convenient access to Context data and
meta-data.
Template example(s):
#foreach( $key in $context.keys )
$key = $context.get($key)
#end
Toolbox configuration:
<tools>
<toolbox scope="request">
<tool class="org.apache.velocity.tools.generic.ContextTool"/>
</toolbox>
</tools>
This class is only designed for use as a request-scope tool.
- 从以下版本开始:
- VelocityTools 2.0
- 版本:
- $Id: ContextTool.java 385122 2006-03-11 18:37:42Z nbubna $
- 作者:
- Nathan Bubna
- 另请参阅:
-
字段概要
字段修饰符和类型字段说明protected org.apache.velocity.context.Context从类继承的字段 org.apache.velocity.tools.generic.SafeConfig
LOCK_CONFIG_KEY, log, LOGGER_NAME_KEY, SAFE_MODE_KEY, USE_CLASS_LOGGER_KEY -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明protected voidconfigure(ValueParser parser) Initializes this instance for the current request.booleanReturnstrueif the context contains a value for the specified reference name (aka context key).protected voidfillKeyset(Set keys) Actually do the work of filling in the set of keys forgetKeys()here so subclasses can add keys too.Retrieves the value for the specified reference name (aka context key).getKeys()Return aSetof the available reference keys in the current context.org.apache.velocity.context.ContextgetThis()Returns the context being analyzed by this tool.Returns a read-only view of the toolboxMapfor this context.Return aSetof the available values in the current context.从类继承的方法 org.apache.velocity.tools.generic.SafeConfig
configure, getLog, initLogger, isConfigLocked, isSafeMode, setLockConfig, setSafeMode
-
字段详细资料
-
context
protected org.apache.velocity.context.Context context -
toolbox
-
-
构造器详细资料
-
ContextTool
public ContextTool()
-
-
方法详细资料
-
configure
Initializes this instance for the current request. Also looks for a safe-mode configuration setting. By default, safeMode is true and thus keys with '.' in them are hidden.- 覆盖:
configure在类中SafeConfig- 参数:
parser- configuration values
-
getThis
public org.apache.velocity.context.Context getThis()Returns the context being analyzed by this tool.- 返回:
- analyzed context
-
getToolbox
Returns a read-only view of the toolbox
Mapfor this context.- 返回:
- a map of all available tools for this request
or
nullif such a map is not available
-
getKeys
Return a
Setof the available reference keys in the current context.- 返回:
- keys set
-
fillKeyset
Actually do the work of filling in the set of keys forgetKeys()here so subclasses can add keys too.- 参数:
keys- set to fill with keys
-
getValues
Return a
Setof the available values in the current context.- 返回:
- values set
-
contains
Returns
trueif the context contains a value for the specified reference name (aka context key).- 参数:
refName- context key- 返回:
trueif key is present in the context
-
get
Retrieves the value for the specified reference name (aka context key).- 参数:
refName- context key- 返回:
- found value, or null
-