com.tensegrity.generic.attribute
Class GenericAttributableOnSet

java.lang.Object
  extended bycom.tensegrity.generic.attribute.GenericAttributableOnSet
All Implemented Interfaces:
Attributable, AttributableOnSet

public class GenericAttributableOnSet
extends java.lang.Object
implements AttributableOnSet

GenericAttributableOnSet is a generic AttributableOnSet implementation that just wraps an AttributeSet in a table or tree structure.

Note: An instance with an attribute structure containing more than 2 levels can't be used in an AttributeTable.

To use this class you should create an AttributeSet containing all Attributes you want it to handle. Then you can create an instance by using the constructor and passing it as argument.

Usually this instance is then passed to an AttributeEditor but it can also be used in any other context, because all methods are supported and implemented.

Author:
BurkhardWick

Field Summary
static boolean FIRE_SPECIFIC_ATTRIBUTES_CHANGED_EVENTS
          Deprecated. Use setFireSpecificAttributesChangedEvents(boolean) and isFireSpecificAttributesChangedEvents() instead
 
Fields inherited from interface com.tensegrity.generic.attribute.AttributableOnSet
TREE_SUBSET_POSTFIX
 
Constructor Summary
GenericAttributableOnSet(AttributeSet set)
          Constructor
 
Method Summary
 void addAttributableOnSetListener(AttributableOnSetListener attributableOnSetListener)
          Adds a listener to the attributable on set instance.
 boolean areAttributableEventsEnabled()
          Returns a boolean that indicates whether generating of events is enabled or not.
 void disableAttributableEvents()
          Disables events for the registered listeners.
 void enableAttributableEvents()
          Enables the transmission of events to registered listeners.
 Attribute getAttribute(java.lang.String name)
          Returns the attribute with the given name or null if there is no Attribute with the given name.
 AttributeSet getAttributes()
          Returns an AttributeSet consisting of all attributes of this AttributableOnSet.
 AttributeSet getAttributesTree()
          Returns an AttributeSet containing all Attributes of this AttributableOnSet in a treelike structure.
 AttributeType getAttributeType(java.lang.String name)
          Returns the AttributeType of the attribute with the given name.
 java.lang.Object getAttributeValue(java.lang.String name)
          Return the value of the attribute with the given name.
 boolean isFireSpecificAttributesChangedEvents()
          Returns true if specific events are fired on change of attributes.
 void removeAttributableOnSetListener(AttributableOnSetListener attributableOnSetListener)
          Removes a listener from the attributable on set instance.
 void setAttribute(Attribute attribute)
          Sets the value of the attribute with the same name to the value of the given attribute.
 void setAttributes(AttributeSet attributes)
          Searches within the AttributeSet given by attributes for attributes that have the same name as the attributes of this AttributableOnSet holds.
 void setAttributesTree(AttributeSet attributes)
          Performs the same operation as the setAttributes(com.tensegrity.generic.attribute.AttributeSet) method with the difference that the AttributeSet given to this method must provide the treelike structure mentioned in the documentation of the getAttributesTree().
 void setAttributeValue(java.lang.String name, java.lang.Object value)
          Sets the value of the attribute with the name to the given value.
 void setFireSpecificAttributesChangedEvents(boolean enable)
          Defines whether this generic implementation will calculate information for attributes changed events which will be given as changed attributes in the AttributableOnSetEvent.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FIRE_SPECIFIC_ATTRIBUTES_CHANGED_EVENTS

public static boolean FIRE_SPECIFIC_ATTRIBUTES_CHANGED_EVENTS
Deprecated. Use setFireSpecificAttributesChangedEvents(boolean) and isFireSpecificAttributesChangedEvents() instead

Defines whether this generic implementation will calculate information for attributes changed events which will be given as changed attributes in the AttributableOnSetEvent. This might be time and memory consuming if there are a lot of attribute changes, so it can be turned off here.

Constructor Detail

GenericAttributableOnSet

public GenericAttributableOnSet(AttributeSet set)
Constructor

Parameters:
set - The AttributeSet which contains all Attributes to handle.
Method Detail

isFireSpecificAttributesChangedEvents

