net.sourceforge.sillyview
Class StringBufferView

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

public class StringBufferView
extends java.lang.Object
implements WidgetView

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

Version:
1.0
Author:
T.J. Willis

Field Summary
private  java.lang.StringBuffer buf
          This view's data.
private  WidgetModel mod
          The model this view gets its data from.
 
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(java.util.Map<java.lang.Object,java.lang.Object> props)
          Adds all the name/value pairs and then updates the model.
 boolean equals(java.lang.Object o)
          Uses StringBuffer.equals() to test for equality.
 WidgetModel getModel()
          Returns the backing model.
 java.lang.Object getValue(java.lang.Object key)
          Gets the value of the named token.
 void setModel(WidgetModel newModel)
          Sets the backing model.
 void setToken(java.lang.Object key, java.lang.Object value)
          Sets the named token to the given value.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

buf

private java.lang.StringBuffer buf
This view's data.


mod

private WidgetModel mod
The model this view gets its data from.

Constructor Detail

StringBufferView

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

Parameters:
model - a WidgetModel value
Method Detail

addTokens

public void addTokens(java.util.Map<java.lang.Object,java.lang.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(java.lang.Object key,
                     java.lang.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 java.lang.Object getValue(java.lang.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(java.lang.Object o)
Uses StringBuffer.equals() to test for equality.

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