net.xoetrope.optional.data.pojo
Class XPojoAdapter

java.lang.Object
  extended by net.xoetrope.registry.ComponentAdapter
      extended by net.xoetrope.registry.ReflectionAdapter
          extended by net.xoetrope.optional.data.pojo.XPojoAdapter
Direct Known Subclasses:
XPojoHibernateAdapter

public class XPojoAdapter
extends ReflectionAdapter

An adapter for POJO's mapping the XUI model's use of the pojo, including customizations specified by the datasourec configuration to the interface provided by the POJO.

Copyright (c) Xoetrope Ltd., 2001-2006
License: see license.txt


Field Summary
protected  XPojoDataSource dataSource
           
protected static java.lang.String[] GETTER_PREFIXES
           
protected static java.lang.String[] SETTER_PREFIXES
           
protected  java.util.HashSet transientProperties
           
 
Fields inherited from class net.xoetrope.registry.ComponentAdapter
className, clazz, getters, setters, UI
 
Constructor Summary
XPojoAdapter(java.lang.Class clazz, XPojoDataSource ds)
          Creates a new instance of XPojoAdapter
 
Method Summary
protected  void customizeProperty(java.lang.String propertyName, java.lang.String getter, java.lang.String setter)
          Adapt a property by replacing the getter and setter names determined by reflection
protected  java.lang.reflect.Method findFirstMethod(java.lang.String propertyName, java.lang.Class[] argTypes, java.lang.String[] prefixes)
          Gets the first method that matches any of the specified method names, method argument types matches the types of passed arguments and.
protected  java.lang.reflect.Method getGetter(java.lang.String propertyName, java.lang.Object[] argVals)
          Retrieves the getter method for the given property
 java.lang.String getId(java.lang.Object pojo)
          Gets the value of the ID attribute
protected  java.lang.reflect.Method getSetter(java.lang.String propertyName, java.lang.Object value)
          Retrieves the setter method for the given property.
protected  boolean isTransient(java.lang.String propertyName)
          Determines whether specified property is transient
protected  void setTransient(java.lang.String propertyName)
          Marks that the specified property is transient.
 
Methods inherited from class net.xoetrope.registry.ReflectionAdapter
addProperty, getProperty, setProperty
 
Methods inherited from class net.xoetrope.registry.ComponentAdapter
addProperty, getAdapterClass, getAdapterClassName, getUI
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GETTER_PREFIXES

protected static java.lang.String[] GETTER_PREFIXES

SETTER_PREFIXES

protected static java.lang.String[] SETTER_PREFIXES

dataSource

protected XPojoDataSource dataSource

transientProperties

protected java.util.HashSet transientProperties
Constructor Detail

XPojoAdapter

public XPojoAdapter(java.lang.Class clazz,
                    XPojoDataSource ds)
Creates a new instance of XPojoAdapter

Method Detail

getId

public java.lang.String getId(java.lang.Object pojo)
Gets the value of the ID attribute

Returns:
the ID attribute

setTransient

protected void setTransient(java.lang.String propertyName)
Marks that the specified property is transient.


isTransient

protected boolean isTransient(java.lang.String propertyName)
Determines whether specified property is transient

Parameters:
propertyName - the name of the property which is to be queried
Returns:
true if the property is transient, false otherwise

customizeProperty

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

Parameters:
propertyName - the prooerty being customized
getter - the property getter
setter - the property setter

getGetter

protected java.lang.reflect.Method getGetter(java.lang.String propertyName,
                                             java.lang.Object[] argVals)
Retrieves the getter method for the given property

Parameters:
propertyName - the name of the property
argVals - property argument values being used to determine the method signature
Returns:
the matching getter method if there is one, null otherwise

getSetter

protected java.lang.reflect.Method getSetter(java.lang.String propertyName,
                                             java.lang.Object value)
Retrieves the setter method for the given property.

Parameters:
propertyName - the name of the property
value - the value that is going to be passed to the setter
the - matching setter method if there is one, null otherwise

findFirstMethod

protected java.lang.reflect.Method findFirstMethod(java.lang.String propertyName,
                                                   java.lang.Class[] argTypes,
                                                   java.lang.String[] prefixes)
Gets the first method that matches any of the specified method names, method argument types matches the types of passed arguments and. The method is being retrieved by reflection

Parameters:
propertyName - the name of the property from which the method name is constructed
argValues - values of the method arguments
prefixes - table containin prefixes which the name of the wanted method may have.
Returns:
matching method or null if no method was found