org.riotfamily.components.model.wrapper
Class ValueWrapper<T>

java.lang.Object
  extended by org.riotfamily.components.model.wrapper.ValueWrapper<T>
Direct Known Subclasses:
BooleanWrapper, ComponentListWrapper, DateWrapper, EntityWrapper, ListWrapper, MapWrapper, NumberWrapper, PageWrapper, RiotFileWrapper, StringWrapper

public abstract class ValueWrapper<T>
extends Object

Since:
7.0
Author:
Felix Gnass [fgnass at neteye dot de]

Constructor Summary
ValueWrapper()
           
 
Method Summary
abstract  ValueWrapper<T> deepCopy()
          Creates a deep copy.
 void each(ValueCallback callback)
           
 boolean equals(Object obj)
          Delegates the call to the equals method of the wrapped object.
 Long getId()
           
abstract  T getValue()
          Returns the value that is passed to the form element when the value is edited.
 int hashCode()
          Delegates the call to the hashCode method of the wrapped object.
 void setId(Long id)
           
abstract  void setValue(T value)
           
 String toString()
          Delegates the call to the toString method of the wrapped object.
 T unwrap()
          Returns the wrapped value.
 void wrap(Object value)
          Wraps the given value.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ValueWrapper

public ValueWrapper()
Method Detail

getId

public Long getId()

setId

public void setId(Long id)

wrap

public void wrap(Object value)
Wraps the given value. The default implementation delegates the call to setValue(Object).


unwrap

public T unwrap()
Returns the wrapped value. The default implementation delegates the call to getValue(). Subclasses that wrap complex values (values with nested wrappers) must overwrite this method to perform a "deep-unwrapping".


getValue

public abstract T getValue()
Returns the value that is passed to the form element when the value is edited. Subclasses will usually return the wrapped value, except for complex wrappers (like ListWrapper and MapWrapper) which return a self-reference.


setValue

public abstract void setValue(T value)

deepCopy

public abstract ValueWrapper<T> deepCopy()
Creates a deep copy. Subclasses will usually just create a new wrapper instance and and invoke setValue(Object) with the value returned by getValue(). Complex wrappers have to make sure that the deepCopy method is invoked for all nested values too.


each

public void each(ValueCallback callback)

hashCode

public int hashCode()
Delegates the call to the hashCode method of the wrapped object.

Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Delegates the call to the equals method of the wrapped object.

Overrides:
equals in class Object

toString

public String toString()
Delegates the call to the toString method of the wrapped object.

Overrides:
toString in class Object