com.taursys.model
Class PropertyAdapter

java.lang.Object
  extended bycom.taursys.model.PropertyAdapter

public class PropertyAdapter
extends java.lang.Object

Sets the name of the property in the valueObject to use. This is the property that get/setObject and get/setText methods will access. The property name should follow JavaBean conventions.

Example: propertyName="color": then it expects getColor and setColor will be the method names in the valueObject.

NOTE: Setting the propertyName will only have effect BEFORE the setAccessorMethods process is invoked. Once the accessor methods have been set, subsequent changes to this property will have no effect.


Constructor Summary
PropertyAdapter(java.lang.Class valueObjectClass, java.lang.String propertyName)
           
 
Method Summary
protected  java.beans.PropertyDescriptor getProperty(java.lang.Class c, java.lang.String propName)
          Searches the given class for the given property name and returns the PropertyDescriptor.
 java.lang.String getPropertyName()
          Returns the name of the property in the valueObject to use.
 java.lang.Object getPropertyValue(java.lang.Object valueObject)
          Returns a property value from the valueObject based on the propertyName.
protected  java.lang.reflect.Method[] getReadMethods()
          Returns the Methods used to get/read the target property.
 java.lang.String getText(java.lang.Object valueObject, java.text.Format format)
          Returns the accessed Object as a String value using Format if defined.
protected  java.lang.reflect.Method getWriteMethod()
          Returns the Method used to get/read the target property.
 void setPropertyValue(java.lang.Object valueObject, java.lang.Object value)
          Sets a property of the valueObject to the given value based on the propertyName.
 void setText(java.lang.Object target, java.lang.String value, java.text.Format format)
          Sets the accessed Object from the given String value to DataType using Format(if defined) to parse.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertyAdapter

public PropertyAdapter(java.lang.Class valueObjectClass,
                       java.lang.String propertyName)
                throws java.beans.IntrospectionException,
                       java.lang.reflect.InvocationTargetException,
                       java.lang.IllegalAccessException
Method Detail

getProperty

protected java.beans.PropertyDescriptor getProperty(java.lang.Class c,
                                                    java.lang.String propName)
                                             throws java.beans.IntrospectionException
Searches the given class for the given property name and returns the PropertyDescriptor. Throws IntrospectionException if property is not found.

Throws:
java.beans.IntrospectionException

getText

public java.lang.String getText(java.lang.Object valueObject,
                                java.text.Format format)
                         throws java.beans.IntrospectionException,
                                java.lang.reflect.InvocationTargetException,
                                java.lang.IllegalAccessException
Returns the accessed Object as a String value using Format if defined. If the accessed Object is null, it will return an empty String ("").

Throws:
java.beans.IntrospectionException
java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException

setText

public void setText(java.lang.Object target,
                    java.lang.String value,
                    java.text.Format format)
             throws java.beans.IntrospectionException,
                    java.lang.reflect.InvocationTargetException,
                    java.lang.IllegalAccessException,
                    java.text.ParseException,
                    UnsupportedDataTypeException,
                    UnsupportedConversionException
Sets the accessed Object from the given String value to DataType using Format(if defined) to parse. If the given String value is null or empty (""), the accessed Object is set to null.

Throws:
java.beans.IntrospectionException
java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException
java.text.ParseException
UnsupportedDataTypeException
UnsupportedConversionException

getPropertyValue

public java.lang.Object getPropertyValue(java.lang.Object valueObject)
                                  throws java.beans.IntrospectionException,
                                         java.lang.reflect.InvocationTargetException,
                                         java.lang.IllegalAccessException
Returns a property value from the valueObject based on the propertyName. The valueObject and propertyName properties must be defined before you invoke this method, and the valueObject must have a getter for the propertyName, otherwise IntrospectionException will be raised. This method will invoke the setAccessorMethods method if it has not yet been invoked.

Throws:
java.beans.IntrospectionException
java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException

setPropertyValue

public void setPropertyValue(java.lang.Object valueObject,
                             java.lang.Object value)
                      throws java.beans.IntrospectionException,
                             java.lang.reflect.InvocationTargetException,
                             java.lang.IllegalAccessException
Sets a property of the valueObject to the given value based on the propertyName. The valueObject and propertyName properties must be defined before you invoke this method, and the valueObject must have a setter for the propertyName, otherwise IntrospectionException will be raised. This method will invoke the setAccessorMethods method if it has not yet been invoked.

Throws:
java.beans.IntrospectionException
java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException

getPropertyName

public java.lang.String getPropertyName()
Returns the name of the property in the valueObject to use. This is the property that get/setObject and get/setText methods will access. The property name should follow JavaBean conventions.

Example: propertyName="color": then it expects getColor and setColor will be the method names in the valueObject.


getReadMethods

protected java.lang.reflect.Method[] getReadMethods()
Returns the Methods used to get/read the target property. This value is set by setAccessorMethods which is invoked automatically by the set/getObject or setText methods.


getWriteMethod

protected java.lang.reflect.Method getWriteMethod()
Returns the Method used to get/read the target property. This value is set by setAccessorMethods which is invoked automatically by the set/getObject or setText methods.



Copyright © 2007 Martin T Phelan. All Rights Reserved.