com.tensegrity.generic.attribute
Class AttributableOnSetCollection

java.lang.Object
  extended bycom.tensegrity.generic.attribute.AttributableOnSetCollection
All Implemented Interfaces:
Attributable, AttributableOnSet
Direct Known Subclasses:
EditorStateAttributableOnSet

public class AttributableOnSetCollection
extends java.lang.Object
implements AttributableOnSet

AttributableOnSet implementation which itself contains some AttributableOnSets. The AttributeSet structures of the single AttributableOnSet s will be merged, if possible, so the getter functions return a structure representing the values in all elements of this collection. Some of the values might be in an undefined state, if they differ in the single elements.

Version:
$Id: AttributableOnSetCollection.java,v 1.3 2006/01/26 17:15:08 MichaelKegel Exp $
Author:
BurkhardWick

Field Summary
 
Fields inherited from interface com.tensegrity.generic.attribute.AttributableOnSet
TREE_SUBSET_POSTFIX
 
Constructor Summary
AttributableOnSetCollection()
          Constructor
AttributableOnSetCollection(AttributableOnSetCollectionFeedback feedback)
          Constructor
 
Method Summary
 void addAttributableOnSet(AttributableOnSet aos)
          Add an AttributableOnSet to the collection
 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 disableTypeRemoval()
          Disables the automatic removal of the type node, which is the root of an attribute tree
 void enableAttributableEvents()
          Enables the transmission of events to registered listeners.
 void enableTypeRemoval()
          Enables the automatic removal of the type node, which is the root of an attribute tree
static Attribute findAttribute(AttributeSet parent, java.lang.String path)
          Deprecated. Use AttributeOperations.findByPath(AttributeSet, String).
 AttributableOnSet get(int i)
          Retrieves the AttributableOnSet at the given index.
 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.
static java.lang.String getPath(AttributeSet set, Attribute attrib)
          Returns the full qualified path of the given attribute in the given set.
static java.lang.String getTypeName(AttributableOnSet onset)
          Returns the type name of the given AttributableOnSet.
 java.lang.String getTypeName(int index)
          Returns the type name of the AttributableOnSet at the given index.
 java.util.Collection getTypeNames()
          Returns a list of all type nams in this collection, so there are no duplicate elements in the list.
 boolean isTypeRemovalEnabled()
          Returns true, if the automatic type removal is enabled
 boolean isUndefinedState(java.lang.String path)
          Checks whether the value of the attribute identified by the given path is in an undefined state.
 void removeAttributableOnSet(AttributableOnSet aos)
          Removes an AttributableOnSet from the collection
 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(AttributableOnSet attributable, AttributeSet attributes)
          Sets the attributes to a specific attributable.
 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.
 int size()
          Returns the size of this collection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AttributableOnSetCollection

public AttributableOnSetCollection()
Constructor


AttributableOnSetCollection

public AttributableOnSetCollection(AttributableOnSetCollectionFeedback feedback)
Constructor

Parameters:
feedback - The feedback for notifications
Method Detail

addAttributableOnSet

public void addAttributableOnSet(AttributableOnSet aos)
Add an AttributableOnSet to the collection

Parameters:
aos - The AttributableOnSet to add

removeAttributableOnSet

public void removeAttributableOnSet(AttributableOnSet aos)
Removes an AttributableOnSet from the collection

Parameters:
aos - The AttributableOnSet to remove

size

public int size()
Returns the size of this collection

Returns:
The size of this collection

get

public AttributableOnSet get(int i)
Retrieves the AttributableOnSet at the given index.

Parameters:
i - The index to retrieve
Returns:
The element at the given index

getTypeName

public java.lang.String getTypeName(int index)
Returns the type name of the AttributableOnSet at the given index.

Parameters:
index - The index of the AttributableOnSet
Returns:
The name of the set that is the root of the attribute tree returned by getAttributesTree() (typename)

isUndefinedState

public boolean isUndefinedState(java.lang.String path)
Checks whether the value of the attribute identified by the given path is in an undefined state. Which means that at least two elements in this collection have different values for this attribute.

Parameters:
path - The complete path of the attribute
Returns:
True, if the value is undefined

isTypeRemovalEnabled

public boolean isTypeRemovalEnabled()
Returns true, if the automatic type removal is enabled

Returns:
true, if the automatic type removal is enabled

enableTypeRemoval

public void enableTypeRemoval()
Enables the automatic removal of the type node, which is the root of an attribute tree


disableTypeRemoval

public void disableTypeRemoval()
Disables the automatic removal of the type node, which is the root of an attribute tree


findAttribute

public static final Attribute findAttribute(AttributeSet parent,
                                            java.lang.String path)
Deprecated. Use AttributeOperations.findByPath(AttributeSet, String).

Utility method to find an attribute in an attribute tree.

Parameters:
parent - The parent set to start search
path - The path to the attribute to look for
Returns:
The found attribute or null

getPath

public static final java.lang.String getPath(AttributeSet set,
                                             Attribute attrib)
Returns the full qualified path of the given attribute in the given set. The given set has to contain the very same instance of the attribute, as an equals would match more than one attribute and is useless here.

Parameters:
set - The set that has to contain the attribute in its substructure
attrib - The attribute to look for
Returns:
The full qualified string of the attribute

getTypeName

public static final java.lang.String getTypeName(AttributableOnSet onset)
Returns the type name of the given AttributableOnSet.

Parameters:
onset - The AttributableOnSet
Returns:
The name of the set that is the root of the attribute tree returned by getAttributesTree() (typename)

getAttributes

public 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 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 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 void setAttributesTree(AttributableOnSet attributable,
                              AttributeSet attributes)
Sets the attributes to a specific attributable.

Parameters:
attributable - The attributable to apply the attributes to
attributes - The attributes to apply

setAttributesTree

public 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 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 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 void enableAttributableEvents()
Description copied from interface: AttributableOnSet
Enables the transmission of events to registered listeners.

Specified by:
enableAttributableEvents in interface AttributableOnSet

disableAttributableEvents

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

Specified by:
disableAttributableEvents in interface AttributableOnSet

areAttributableEventsEnabled

public 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 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 void setAttribute(Attribute attribute)
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.

getAttributeValue

public 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 void setAttributeValue(java.lang.String name,
                              java.lang.Object value)
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.

getAttributeType

public 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.

getTypeNames

public java.util.Collection getTypeNames()
Returns a list of all type nams in this collection, so there are no duplicate elements in the list.

Returns:
a list of all type nams in this collection


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