org.springframework.binding.value.support
Class TypeConverter

Show UML class diagram
java.lang.Object
  extended by org.springframework.binding.value.support.AbstractValueModelWrapper
      extended by org.springframework.binding.value.support.TypeConverter
All Implemented Interfaces:
DerivedValueModel, ValueModelWrapper, ValueModel

public class TypeConverter
extends AbstractValueModelWrapper
implements DerivedValueModel

A value model wrapper that supports converting the wrapped value to and from another type using the supplied conversion Closures.

Author:
Keith Donald, Oliver Hutchison

Field Summary
 
Fields inherited from interface org.springframework.binding.value.ValueModel
VALUE_PROPERTY
 
Constructor Summary
TypeConverter(ValueModel wrappedModel, Closure convertTo, Closure convertFrom)
          Constructor which uses Closure blocks to convert between values.
TypeConverter(ValueModel wrappedModel, org.springframework.binding.convert.ConversionExecutor convertTo, org.springframework.binding.convert.ConversionExecutor convertFrom)
          Convenience constructor using conversionExecutors.
 
Method Summary
 ValueModel[] getSourceValueModels()
          Returns an array of all values models that are used to derive the value represented by this value model.
 Object getValue()
          Returns this model's value.
protected  ValueChangeDetector getValueChangeDetector()
           
 boolean isReadOnly()
          Returns true if the implementation does not support calls setValue.
 void setValueChangeDetector(ValueChangeDetector valueChangeDetector)
           
 void setValueSilently(Object value, PropertyChangeListener listenerToSkip)
          Sets a new value and if the value has changed notifies all registered value change listeners except for the specified listener to skip.
 
Methods inherited from class org.springframework.binding.value.support.AbstractValueModelWrapper
addValueChangeListener, getInnerMostValue, getInnerMostWrappedValueModel, getWrappedValueModel, removeValueChangeListener, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.springframework.binding.value.ValueModel
addValueChangeListener, removeValueChangeListener, setValue
 

Constructor Detail

TypeConverter

public TypeConverter(ValueModel wrappedModel,
                     org.springframework.binding.convert.ConversionExecutor convertTo,
                     org.springframework.binding.convert.ConversionExecutor convertFrom)
Convenience constructor using conversionExecutors.

Parameters:
wrappedModel - the inner valueModel
convertTo - conversion to use when setting a value.
convertFrom - conversion to use when getting a value.
See Also:
TypeConverter(ValueModel, Closure, Closure)

TypeConverter

public TypeConverter(ValueModel wrappedModel,
                     Closure convertTo,
                     Closure convertFrom)
Constructor which uses Closure blocks to convert between values.

Parameters:
wrappedModel - the inner valueModel
convertTo - Closure to execute when setting a value.
convertFrom - Closure to execute when getting a value.
Method Detail

getValue

public Object getValue()
                throws IllegalArgumentException
Returns this model's value. In case of a write-only value, implementers may choose to either reject this operation or or return null or any other appropriate value. Value from inner model will be converted using the supplied convertFrom closure.

Specified by:
getValue in interface ValueModel
Overrides:
getValue in class AbstractValueModelWrapper
Returns:
this model's value
Throws:
IllegalArgumentException

setValueSilently

public void setValueSilently(Object value,
                             PropertyChangeListener listenerToSkip)
                      throws IllegalArgumentException
Description copied from interface: ValueModel
Sets a new value and if the value has changed notifies all registered value change listeners except for the specified listener to skip.

Specified by:
setValueSilently in interface ValueModel
Overrides:
setValueSilently in class AbstractValueModelWrapper
Parameters:
value - the value to be set
listenerToSkip - the PropertyChangeListener that should not be notified of this change (may be null).
Throws:
IllegalArgumentException

getSourceValueModels

public ValueModel[] getSourceValueModels()
Description copied from interface: DerivedValueModel
Returns an array of all values models that are used to derive the value represented by this value model.

Specified by:
getSourceValueModels in interface DerivedValueModel

isReadOnly

public boolean isReadOnly()
Description copied from interface: DerivedValueModel
Returns true if the implementation does not support calls setValue.

Specified by:
isReadOnly in interface DerivedValueModel

setValueChangeDetector

public void setValueChangeDetector(ValueChangeDetector valueChangeDetector)

getValueChangeDetector

protected ValueChangeDetector getValueChangeDetector()


Copyright © 2004-2009 The Spring Framework. All Rights Reserved.