simple.page
Class Model

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap
          extended by simple.page.Model
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map

public class Model
extends java.util.HashMap

The Model is used to store all attributes that are to be passed into the page. This implements the Map interface in such a way that it allows attribute inheritance.

Author:
Niall Gallagher
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>
 
Constructor Summary
Model()
          Constructor for the Model object.
Model(java.util.Map root)
          Constructor for the Model object.
 
Method Summary
 java.lang.Object get(java.lang.Object key)
          Acquire the attribute referenced by the provided key.
 void write(java.io.PrintWriter out, java.lang.Object key)
          This method is used to write the value of the referenced value directly to the PrintWriter.
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

Model

public Model()
Constructor for the Model object. This is used to create an empty model, which acts much like a hash map.


Model

public Model(java.util.Map root)
Constructor for the Model object. This is used to create a model that inherits attributes from the provided map instance. If the map is null then it is ignored.

Parameters:
root - this is used to provide a base set of objects
Method Detail

get

public java.lang.Object get(java.lang.Object key)
Acquire the attribute referenced by the provided key. This is used to search for the attribute up the inheritance tree if the attribute is not found in any parent map null is returned.

Specified by:
get in interface java.util.Map
Overrides:
get in class java.util.HashMap
Parameters:
key - this is used to reference an attribute in the model
Returns:
this returns the attribute, or null if not found

write

public void write(java.io.PrintWriter out,
                  java.lang.Object key)
This method is used to write the value of the referenced value directly to the PrintWriter. This is used when the JSP references an inserted tile, but can also be used as a general purpose means for displaying a model property.

Parameters:
out - this is the print writer to write the property to
key - this is the name or key to the requested value