com.taursys.model
Class VOValueHolder

java.lang.Object
  extended bycom.taursys.model.AbstractValueHolder
      extended bycom.taursys.model.ObjectValueHolder
          extended bycom.taursys.model.VOValueHolder
All Implemented Interfaces:
javax.swing.event.ChangeListener, java.util.EventListener, java.beans.PropertyChangeListener, ValueHolder

public class VOValueHolder
extends ObjectValueHolder
implements java.beans.PropertyChangeListener

This is an implementation of ValueHolder which stores value in a ValueObject(JavaBean). This ValueHolder can be shared by multiple models and can access all/any properties of the ValueObject/JavaBean. For each property accessed, this object creates and uses a PropertyAccessor to manage the access process. For performance benefits, this class caches the PropertyAccessors after they have been created and reuses them for subsequent invocations.


Field Summary
 
Fields inherited from class com.taursys.model.ObjectValueHolder
obj
 
Constructor Summary
VOValueHolder()
          Constructs a new VOValueHolder.
 
Method Summary
 int getJavaDataType(java.lang.String propertyName)
          Returns the java data type for the given property
protected  PropertyAccessor getPropertyAccessor(java.lang.String propertyName)
          Returns existing PropertyAccessor for given propertyName else creates new one.
protected  java.util.Map getPropertyAccessors()
          Returns the map of PropertyAccessors which have been created so far.
 java.lang.Object getPropertyValue(java.lang.String propertyName)
          Returns the value of the given property in the obj.
protected  java.lang.Object getPropertyValue(java.lang.String propertyName, java.lang.Object vo)
          Get the value for the given property in the given obj.
protected  java.lang.Object[] getPropertyValues(java.lang.String[] propertyNames, java.lang.Object vo)
          Get the values for the given properties in the given obj.
 java.lang.Object getValueObject()
          Get the internal object for this holder.
 java.lang.Class getValueObjectClass()
          Returns the class of the value object.
 void propertyChange(java.beans.PropertyChangeEvent e)
          This method gets called when a bound property is changed.
 void setObject(java.lang.Object obj)
          Set the internal object for this holder.
 void setObject(java.lang.Object obj, javax.swing.event.ChangeEvent e)
          Set the internal object for this holder.
 void setPropertyValue(java.lang.String propertyName, java.lang.Object value)
          Set the value for the given property in the obj.
protected  void setPropertyValues(java.lang.String[] propertyNames, java.lang.Object[] values, java.lang.Object vo)
          Set the values for the given properties in the given obj.
protected  void setPropertyValues(java.lang.String propertyName, java.lang.Object value, java.lang.Object vo)
          Set the values for the given properties in the given obj.
 void setValueObject(java.lang.Object obj)
          Set the internal object for this holder.
 void setValueObject(java.lang.Object obj, javax.swing.event.ChangeEvent e)
          Set the internal object for this holder.
 void setValueObjectClass(java.lang.Class newValueObjectClass)
          Sets the class of the value object.
 java.lang.String toString()
          Returns a string representation of this object.
 
Methods inherited from class com.taursys.model.ObjectValueHolder
addChangeListener, fireContentValueChanged, getObject, getParentPropertyName, getParentValueHolder, setParentPropertyName, setParentValueHolder, stateChanged
 
Methods inherited from class com.taursys.model.AbstractValueHolder
checkArrays, fireStateChanged, getAlias, getPropertyValues, isMultiplePropertiesChanging, removeChangeListener, setAlias, setMultiplePropertiesChanging, setPropertyValues
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VOValueHolder

public VOValueHolder()
Constructs a new VOValueHolder.

Method Detail

getPropertyValue

public java.lang.Object getPropertyValue(java.lang.String propertyName)
                                  throws ModelException
Returns the value of the given property in the obj.

Specified by:
getPropertyValue in interface ValueHolder
Overrides:
getPropertyValue in class ObjectValueHolder
Parameters:
propertyName - ignored
Returns:
the internal value
Throws:
ModelException

setPropertyValue

public void setPropertyValue(java.lang.String propertyName,
                             java.lang.Object value)
                      throws ModelException
Set the value for the given property in the obj. Fires a StateChanged event to any listeners.

Specified by:
setPropertyValue in interface ValueHolder
Overrides:
setPropertyValue in class ObjectValueHolder
Throws:
ModelException

getJavaDataType

public int getJavaDataType(java.lang.String propertyName)
                    throws ModelException
Returns the java data type for the given property

