Joda System API

org.joda.property
Class JodaFactory

java.lang.Object
  |
  +--org.joda.property.JodaFactory
Direct Known Subclasses:
ProxyPropertyFactory

public abstract class JodaFactory
extends java.lang.Object

Factory used to create new PropertyTools. This can be used either by using the static create method, or by creating your own factory and calling create() on the instance.

In use, the code might look like:
Person person = (Person) PropertyFactory.create(Person.class);

Applications may choose to have their own class which provides more convenient typecast methods.

Author:
Stephen Colebourne

Constructor Summary
JodaFactory()
           
 
Method Summary
static Bean create(java.lang.Class intface)
          Create a new Bean for the specified interface.
static Bean create(java.lang.Class intface, java.lang.String name)
          Create a new Bean using the default factory.
 Bean createBean(java.lang.Class intface)
          Create a new top level Bean.
abstract  Bean createBean(java.lang.Class intface, java.lang.String name)
          Create a new top level Bean.
abstract  BeanList createBeanList(java.lang.Class intface)
          Create a wrapper for a list of beans that can have a typecast get method.
static BeanList createList(java.lang.Class intface)
          Create a new BeanList for the specified interface.
abstract  Property createProperty(Bean bean, java.lang.String name, java.lang.Class intface)
          Create a new Property and attach it to a particular Bean.
abstract  Property createProperty(Bean bean, java.lang.String name, java.lang.Class intface, java.lang.Class[] types)
          Create a new Property and attach it to a particular Bean.
abstract  Property createProperty(Bean bean, java.lang.String name, java.lang.Class intface, java.lang.Class[] types, PropertyData data)
          Create a new Property and attach it to a particular Bean.
static JodaFactory getInstance()
          Gets the default factory for use in the JVM.
static boolean isFireEvents()
          Gets whether to fire events.
static void setFireEvents(boolean fireEvents)
          Sets whether to fire events.
static void setPropertyFactory(JodaFactory factory)
          Sets the default factory for use in the JVM.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JodaFactory

public JodaFactory()
Method Detail

create

public static Bean create(java.lang.Class intface)
Create a new Bean for the specified interface.

Parameters:
intface - the bean interface (extends Bean)
Returns:
the created object
Throws:
FactoryException - if the object cannot be created

create

public static Bean create(java.lang.Class intface,
                          java.lang.String name)
Create a new Bean using the default factory.

Parameters:
intface - the bean interface (extends Bean)
name - the name of the bean
Returns:
the created object
Throws:
FactoryException - if the object cannot be created

createList

public static BeanList createList(java.lang.Class intface)
Create a new BeanList for the specified interface.

Parameters:
intface - the bean interface (extends BeanList)
Returns:
the created bean list
Throws:
FactoryException - if the object cannot be created

getInstance

public static JodaFactory getInstance()
Gets the default factory for use in the JVM.

Returns:
the PropertyFactory to set as the default

setPropertyFactory

public static void setPropertyFactory(JodaFactory factory)
Sets the default factory for use in the JVM. This method is not thread-safe, and should generally be called once in the program initialisation code.

Parameters:
factory - the PropertyFactory to set as the default

createBean

public abstract Bean createBean(java.lang.Class intface,
                                java.lang.String name)
Create a new top level Bean.

Parameters:
intface - the bean interface (extends Bean)
name - the name of the bean
Returns:
a new top level Bean

createBean

public Bean createBean(java.lang.Class intface)
Create a new top level Bean.

Parameters:
intface - the bean interface (extends Bean)
Returns:
a new top level Bean

createBeanList

public abstract BeanList createBeanList(java.lang.Class intface)
Create a wrapper for a list of beans that can have a typecast get method.

Parameters:
intface - the bean list interface (extends BeanList)

createProperty

public abstract Property createProperty(Bean bean,
                                        java.lang.String name,
                                        java.lang.Class intface)
Create a new Property and attach it to a particular Bean. This can be used by advanced applications to create properties to add to Beans dynamically.

Parameters:
bean - the bean the property is to be attached to
name - the name of the property
intface - the property interface (extends Property)
Returns:
a new Property

createProperty

public abstract Property createProperty(Bean bean,
                                        java.lang.String name,
                                        java.lang.Class intface,
                                        java.lang.Class[] types)
Create a new Property and attach it to a particular Bean. This can be used by advanced applications to create properties to add to Beans dynamically.

The Property interface is typically XxxProperty. This method gives more control over specifying the type of related object.

The Property type array must match the required interface. For simple interfaces such as StringProperty, the array has one element - String.

For a link interface LinkProperty, the array has one element - the bean type.

For list property interfaces, LinkListProperty and DataListProperty, the array has two elements, List.class and the type of object in the list

For map property interfaces, LinkMapProperty and DataMapProperty, the array has three elements, Map and the type of the key and the type of the value in the map.

Parameters:
bean - the bean the property is to be attached to
name - the name of the property
intface - the property interface (extends Property)
types - the property types (do not extend Property)
Returns:
a new Property

createProperty

public abstract Property createProperty(Bean bean,
                                        java.lang.String name,
                                        java.lang.Class intface,
                                        java.lang.Class[] types,
                                        PropertyData data)
Create a new Property and attach it to a particular Bean. This can be used by advanced applications to create properties to add to Beans dynamically.

The Property interface is typically XxxProperty. This method gives more control over specifying the type of related object.

The Property type array must match the required interface. For simple interfaces such as StringProperty, the array has one element - String.

For a link interface LinkProperty, the array has one element - the bean type.

For list property interfaces, LinkListProperty and DataListProperty, the array has two elements, List.class and the type of object in the list

For map property interfaces, LinkMapProperty and DataMapProperty, the array has three elements, Map and the type of the key and the type of the value in the map.

Parameters:
bean - the bean the property is to be attached to
name - the name of the property
intface - the property interface (extends Property)
types - the property types (do not extend Property)
data - the property data object to use
Returns:
a new Property

isFireEvents

public static boolean isFireEvents()
Gets whether to fire events.

Returns:
if firing events

setFireEvents

public static void setFireEvents(boolean fireEvents)
Sets whether to fire events.

Parameters:
fireEvents - whether to fire events

Joda System API

Copyright © 2001-2003 Stephen Colebourne. All Rights Reserved.