org.formaria.editor.data.pojo
Class PojoDataSourceEx

java.lang.Object
  extended by org.formaria.data.DataSource
      extended by org.formaria.editor.data.pojo.PojoDataSourceEx
Direct Known Subclasses:
PersistentPojoDataSourceEx

public class PojoDataSourceEx
extends DataSource

A data source for working with POJOs in the data visualiser.

Copyright (c) Formaria Ltd., 2001-2007, 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.util.Hashtable adapters
           
protected static java.lang.String[] GETTER_PREFIXES
           
protected  java.util.ArrayList modelListeners
           
protected  java.util.Hashtable overrides
           
protected  java.lang.Object pojoContext
           
protected  DataModel pojoRootModel
           
protected  PropertiesRetriever propertiesRetriever
           
protected static java.lang.String[] SETTER_PREFIXES
           
 
Fields inherited from class org.formaria.data.DataSource
currentProject
 
Constructor Summary
PojoDataSourceEx(Project project)
          Creates new instance of PojoDataSource
 
Method Summary
 PojoModelVis adaptPojo(java.lang.Class pojoClass, java.lang.String propertyName, DataModel parentNode)
          Adapts the transient pojo of the specified type.
 PojoModelVis adaptPojo(java.lang.reflect.Method getter, java.lang.reflect.Method setter, java.lang.String propertyName, DataModel parentNode)
          Adapts the POJO returned by method invoked on a parent object.
 PojoModelVis adaptPojo(java.lang.Object pojo, DataModel parentNode)
          Adapt a POJO for use in the model, applying any overrides to the POJO's API defined in the data source's configuration file (by default pojo.xml)
protected  PojoAdapterEx createAdapter(java.lang.Class pojoClass)
          Creates a new instance of PojoAdapterEx
protected  void customizeProperty(PojoAdapterEx adapter, XmlElement propertyElement)
           
 PojoAdapterEx getAdapter(java.lang.Class pojoClass)
          Gets the adapter for the specified class
protected static java.lang.String getDispValue(java.lang.Object pojo)
          Gets the pojo caption that will appear in the visualiser tree node.
 java.lang.Object getPojoContext()
          Returns the pojo context object.
protected  ProjectClassLoader getProjectClassLoader()
          Returns the class loader being used to load current project's classes.
 PropertiesRetriever getPropertiesRetriever()
          Returns the finder arguments values holder.
static boolean getterSupported(java.lang.reflect.Method method, boolean prefixes)
          Determines whether the passed getter is supported
 void loadTable(XmlElement source, DataModel model)
          Recursively load the model data
protected  void overrideAdapter(PojoAdapterEx adapter)
          Overrides the adapter, adds the customization specified by the configuration.
static boolean setterSupported(java.lang.reflect.Method method, boolean prefixes)
          Determines whether the passed setter method is supported
 
Methods inherited from class org.formaria.data.DataSource
outputModel, outputModel, outputModel, read, read, readDataSource, setUseValueAsId, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GETTER_PREFIXES

protected static final java.lang.String[] GETTER_PREFIXES

SETTER_PREFIXES

protected static final java.lang.String[] SETTER_PREFIXES

propertiesRetriever

protected PropertiesRetriever propertiesRetriever

pojoContext

protected java.lang.Object pojoContext

pojoRootModel

protected DataModel pojoRootModel

overrides

protected java.util.Hashtable overrides

adapters

protected java.util.Hashtable adapters

modelListeners

protected java.util.ArrayList modelListeners
Constructor Detail

PojoDataSourceEx

public PojoDataSourceEx(Project project)
Creates new instance of PojoDataSource

Parameters:
project - the owning project
Method Detail

getPropertiesRetriever

public PropertiesRetriever getPropertiesRetriever()
Returns the finder arguments values holder.


getPojoContext

public java.lang.Object getPojoContext()
Returns the pojo context object.

Returns:
pojo context object

getAdapter

public PojoAdapterEx getAdapter(java.lang.Class pojoClass)
Gets the adapter for the specified class

Parameters:
pojoClass - the class whose adapter is to be returned
Returns:
the adapter

createAdapter

protected PojoAdapterEx createAdapter(java.lang.Class pojoClass)
Creates a new instance of PojoAdapterEx

Parameters:
pojoClass - the class to be adapted

overrideAdapter

protected void overrideAdapter(PojoAdapterEx adapter)
Overrides the adapter, adds the customization specified by the configuration.

Parameters:
adapter - the adapter to be customized

customizeProperty

protected void customizeProperty(PojoAdapterEx adapter,
                                 XmlElement propertyElement)

adaptPojo

public PojoModelVis adaptPojo(java.lang.Object pojo,
                              DataModel parentNode)
Adapt a POJO for use in the model, applying any overrides to the POJO's API defined in the data source's configuration file (by default pojo.xml)

Parameters:
pojo - the object being adapted
parentNode - the parent model node
Returns:
the pojo model node encapsulating the pojo

adaptPojo

public PojoModelVis adaptPojo(java.lang.reflect.Method getter,
                              java.lang.reflect.Method setter,
                              java.lang.String propertyName,
                              DataModel parentNode)
Adapts the POJO returned by method invoked on a parent object.

Parameters:
parentNode - parent model node
method - the Method that returns the pojo which is to be adapted
Returns:
the pojo model node encapsulating the pojo

adaptPojo

public PojoModelVis adaptPojo(java.lang.Class pojoClass,
                              java.lang.String propertyName,
                              DataModel parentNode)
Adapts the transient pojo of the specified type.

Parameters:
pojoClass - the type of the underlying pojo
propertyName - the name of the transient property
parentNode - parent model node

getterSupported

public static boolean getterSupported(java.lang.reflect.Method method,
                                      boolean prefixes)
Determines whether the passed getter is supported

Parameters:
method - the Method to be checked
prefixes - indicates whether the getter prefixes should be checked
Returns:
true if the method is supported, false otherwise

setterSupported

public static boolean setterSupported(java.lang.reflect.Method method,
                                      boolean prefixes)
Determines whether the passed setter method is supported

Parameters:
method - the method to be queried
prefixes - indicates whether the getter prefixes should be checked
Returns:
true if the passed method is supported, false otherwise

getDispValue

protected static java.lang.String getDispValue(java.lang.Object pojo)
Gets the pojo caption that will appear in the visualiser tree node.

Parameters:
pojo - Object
Returns:
the caption

getProjectClassLoader

protected ProjectClassLoader getProjectClassLoader()
Returns the class loader being used to load current project's classes.

Returns:
ProjectClassLoader of the current project

loadTable

public void loadTable(XmlElement source,
                      DataModel model)
Recursively load the model data

Overrides:
loadTable in class DataSource
Parameters:
source - the source element
model - the model node for the source element