freemarker.ext.misc
Class HashValues

java.lang.Object
  |
  +--freemarker.ext.misc.HashValues
All Implemented Interfaces:
TemplateMethodModel2, TemplateModel

public final class HashValues
extends java.lang.Object
implements TemplateMethodModel2

Determines the values of the underlying Map object given a TemplateObjectModel. Does this by calling the getAsObject method. If the object is of the expected type, the values are returned as a FastList. Otherwise, a TemplateModelException is thrown.

Usage:
From java:

 TemplateModelRoot root = new SimpleHash();

 root.put( "values", freemarker.ext.misc.HashValues.getInstance() );

 ...
 

From your FM-Classic template:

 <assign hash1 = { "test1", "value1",
                      "test2", "value2",
                      "test3", "value3" }>
 <assign valueList = values( hash1 )>
 <p>The values of hash1 are:</p>
 <p><foreach value in valueList>
 ${value}<br>
 </foreach></p>

 ...
 

Note:
HashValues is a singleton instance. Use the getInstance() method to retrieve instances of this model.

Since:
1.8
Version:
$Id: HashValues.java,v 1.1 2003/11/17 13:05:37 run2000 Exp $
Author:
Nicholas Cull

Method Summary
 TemplateModel exec(java.util.List arguments)
          Executes a method call.
static HashValues getInstance()
          Retrieve a singleton instance of this class.
 boolean isEmpty()
          Is the object empty?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static HashValues getInstance()
Retrieve a singleton instance of this class. Since there is no state information held between calls, there is only a need for one instance.
Returns:
an instance of this HashValues class

isEmpty

public boolean isEmpty()
                throws TemplateModelException
Is the object empty?
Specified by:
isEmpty in interface TemplateModel
Returns:
false, since the method is never empty

exec

public TemplateModel exec(java.util.List arguments)
                   throws TemplateModelException
Executes a method call. Arguments are passed as a List of TemplateModel objects.
Specified by:
exec in interface TemplateMethodModel2
Parameters:
arguments - a List of TemplateModel objects containing the values of the arguments passed to the method.
Returns:
the TemplateModel produced by the method, or null.