com.jgoodies.binding.value
Class ConverterValueModel

java.lang.Object
  extended by com.jgoodies.common.bean.Bean
      extended by com.jgoodies.binding.beans.Model
          extended by com.jgoodies.binding.value.AbstractValueModel
              extended by com.jgoodies.binding.value.AbstractWrappedValueModel
                  extended by com.jgoodies.binding.value.ConverterValueModel
All Implemented Interfaces:
ComponentModel, ComponentValueModel, ValueModel, com.jgoodies.common.bean.ObservableBean, com.jgoodies.common.bean.ObservableBean2, Serializable

public final class ConverterValueModel
extends AbstractWrappedValueModel

A ValueModel that converts the values of a wrapped ValueModel. The conversion is used when reading values, writing values, and in change notification.

More formally, a converting ValueModel VM1 converts the type T2 of an object being held as a value in one ValueModel VM2 into another type T1. When reading a value from VM1, instances of T2 are read from VM2 and are converted to T1. When storing a new value to VM1, the type converter will perform the inverse conversion and will convert an instance of T1 to T2.

Since:
2.7
Version:
$Revision: 1.15 $
Author:
Karsten Lentzsch
See Also:
ValueModel, Serialized Form

Field Summary
 
Fields inherited from class com.jgoodies.common.bean.Bean
changeSupport
 
Fields inherited from interface com.jgoodies.binding.value.ValueModel
PROPERTY_VALUE
 
Fields inherited from interface com.jgoodies.binding.value.ComponentModel
PROPERTY_EDITABLE, PROPERTY_ENABLED, PROPERTY_VISIBLE
 
Constructor Summary
ConverterValueModel(ValueModel source, BindingConverter converter)
          Constructs a ConverterValueModel on the given source ValueModel and BindingConverter.
 
Method Summary
 Object convertFromSubject(Object sourceValue)
          Converts a value from the subject to the type or format used by this converter.
protected  PropertyChangeListener createValueChangeHandler()
           
 Object getValue()
          Converts the subject's value and returns the converted value.
 void setValue(Object targetValue)
          Sets a new value and notifies any registered value listeners if the value has changed.
 
Methods inherited from class com.jgoodies.binding.value.AbstractWrappedValueModel
getWrappee, isEditable, isEnabled, isVisible, release, setEditable, setEnabled, setVisible
 
Methods inherited from class com.jgoodies.binding.value.AbstractValueModel
addValueChangeListener, booleanValue, doubleValue, fireValueChange, fireValueChange, fireValueChange, fireValueChange, fireValueChange, fireValueChange, fireValueChange, floatValue, getString, intValue, longValue, paramString, removeValueChangeListener, setValue, setValue, setValue, setValue, setValue, toString, valueString
 
Methods inherited from class com.jgoodies.binding.beans.Model
createPropertyChangeSupport, firePropertyChange
 
Methods inherited from class com.jgoodies.common.bean.Bean
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, fireMultiplePropertiesChanged, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, getPropertyChangeListeners, getPropertyChangeListeners, getVetoableChangeListeners, getVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.jgoodies.binding.value.ValueModel
addValueChangeListener, removeValueChangeListener
 
Methods inherited from interface com.jgoodies.common.bean.ObservableBean2
addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener
 
Methods inherited from interface com.jgoodies.common.bean.ObservableBean
addPropertyChangeListener, removePropertyChangeListener
 

Constructor Detail

ConverterValueModel

public ConverterValueModel(ValueModel source,
                           BindingConverter converter)
Constructs a ConverterValueModel on the given source ValueModel and BindingConverter.

Parameters:
source - the ValueModel that holds the source value
converter - converts source values to target values and vice versa
Throws:
NullPointerException - if source is null
Method Detail

convertFromSubject

public Object convertFromSubject(Object sourceValue)
Converts a value from the subject to the type or format used by this converter.

Parameters:
sourceValue - the source's value
Returns:
the converted value in the type or format used by this converter

setValue

public void setValue(Object targetValue)
Description copied from interface: ValueModel
Sets a new value and notifies any registered value listeners if the value has changed. In case of a read-only value implementors may choose to either reject this operation or to do nothing.

Parameters:
targetValue - the value to be set

getValue

public Object getValue()
Converts the subject's value and returns the converted value.

Returns:
the converted subject value

createValueChangeHandler

protected PropertyChangeListener createValueChangeHandler()
Specified by:
createValueChangeHandler in class AbstractWrappedValueModel


Copyright © 2002-2013 JGoodies Software GmbH. All Rights Reserved.