|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object freemarker.ext.misc.HashKeys
public final class HashKeys
Determines the keyset of the underlying Map
object given a
TemplateObjectModel
. Does this by calling the
getAsObject
method. If the object is of the expected type,
the keyset is returned as a FastList
. Otherwise, a
TemplateModelException
is thrown.
Usage:
From java:
TemplateModelRoot root = new SimpleHash(); root.put( "keys", freemarker.ext.misc.HashKeys.getInstance() ); ...
From your FM-Classic template:
<assign hash1 = { "test1", "value1", "test2", "value2", "test3", "value3" }> <assign keyList = keys( hash1 )> <p>The keys of hash1 are:</p> <p><foreach key in keyList> ${key}<br> </foreach></p> ...
Note:
HashKeys
is a singleton instance. Use the
getInstance()
method to retrieve instances of this model.
Method Summary | |
---|---|
TemplateModel |
exec(java.util.List<TemplateModel> arguments)
Executes a method call. |
static HashKeys |
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 |
---|
public static HashKeys getInstance()
HashKeys
classpublic boolean isEmpty() throws TemplateModelException
isEmpty
in interface TemplateModel
false
, since the method is never empty
TemplateModelException
public TemplateModel exec(java.util.List<TemplateModel> arguments) throws TemplateModelException
List
of
TemplateModel
objects.
exec
in interface TemplateMethodModel2
arguments
- a List
of TemplateModel
objects
containing the values of the arguments passed to the method.
TemplateModel
produced by the method, or null
.
TemplateModelException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |