| 
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectfreemarker.template.SimpleHash
public class SimpleHash
A synchronized implementation of the TemplateHashModel and
 TemplateModelRoot interfaces, using an underlying
 Map.
All the public methods in this implementation are synchronized.
SimpleList, 
SimpleScalar, 
SimpleNumber, 
Serialized Form| Field Summary | |
|---|---|
protected  java.util.Map<java.lang.String,TemplateModel> | 
hash
The contents of this SimpleHash are stored in this
 Map object. | 
| Constructor Summary | |
|---|---|
SimpleHash()
Constructs an empty SimpleHash. | 
|
SimpleHash(java.util.Map<java.lang.String,? extends TemplateModel> hash)
Constructs a SimpleHash given a Map of
 values. | 
|
| Method Summary | |
|---|---|
 boolean | 
equals(java.lang.Object o)
Tests this object for equality with the given object.  | 
 TemplateModel | 
get(java.lang.String key)
Gets a TemplateModel from the underlying hash. | 
 java.lang.Object | 
getAsObject()
Return an unmodifiable copy of the underlying Map object
 for manipulation by the freemarker.ext.beans package. | 
 int | 
hashCode()
Return the hash value for this object.  | 
 boolean | 
isEmpty()
Is the underlying Map empty? | 
 void | 
put(java.lang.String key,
    boolean value)
Puts a boolean in the hash, by first wrapping the boolean in a FastBoolean. | 
 void | 
put(java.lang.String key,
    long value)
Puts a number in the hash, by first wrapping the string in a FastNumber. | 
 void | 
put(java.lang.String key,
    java.lang.Number value)
Puts a number in the hash, by first wrapping the string in a FastNumber. | 
 void | 
put(java.lang.String key,
    java.lang.String value)
Puts a string in the hash, by first wrapping the string in a FastScalar. | 
 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 Map. | 
 java.lang.String | 
toString()
Convenience method for returning the String value of the
 underlying hash. | 
| Methods inherited from class java.lang.Object | 
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait | 
| Field Detail | 
|---|
protected java.util.Map<java.lang.String,TemplateModel> hash
SimpleHash are stored in this
 Map object.
| Constructor Detail | 
|---|
public SimpleHash()
SimpleHash.
public SimpleHash(java.util.Map<java.lang.String,? extends TemplateModel> hash)
SimpleHash given a Map of
 values. A defensive copy of the map is taken.
hash - The Map of values to be copied into this
 SimpleHash.
java.lang.NullPointerException - the map value is null| Method Detail | 
|---|
public boolean isEmpty()
                throws TemplateModelException
Map empty?
isEmpty in interface TemplateModeltrue if the Map is empty, otherwise
 false
TemplateModelException
public void put(java.lang.String key,
                TemplateModel model)
TemplateModel in the hash.
put in interface TemplateModelRootput in interface TemplateWriteableHashModelkey - 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 value)
FastScalar.
key - the name by which the resulting TemplateModel
 is identified in the template.value - the string to store.
public void put(java.lang.String key,
                java.lang.Number value)
FastNumber.
key - the name by which the resulting TemplateModel
 is identified in the template.value - the number to store.
public void put(java.lang.String key,
                long value)
FastNumber.
key - the name by which the resulting TemplateModel
 is identified in the template.value - the number to store.
public void put(java.lang.String key,
                boolean value)
FastBoolean.
key - the name by which the resulting TemplateModel
 is identified in the template.value - the boolean to store.
public TemplateModel get(java.lang.String key)
                  throws TemplateModelException
TemplateModel from the underlying hash.
get in interface TemplateHashModelkey - the name by which the TemplateModel
 is identified in the template.
TemplateModel referred to by the key,
 or null if not found.
TemplateModelException - there was a problem getting the value
 for the given keypublic void remove(java.lang.String key)
Map.
remove in interface TemplateModelRootkey - the key to be removed
public java.lang.Object getAsObject()
                             throws TemplateModelException
Map object
 for manipulation by the freemarker.ext.beans package.
getAsObject in interface TemplateObjectModelMap object
TemplateModelException - the object could not be returnedpublic java.lang.String toString()
String value of the
 underlying hash.
toString in class java.lang.Objectpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objecto - the object to be compared against
true if the objects are equal, otherwise
  falsepublic int hashCode()
hashCode in class java.lang.Object
  | 
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||