Specified by:
getJavaDataType in interface ValueHolder
Overrides:
getJavaDataType in class ObjectValueHolder
Returns:
always returns DataTypes.TYPE_UNDEFINED (propertyName is ignored)
Throws:
ModelException

setObject

public void setObject(java.lang.Object obj)
Set the internal object for this holder. Also registers this ValueHolder as a bound property change listener if the internal object implements the BoundValueObject interface. Finally it fires a ContentChangeEvent to all ChangeListeners.

Overrides:
setObject in class ObjectValueHolder
Parameters:
obj - the internal object for this holder.

setObject

public void setObject(java.lang.Object obj,
                      javax.swing.event.ChangeEvent e)
Set the internal object for this holder. Also registers this ValueHolder as a bound property change listener if the internal object implements the BoundValueObject interface. Finally it fires the given ChangeEvent to all ChangeListeners (if it is not null).

Overrides:
setObject in class ObjectValueHolder
Parameters:
obj - the internal object for this holder.
e - ChangeEvent to fire to all ChangeListeners (if not null)

setValueObject

public void setValueObject(java.lang.Object obj)
Set the internal object for this holder. Also registers this ValueHolder as a bound property change listener if the internal object implements the BoundValueObject interface. Finally it fires a ContentChangeEvent to all ChangeListeners.

Parameters:
obj - the internal object for this holder.

setValueObject

public void setValueObject(java.lang.Object obj,
                           javax.swing.event.ChangeEvent e)
Set the internal object for this holder. Also registers this ValueHolder as a bound property change listener if the internal object implements the BoundValueObject interface. Finally it fires the given ChangeEvent to all ChangeListeners (if it is not null).

Parameters:
obj - the internal object for this holder.
e - ChangeEvent to fire to all ChangeListeners (if not null)

getValueObject

public java.lang.Object getValueObject()
Get the internal object for this holder.

Returns:
the internal object for this holder.

setValueObjectClass

public void setValueObjectClass(java.lang.Class newValueObjectClass)
Sets the class of the value object. Only needed if the obj itself can be null. If set, this takes presidence over the actual class of the obj.


getValueObjectClass

public java.lang.Class getValueObjectClass()
Returns the class of the value object. Only needed if the obj itself can be null. If set, this takes presidence over the actual class of the obj.


getPropertyValue

protected java.lang.Object getPropertyValue(java.lang.String propertyName,
                                            java.lang.Object vo)
                                     throws ModelException
Get the value for the given property in the given obj.

Overrides:
getPropertyValue in class ObjectValueHolder
Throws:
ModelException

getPropertyValues

protected java.lang.Object[] getPropertyValues(java.lang.String[] propertyNames,
                                               java.lang.Object vo)
                                        throws ModelException
Get the values for the given properties in the given obj.

Overrides:
getPropertyValues in class ObjectValueHolder
Throws:
ModelException

setPropertyValues

protected void setPropertyValues(java.lang.String propertyName,
                                 java.lang.Object value,
                                 java.lang.Object vo)
                          throws ModelException
Set the values for the given properties in the given obj. Fires a StateChanged event to any listeners.

Overrides:
setPropertyValues in class ObjectValueHolder
Throws:
ModelException

setPropertyValues

protected void setPropertyValues(java.lang.String[] propertyNames,
                                 java.lang.Object[] values,
                                 java.lang.Object vo)
                          throws ModelException
Set the values for the given properties in the given obj. Fires a StateChanged event to any listeners.

Overrides:
setPropertyValues in class ObjectValueHolder
Throws:
ModelException

getPropertyAccessor

protected PropertyAccessor getPropertyAccessor(java.lang.String propertyName)
                                        throws ModelException
Returns existing PropertyAccessor for given propertyName else creates new one.

Throws:
ModelException

getPropertyAccessors

protected java.util.Map getPropertyAccessors()
Returns the map of PropertyAccessors which have been created so far.


propertyChange

public void propertyChange(java.beans.PropertyChangeEvent e)
This method gets called when a bound property is changed. Notifies this value holder that a property of the value object has changed. This component will, in turn, notify all of its ChangeListeners with a ContentValueChangeEvent. The components will NOT be notified twice if the change was initiated through this component's setPropertyValue method.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener

toString

public java.lang.String toString()
Returns a string representation of this object. This contains the object identity and state information.

Overrides:
toString in class ObjectValueHolder
Returns:
a string representation of this object


Copyright © 2007 Martin T Phelan. All Rights Reserved.