public boolean isFireSpecificAttributesChangedEvents()
Returns true if specific events are fired on change of attributes. (@see #setFireSpecifixAttributesChangedEvents(boolean)).

Returns:
true if specific events are fired on change of attributes

setFireSpecificAttributesChangedEvents

public void setFireSpecificAttributesChangedEvents(boolean enable)
Defines whether this generic implementation will calculate information for attributes changed events which will be given as changed attributes in the AttributableOnSetEvent. This might be time and memory consuming if there are a lot of attribute changes, so it can be turned off here. Per default this option is turned on.

Parameters:
enable - true to enable this feature

getAttributes

public final AttributeSet getAttributes()
Description copied from interface: AttributableOnSet
Returns an AttributeSet consisting of all attributes of this AttributableOnSet.

Specified by:
getAttributes in interface AttributableOnSet
Returns:
AttributeSet an AttributeSet with all attributes.

setAttributes

public final void setAttributes(AttributeSet attributes)
Description copied from interface: AttributableOnSet
Searches within the AttributeSet given by attributes for attributes that have the same name as the attributes of this AttributableOnSet holds. The value of every attribute that has the same name is used as the new value for the corresponding attribute of this AttributableOnSet. An Attribute within the given AttributeSet that is not an attribute of the object that implements the AttributableOnSet interface is not handled by nor added to the specific implementor of the AttributableOnSet interface.

Specified by:
setAttributes in interface AttributableOnSet
Parameters:
attributes - the AttributeSet consisting of the attributes whose values to set.

getAttributesTree

public final AttributeSet getAttributesTree()
Description copied from interface: AttributableOnSet
Returns an AttributeSet containing all Attributes of this AttributableOnSet in a treelike structure.
Treelike means that each attribute can have a subset that contains subsequent Attributes for an Attribute of this AttributableOnSet.
Since an Attribute can only have one value (in this case an object or the Attributes for an object) the subsequent attributes are plugged into the returned AttributeSet as a new Attribute with the same name and the AttributableOnSet.TREE_SUBSET_POSTFIX.

Specified by:
getAttributesTree in interface AttributableOnSet
Returns:
AttributeSet an AttributeSet with the attributes in a treelike structure

setAttributesTree

public final void setAttributesTree(AttributeSet attributes)
Description copied from interface: AttributableOnSet
Performs the same operation as the AttributableOnSet.setAttributes(com.tensegrity.generic.attribute.AttributeSet) method with the difference that the AttributeSet given to this method must provide the treelike structure mentioned in the documentation of the AttributableOnSet.getAttributesTree().

Specified by:
setAttributesTree in interface AttributableOnSet
Parameters:
attributes - the AttributeSet containing the attributes whose values to set.

addAttributableOnSetListener

public final void addAttributableOnSetListener(AttributableOnSetListener attributableOnSetListener)
Description copied from interface: AttributableOnSet
Adds a listener to the attributable on set instance.

Specified by:
addAttributableOnSetListener in interface AttributableOnSet
Parameters:
attributableOnSetListener - an AttributableOnSet listener listening for changes

removeAttributableOnSetListener

public final void removeAttributableOnSetListener(AttributableOnSetListener attributableOnSetListener)
Description copied from interface: AttributableOnSet
Removes a listener from the attributable on set instance.

Specified by:
removeAttributableOnSetListener in interface AttributableOnSet
Parameters:
attributableOnSetListener - the AttributableOnSet to be removed from the list of listeners.

enableAttributableEvents

public final void enableAttributableEvents()
Description copied from interface: AttributableOnSet
Enables the transmission of events to registered listeners.

Specified by:
enableAttributableEvents in interface AttributableOnSet

disableAttributableEvents

public final void disableAttributableEvents()
Description copied from interface: AttributableOnSet
Disables events for the registered listeners.

Specified by:
disableAttributableEvents in interface AttributableOnSet

areAttributableEventsEnabled

public final boolean areAttributableEventsEnabled()
Description copied from interface: AttributableOnSet
Returns a boolean that indicates whether generating of events is enabled or not.

Specified by:
areAttributableEventsEnabled in interface AttributableOnSet
Returns:
boolean flag that indicates whether event generation is active or not

getAttribute

public final Attribute getAttribute(java.lang.String name)
Description copied from interface: Attributable
Returns the attribute with the given name or null if there is no Attribute with the given name.

Specified by:
getAttribute in interface Attributable
Parameters:
name - name of the attribute to return.
Returns:
the attribute with the given name or null.

setAttribute

public final void setAttribute(Attribute attribute)
                        throws IllegalValueException,
                               ConstraintViolationException
Description copied from interface: Attributable
Sets the value of the attribute with the same name to the value of the given attribute.
Notice: If the specific implementor of the Attributable interface doesn't support an Attribute with the name of the Attribute given by attribute, the given attribute is not handled by nor added to the attributes of the Attributable.

Specified by:
setAttribute in interface Attributable
Parameters:
attribute - the attribute to be set.
Throws:
ConstraintViolationException - is thrown when the value of the given Attribute violates the constraint of the Attribute to set.
IllegalValueException - is thrown when the value of the given Attribute is illegal (for instance when it is null).

getAttributeValue

public final java.lang.Object getAttributeValue(java.lang.String name)
Description copied from interface: Attributable
Return the value of the attribute with the given name.

Specified by:
getAttributeValue in interface Attributable
Parameters:
name - the name of the attribute to return the value from.
Returns:
the value of the attribute with the given name.

setAttributeValue

public final void setAttributeValue(java.lang.String name,
                                    java.lang.Object value)
                             throws IllegalValueException,
                                    ConstraintViolationException
Description copied from interface: Attributable
Sets the value of the attribute with the name to the given value.
Notice: If the specific implementor of the Attributable interface doesn't support an Attribute with the name given by name, the attribute given through name and value is not handled nor created by Attributable.

Specified by:
setAttributeValue in interface Attributable
Parameters:
name - the name of the attribute.
value - the value to set the attributes value to.
Throws:
ConstraintViolationException - is thrown when the given value violates the constraint of the Attribute to set.
IllegalValueException - is thrown when the given value is illegal (for instance when it is null).

getAttributeType

public final AttributeType getAttributeType(java.lang.String name)
Description copied from interface: Attributable
Returns the AttributeType of the attribute with the given name.

Specified by:
getAttributeType in interface Attributable
Parameters:
name - the name of the attribute.
Returns:
the attribute type with given name.


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.