org.graffiti.util.attributes
Class AttributeFactory

java.lang.Object
  extended by org.graffiti.util.attributes.AttributeFactory

public abstract class AttributeFactory
extends Object

Factory class for creating attributes. Which attribute is to be created is determined by the respective subclass of AttributeFactory by implementing createAttribute(String). All setter methods of the created Attribute must feature the following structure:

  1. Call preCallback.
  2. Iff #preCallback returns true, actually set the value.
  3. Call postCallback.

Version:
$Revision$ $Date$
Author:
Andreas Gleißner
See Also:
AttributeFactoryFactory

Field Summary
protected  VoidCallback<Object> postCallback
          The callback to be called after the value of an attribute created by this factory has actually been set.
protected  Callback<Boolean,Object> preCallback
          The callback to be called before the value of an attribute created by this factory is actually set.
 
Constructor Summary
AttributeFactory()
           
 
Method Summary
protected abstract  Attribute createAttribute(String id)
          Creates a new attribute with the specified id.
protected  void postCallback(Object o)
          Calls the postCallback earlier set by setCallback(Callback, VoidCallback).
protected  boolean preCallback(Object o)
          Calls the preCallback earlier set by setCallback(Callback, VoidCallback).
protected  void setCallback(Callback<Boolean,Object> preCallback, VoidCallback<Object> postCallback)
          Sets the callbacks.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

preCallback

protected Callback<Boolean,Object> preCallback
The callback to be called before the value of an attribute created by this factory is actually set.


postCallback

protected VoidCallback<Object> postCallback
The callback to be called after the value of an attribute created by this factory has actually been set.

Constructor Detail

AttributeFactory

public AttributeFactory()
Method Detail

setCallback

protected final void setCallback(Callback<Boolean,Object> preCallback,
                                 VoidCallback<Object> postCallback)
Sets the callbacks. The callbacks have to be called by all setter methods of the attributes created by this factory.

Parameters:
preCallback - the callback to be called before the value of an attribute created by this factory is actually set.
postCallback - the callback to be called after the value of an attribute created by this factory has actually been set.

createAttribute

protected abstract Attribute createAttribute(String id)
Creates a new attribute with the specified id. Before calling #createAttribute(String), the callbacks have to be set by setCallback(Callback, VoidCallback).

Parameters:
id - the id of the attribute to be created.
Returns:
a new attribute with the specified id. The setter methods of the returned attribute must feature the following structure:
  1. Call preCallback.
  2. Iff #preCallback returns true, actually set the value.
  3. Call postCallback.

preCallback

protected final boolean preCallback(Object o)
Calls the preCallback earlier set by setCallback(Callback, VoidCallback). Must only be called by setter methods of attributes created by this factory.

Parameters:
o - value passed to the setter method of the attribute calling this method.
Returns:
true, if the setter method of the attribute calling this method should actually set the new value.

postCallback

protected final void postCallback(Object o)
Calls the postCallback earlier set by setCallback(Callback, VoidCallback). Must only be called by setter methods of attributes created by this factory.

Parameters:
o - value passed to the setter method of the attribute calling this method.


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