net.sourceforge.sillyview
Class StringBufferView

java.lang.Object
  extended by net.sourceforge.sillyview.StringBufferView
All Implemented Interfaces:
WidgetView

public class StringBufferView
extends Object
implements WidgetView

A StringBuffer that has a backing WidgetModel to provide its data. Useful mostly for debugging and servlets.


Field Summary
 
Fields inherited from interface net.sourceforge.sillyview.WidgetView
FALSE, TITLE, TRUE
 
Constructor Summary
StringBufferView(WidgetModel model)
          Creates a new StringBufferView instance.
 
Method Summary
 void addTokens(Map<Object,Object> props)
          Adds all the name/value pairs and then updates the model.
 boolean equals(Object o)
          Uses StringBuffer.equals() to test for equality.
 WidgetModel getModel()
          Returns the backing model.
 Object getValue(Object key)
          Gets the value of the named token.
 void setModel(WidgetModel newModel)
          Sets the backing model.
 void setToken(Object key, Object value)
          Sets the named token to the given value.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StringBufferView

public StringBufferView(WidgetModel model)
Creates a new StringBufferView instance.

Parameters:
model - a WidgetModel value
Method Detail

addTokens

public void addTokens(Map<Object,Object> props)
Adds all the name/value pairs and then updates the model. If the named token already exists, replace the value. This is more efficient than many calls to setToken(), because model.getCurrentModel is only called once.

Specified by:
addTokens in interface WidgetView
Parameters:
props - a Map value

setToken

public void setToken(Object key,
                     Object value)
Sets the named token to the given value. Most tokens will be propegated to the backing model. Resets the StringBuffer's contents to model.getCurrentModel().toString().

Specified by:
setToken in interface WidgetView
Parameters:
key - an Object value
value - an Object value

getValue

public Object getValue(Object key)
Gets the value of the named token. Most values will be taken from the backing model.

Specified by:
getValue in interface WidgetView
Parameters:
key - an Object value
Returns:
an Object value

getModel

public WidgetModel getModel()
Returns the backing model.

Specified by:
getModel in interface WidgetView
Returns:
a WidgetModel value

setModel

public void setModel(WidgetModel newModel)
Sets the backing model.

Specified by:
setModel in interface WidgetView
Parameters:
newModel - a WidgetModel value

equals

public boolean equals(Object o)
Uses StringBuffer.equals() to test for equality.

Overrides:
equals in class Object
Parameters:
o - an Object value
Returns:
a boolean value

toString

public String toString()
Overrides:
toString in class Object