org.graffiti.util.attributes
Class AttributeFactoryFactoryManager

java.lang.Object
  extended by org.graffiti.util.attributes.AttributeFactoryFactoryManager
Direct Known Subclasses:
PrimitiveAttributeFactoryFactoryManager

public class AttributeFactoryFactoryManager
extends Object

Class for creating attributes employing a double factory pattern. It contains a map that determines the kind of attribute to be created dependent on the Class object passed to the createAttribute method. The construction process is triple-stage. First, the appropriate AttributeFactoryFactory is determined for a given Class object by a look up in the map. Then the AttributeFactoryFactory is used to create an AttributeFactory, which finally creates the desired Attribute. One may optionally specify callbacks to be called by the setter methods of the created Attributes.

Version:
$Revision$ $Date$
Author:
Andreas Gleißner
See Also:
AttributeFactory.setCallback(Callback, VoidCallback)

Constructor Summary
AttributeFactoryFactoryManager()
          Constructs a AttributeFactoryFactoryManager.
 
Method Summary
 void add(AttributeFactoryFactory factory, Class<?>... types)
          Associates the specified types with the specified AttributeFactoryFactory.
 Attribute createAttribute(String id, Class<?> clazz)
          Creates a new Attribute for the specified Class object and with the specified id.
 Attribute createAttribute(String id, Class<?> clazz, Callback<Boolean,Object> preCallback, VoidCallback<Object> postCallback)
          Creates a new Attribute for the specified Class object and with the specified id.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AttributeFactoryFactoryManager

public AttributeFactoryFactoryManager()
Constructs a AttributeFactoryFactoryManager.

Method Detail

createAttribute

public Attribute createAttribute(String id,
                                 Class<?> clazz)
Creates a new Attribute for the specified Class object and with the specified id.

Parameters:
id - the id of the attribute to be created.
clazz - the Class object to determine the attribute to be created. Note that clazz does not represent the type of the returned attribute but is rather associated with it using a map.
Returns:
a new Attribute for the specified Class object and with the specified id.
See Also:
map, createAttribute(String, Class, Callback, VoidCallback)

createAttribute

public Attribute createAttribute(String id,
                                 Class<?> clazz,
                                 Callback<Boolean,Object> preCallback,
                                 VoidCallback<Object> postCallback)
Creates a new Attribute for the specified Class object and with the specified id. All setter methods of the created {code Attribute} feature the following structure:
  1. Call preCallback.
  2. Iff preCallback returns true, actually set the value.
  3. Call postCallback.

Parameters:
id - the id of the attribute to be created.
clazz - the Class object to determine the attribute to be created. Note that clazz does not represent the type of the returned attribute but is rather associated with it using a map.
preCallback - the callback to be called before the value of the returned attribute is actually set.
postCallback - the callback to be called after the value of the returned attribute has actually been set.
Returns:
a new Attribute for the specified Class object and with the specified id.
See Also:
map, createAttribute(String, Class)

add

public void add(AttributeFactoryFactory factory,
                Class<?>... types)
Associates the specified types with the specified AttributeFactoryFactory.

Parameters:
factory - the AttributeFactoryFactory to create the AttributeFactory to create the desired Attribute if one of the specified Class objects are passed to createAttribute.
types - the Class objects to be associated with the specified AttributeFactoryFactory.


Generated at 2012-05-30 11:00:36 PM CEST