org.formaria.editor.data.pojo
Class PojoAdapterEx

java.lang.Object
  extended by org.formaria.editor.data.pojo.PojoAdapterEx
Direct Known Subclasses:
PersistentPojoAdapterEx

public class PojoAdapterEx
extends java.lang.Object

A POJO adapter that extends the basic pojo to support listing and querying of all possible properties.

Copyright (c) Formaria Ltd., 2001-2006, This software is licensed under the GNU Public License (GPL), please see license.txt for more details. If you make commercial use of this software you must purchase a commercial license from Formaria.


Field Summary
protected  java.lang.Class clazz
           
protected  PojoDataSourceEx dataSource
           
protected  java.util.Hashtable getters
           
protected  PojoProperties properties
           
protected  java.util.Hashtable setters
           
 
Constructor Summary
PojoAdapterEx(java.lang.Class cl, PojoDataSourceEx ds)
          Creates a new instance of PojoAdapterEx
 
Method Summary
protected  void addCollectionType(java.lang.String propertyName, java.lang.String className)
          Marks that the specified collection is intended to store the elements of the specified type
protected  void addTransientCollectionType(java.lang.String propertyName, java.lang.String className)
          Marks that the specified transient collection is intended to store elements of the specified type.
protected  void addTransientProperty(java.lang.String propertyName, java.lang.String className)
          Adds the transient property of the POJO
protected  void customizePojoProperty(java.lang.String propertyName, java.lang.String propGetter, java.lang.String propSetter)
          Adapt a property by replacing the getter and setter names determined by reflection
protected  void findAccessors()
           
protected  void findProperties()
          Finds and saves all properties of the adapted class.
 java.lang.Class getAdaptedClass()
          Gets the type adapted by this object.
 java.lang.String[] getGettersBySig(java.lang.Class[] parameterTypes)
           
protected  java.lang.reflect.Method getMethod(java.lang.String method)
          Gets the method described by the passed String.
 int getNumChildren()
          Gets the number of properties
 PojoDataSourceEx getPojoDataSourceEx()
          Gets the PojoDataSourceEx object used to construct POJO's model.
protected  PojoProperties getProperties()
          Gets the properties of the Class being adapted by this object.
 DataModel getProperty(java.lang.String propertyName, DataModel parentNode)
          Gets a model node wrapping property value of the passed object.
 java.lang.String[] getSetters()
           
 java.lang.String[] getSettersBySig(java.lang.Class[] parameterTypes)
           
protected static java.lang.String getSignature(java.lang.reflect.Method method)
          Gets the String describing the signature of the specified method.
protected static java.lang.String getSignature(java.lang.String method)
          Gets the method signature
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

clazz

protected java.lang.Class clazz

dataSource

protected PojoDataSourceEx dataSource

properties

protected PojoProperties properties

getters

protected java.util.Hashtable getters

setters

protected java.util.Hashtable setters
Constructor Detail

PojoAdapterEx

public PojoAdapterEx(java.lang.Class cl,
                     PojoDataSourceEx ds)
Creates a new instance of PojoAdapterEx

Parameters:
cl - the class to be adapted
ds - the data source object.
Method Detail

getAdaptedClass

public java.lang.Class getAdaptedClass()
Gets the type adapted by this object.

Returns:
class object

findProperties

protected void findProperties()
Finds and saves all properties of the adapted class.


findAccessors

protected void findAccessors()

getGettersBySig

public java.lang.String[] getGettersBySig(java.lang.Class[] parameterTypes)

getSettersBySig

public java.lang.String[] getSettersBySig(java.lang.Class[] parameterTypes)

getSetters

public java.lang.String[] getSetters()

getMethod

protected java.lang.reflect.Method getMethod(java.lang.String method)
Gets the method described by the passed String.

Parameters:
String - describing the method
Returns:
requested method

addCollectionType

protected void addCollectionType(java.lang.String propertyName,
                                 java.lang.String className)
Marks that the specified collection is intended to store the elements of the specified type

Parameters:
propertyName - the name of the property representing the collection
className - the type of the collection elements

addTransientCollectionType

protected void addTransientCollectionType(java.lang.String propertyName,
                                          java.lang.String className)
Marks that the specified transient collection is intended to store elements of the specified type.

Parameters:
className - the type of the collection elements.

addTransientProperty

protected void addTransientProperty(java.lang.String propertyName,
                                    java.lang.String className)
Adds the transient property of the POJO

Parameters:
propertyName - the name of the transient property
className - the name of the class whose instance will be "stored" by this property

customizePojoProperty

protected void customizePojoProperty(java.lang.String propertyName,
                                     java.lang.String propGetter,
                                     java.lang.String propSetter)
Adapt a property by replacing the getter and setter names determined by reflection

Parameters:
propName - the property being customized
propGetter - the getter method
propSetter - the setter method

getSignature

protected static java.lang.String getSignature(java.lang.String method)
Gets the method signature

Parameters:
method - the name of the method + signature
Returns:
signature

getSignature

protected static java.lang.String getSignature(java.lang.reflect.Method method)
Gets the String describing the signature of the specified method.

Parameters:
method - the method whose signature is to be obtained
Returns:
the method signature

getProperty

public DataModel getProperty(java.lang.String propertyName,
                             DataModel parentNode)
Gets a model node wrapping property value of the passed object.

Parameters:
obj - the object whose property is to be retrieved
propertyName - the name of the property
parentNode - the parent model node for the returned object
Returns:
DataModel instance wrapping property value of the obj

getProperties

protected PojoProperties getProperties()
Gets the properties of the Class being adapted by this object.


getPojoDataSourceEx

public PojoDataSourceEx getPojoDataSourceEx()
Gets the PojoDataSourceEx object used to construct POJO's model.

Returns:
the PojoDataSourceEx object.

getNumChildren

public int getNumChildren()
Gets the number of properties

Returns:
number of properties