com.guiseframework.model
Class DefaultValueModel<V>

java.lang.Object
  extended by com.globalmentor.beans.BoundPropertyObject
      extended by com.guiseframework.model.AbstractModel
          extended by com.guiseframework.model.AbstractValueModel<V>
              extended by com.guiseframework.model.DefaultValueModel<V>
Type Parameters:
V - The type of value contained in the model.
All Implemented Interfaces:
com.globalmentor.beans.PropertyBindable, com.globalmentor.beans.PropertyConstrainable, Model, Valued<V>, ValueModel<V>
Direct Known Subclasses:
DefaultTreeNodeModel, Table.DefaultCellValueModel, ValuePrototype

public class DefaultValueModel<V>
extends AbstractValueModel<V>

A default implementation of a model representing a value.

Author:
Garret Wilson

Field Summary
 
Fields inherited from class com.globalmentor.beans.BoundPropertyObject
NO_PROPERTY_CHANGE_LISTENERS, NO_VETOABLE_CHANGE_LISTENERS
 
Fields inherited from interface com.guiseframework.model.ValueModel
VALIDATOR_PROPERTY, VALUE_PROPERTY
 
Fields inherited from interface com.guiseframework.model.Model
PLAIN_TEXT_CONTENT_TYPE, XHTML_CONTENT_TYPE, XHTML_FRAGMENT_CONTENT_TYPE
 
Constructor Summary
DefaultValueModel(java.lang.Class<V> valueClass)
          Constructs a value model indicating the type of value it can hold.
DefaultValueModel(java.lang.Class<V> valueClass, V defaultValue)
          Constructs a value model indicating the type of value it can hold, along with an initial value.
 
Method Summary
 void clearValue()
          Clears the value by setting the value to null, which may be invalid according to any installed validators.
 V getDefaultValue()
           
 V getValue()
           
 void resetValue()
          Resets the value to a default value, which may be invalid according to any installed validators.
 void setValue(V newValue)
          Sets the new value.
 
Methods inherited from class com.guiseframework.model.AbstractValueModel
createPropertyVetoException, getValidator, getValueClass, isValidValue, setValidator, validateValue
 
Methods inherited from class com.guiseframework.model.AbstractModel
getEventListenerManager, getPlainText
 
Methods inherited from class com.globalmentor.beans.BoundPropertyObject
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, createPostponedPropertyChangeEvent, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, getForwardPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeSupport, getRepeatPropertyChangeListener, getRepeatVetoableChangeListener, getVetoableChangeListeners, getVetoableChangeListeners, getVetoableChangeSupport, hasPropertyChangeListeners, hasVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.globalmentor.beans.PropertyBindable
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, hasPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
 
Methods inherited from interface com.globalmentor.beans.PropertyConstrainable
addVetoableChangeListener, addVetoableChangeListener, getVetoableChangeListeners, getVetoableChangeListeners, hasVetoableChangeListeners, removeVetoableChangeListener, removeVetoableChangeListener
 

Constructor Detail

DefaultValueModel

public DefaultValueModel(java.lang.Class<V> valueClass)
Constructs a value model indicating the type of value it can hold. The default value is set to null.

Parameters:
valueClass - The class indicating the type of value held in the model.
Throws:
java.lang.NullPointerException - if the given value class is null.

DefaultValueModel

public DefaultValueModel(java.lang.Class<V> valueClass,
                         V defaultValue)
Constructs a value model indicating the type of value it can hold, along with an initial value.

Parameters:
valueClass - The class indicating the type of value held in the model.
defaultValue - The default value, which will not be validated.
Throws:
java.lang.NullPointerException - if the given value class is null.
Method Detail

getDefaultValue

public V getDefaultValue()
Returns:
The default value.

getValue

public V getValue()
Returns:
The input value, or null if there is no input value.

setValue

public void setValue(V newValue)
              throws java.beans.PropertyVetoException
Sets the new value. This is a bound property that only fires a change event when the new value is different via the equals() method. If a validator is installed, the value will first be validated before the current value is changed. Validation always occurs if a validator is installed, even if the value is not changing. If the value change is vetoed by the installed validator, the validation exception will be accessible via Throwable.getCause().

Parameters:
newValue - The new value.
Throws:
java.beans.PropertyVetoException - if the provided value is not valid or the change has otherwise been vetoed.
See Also:
AbstractValueModel.getValidator(), ValueModel.VALUE_PROPERTY

clearValue

public void clearValue()
Clears the value by setting the value to null, which may be invalid according to any installed validators. No validation occurs.

See Also:
ValueModel.VALUE_PROPERTY

resetValue

public void resetValue()
Resets the value to a default value, which may be invalid according to any installed validators. No validation occurs.

See Also:
ValueModel.VALUE_PROPERTY


Copyright © 2005-2010 GlobalMentor, Inc. All Rights Reserved.