|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--freemarker.template.SimpleHash
A simple implementation of the TemplateHashModelEx and TemplateModelRoot interfaces, using an underlying HashMap.
Note:
As of 2.0, this class is unsynchronized by default. To obtain a
synchronized wrapper, call the synchronizedWrapper()
method.
SimpleList
,
SimpleScalar
, Serialized FormField Summary | |
protected java.util.HashMap |
hash
|
Constructor Summary | |
SimpleHash()
Constructs an empty SimpleHash. |
|
SimpleHash(java.util.Map map)
Constructs a SimpleHash given the backing Map. |
Method Summary | |
TemplateModel |
get(java.lang.String key)
Gets a TemplateModel from the underlying hash. |
java.util.Locale |
getLocale()
gets the locale to be used for number/date formatting (A hook for later user currently -- revusky) |
boolean |
isEmpty()
Is the underlying hash empty? |
TemplateSequenceModel |
keys()
|
void |
put(java.lang.String key,
boolean b)
Puts a boolean in the hash, by first wrapping the boolean in a SimpleScalar. |
void |
put(java.lang.String key,
java.lang.Number num)
|
void |
put(java.lang.String key,
java.lang.String s)
Puts a string in the hash, by first wrapping the string in a SimpleScalar. |
void |
put(java.lang.String key,
TemplateModel model)
Puts a TemplateModel in the hash. |
void |
remove(java.lang.String key)
Removes the given key from the underlying hash. |
void |
setLocale(java.util.Locale locale)
sets the locale to be used for number/date formatting (A hook for later user currently -- revusky) |
int |
size()
|
SimpleHash |
synchronizedWrapper()
|
java.lang.String |
toString()
Convenience method for returning the String value of the underlying hash. |
TemplateSequenceModel |
values()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected java.util.HashMap hash
Constructor Detail |
public SimpleHash()
public SimpleHash(java.util.Map map)
hash
- The Map to use as the backing for this SimpleHash.Method Detail |
public boolean isEmpty() throws TemplateModelException
isEmpty
in interface TemplateModel
freemarker.template.TemplateModel
public void put(java.lang.String key, TemplateModel model)
put
in interface TemplateModelRoot
key
- the name by which the TemplateModel is
identified in the template.model
- the TemplateModel to store.public void put(java.lang.String key, java.lang.String s)
key
- the name by which the resulting TemplateModel
is identified in the template.s
- the string to store.public void put(java.lang.String key, boolean b)
key
- the name by which the resulting TemplateModel
is identified in the template.b
- the boolean to store.public void put(java.lang.String key, java.lang.Number num)
public TemplateModel get(java.lang.String key) throws TemplateModelException
get
in interface TemplateHashModel
key
- the name by which the TemplateModel
is identified in the template.public void remove(java.lang.String key)
remove
in interface TemplateModelRoot
key
- the key to be removedpublic java.lang.String toString()
toString
in class java.lang.Object
public void setLocale(java.util.Locale locale)
TemplateModelRoot
setLocale
in interface TemplateModelRoot
public java.util.Locale getLocale()
TemplateModelRoot
getLocale
in interface TemplateModelRoot
public int size() throws TemplateModelException
size
in interface TemplateHashModelEx
freemarker.template.TemplateHashModelEx
public TemplateSequenceModel keys() throws TemplateModelException
keys
in interface TemplateHashModelEx
freemarker.template.TemplateHashModelEx
public TemplateSequenceModel values() throws TemplateModelException
values
in interface TemplateHashModelEx
freemarker.template.TemplateHashModelEx
public SimpleHash synchronizedWrapper()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |