类 ContextTool

java.lang.Object
org.apache.velocity.tools.generic.SafeConfig
org.apache.velocity.tools.generic.ContextTool
直接已知子类:
ViewContextTool

@DefaultKey("context") @InvalidScope({"application","session"}) public class ContextTool extends SafeConfig

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
  • 字段详细资料

    • context

      protected org.apache.velocity.context.Context context
    • toolbox

      protected Map<String,Object> toolbox
  • 构造器详细资料

    • ContextTool

      public ContextTool()
  • 方法详细资料

    • configure

      protected void configure(ValueParser parser)
      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
    • getThis

      public org.apache.velocity.context.Context getThis()
      Returns the context being analyzed by this tool.
    • getToolbox

      public Map<String,Object> getToolbox()

      Returns a read-only view of the toolbox Map for this context.

      返回:
      a map of all available tools for this request or null if such a map is not available
    • getKeys

      public Set getKeys()

      Return a Set of the available reference keys in the current context.

    • fillKeyset

      protected void fillKeyset(Set keys)
      Actually do the work of filling in the set of keys for getKeys() here so subclasses can add keys too.
    • getValues

      public Set getValues()

      Return a Set of the available values in the current context.

    • contains

      public boolean contains(Object refName)

      Returns true if the context contains a value for the specified reference name (aka context key).

    • get

      public Object get(Object refName)
      Retrieves the value for the specified reference name (aka context key).