com.tensegrity.generic.attribute
Class AttributeSetPool

java.lang.Object
  extended bycom.tensegrity.generic.attribute.AttributeSetPool

public class AttributeSetPool
extends java.lang.Object

The AttributeSetPool can be used to pool attribute created by an AttributeFactory. By doing so creating a lot of duplicated attributes can be avoided.

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

Field Summary
protected static java.util.HashMap attributeSets
          Hashmap to store the attribute sets
static java.lang.String ELEMATTR_EXPRESSION
          Typename for the expression attribute
static java.lang.String ELEMATTR_NAME
          Typename for the name attribute
static java.lang.String ELEMATTR_TYPE
          Typename for the type attribute
static java.lang.String ELEMATTR_VALUE
          Typename for the value attribute
static java.lang.String ELEMTYPE_ATTRIBUTE
          Typename for the attribute element
static java.lang.String ELEMTYPE_CONSTRAINT
          Typename for the constraint element
static java.lang.String ELEMTYPE_SET
          Typename for the set element
protected static int PARSESTEP_ATTRIBUTES
          Constant for the parse step concerning the attributes
protected static int PARSESTEP_END
          Constant for the last parse step
protected static int PARSESTEP_SETS
          Constant for the parse step concerning the sets
 
Method Summary
static boolean addAttributePaths(AttributeCollection collection)
          Adds the list or set of attributes to the pool.
protected static boolean addAttributePaths(AttributeCollection collection, AttributeSet parentSet, java.lang.String path)
          Adds the list or set of attributes to the pool.
static void addAttributeSet(java.lang.String path, AttributeSet attrSet)
          Adds the given set to the pool.
protected static AttributeSet assertPath(AttributeCollection collection, java.lang.String path)
          Returns the attributeset at the location defined by the given path.
protected static AttributeSet findLeafSet(AttributeSet set)
          Finds the first leaf (set without subset) in the given set
static AttributeList getAttributes()
          Returns all attributes in the pool.
static AttributeSet getAttributeSet(java.lang.String path)
          Returns the pooled set with the given path
static AttributeSet getAttributeSetClone(java.lang.String path)
          Returns a clone of the requested set path, that can be modified without effect to the original pooled set.
protected static boolean isAttribute(Attribute attrib)
          Checks, whether the given attribute is of type Attribute
protected static boolean isAttributeList(Attribute attrib)
          Checks, whether the given attribute is of type AttributeList
protected static boolean isAttributeSet(Attribute attrib)
          Checks, whether the given attribute is of type AttributeSet
static AttributeSet removeAttributeSet(java.lang.String path)
          Removes the pooled set with the given path
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PARSESTEP_ATTRIBUTES

protected static final int PARSESTEP_ATTRIBUTES
Constant for the parse step concerning the attributes

See Also:
Constant Field Values

PARSESTEP_SETS

protected static final int PARSESTEP_SETS
Constant for the parse step concerning the sets

See Also:
Constant Field Values

PARSESTEP_END

protected static final int PARSESTEP_END
Constant for the last parse step

See Also:
Constant Field Values

ELEMTYPE_ATTRIBUTE

public static final java.lang.String ELEMTYPE_ATTRIBUTE
Typename for the attribute element

See Also:
Constant Field Values

ELEMTYPE_SET

public static final java.lang.String ELEMTYPE_SET
Typename for the set element

See Also:
Constant Field Values

ELEMTYPE_CONSTRAINT

public static final java.lang.String ELEMTYPE_CONSTRAINT
Typename for the constraint element

See Also:
Constant Field Values

ELEMATTR_NAME

public static final java.lang.String ELEMATTR_NAME
Typename for the name attribute

See Also:
Constant Field Values

ELEMATTR_TYPE

public static final java.lang.String ELEMATTR_TYPE
Typename for the type attribute

See Also:
Constant Field Values

ELEMATTR_VALUE

public static final java.lang.String ELEMATTR_VALUE
Typename for the value attribute

See Also:
Constant Field Values

ELEMATTR_EXPRESSION

public static final java.lang.String ELEMATTR_EXPRESSION
Typename for the expression attribute

See Also:
Constant Field Values

attributeSets

protected static final java.util.HashMap attributeSets
Hashmap to store the attribute sets

Method Detail

addAttributeSet

public static void addAttributeSet(java.lang.String path,
                                   AttributeSet attrSet)
Adds the given set to the pool.

Parameters:
path - The complete path of the set to return Path levels are seperated by ':'
attrSet - The set to add to the pool

removeAttributeSet

public static AttributeSet removeAttributeSet(java.lang.String path)
Removes the pooled set with the given path

Parameters:
path - The complete path of the set to return Path levels are seperated by ':'
Returns:
AttributeSet The removed set or null, if the set was not found

getAttributeSet

public static AttributeSet getAttributeSet(java.lang.String path)
Returns the pooled set with the given path

Parameters:
path - The complete path of the set to return Path levels are seperated by ':'
Returns:
AttributeSet The requested set

getAttributeSetClone

public static AttributeSet getAttributeSetClone(java.lang.String path)
                                         throws java.lang.CloneNotSupportedException
Returns a clone of the requested set path, that can be modified without effect to the original pooled set.

Parameters:
path - The complete path of the set to return Path levels are seperated by ':'
Returns:
AttributeSet The clone of the requested set
Throws:
java.lang.CloneNotSupportedException - If this AttributeSet implementation does not support/allow cloning.

addAttributePaths

public static boolean addAttributePaths(AttributeCollection collection)
                                 throws java.text.ParseException,
                                        IllegalNameException,
                                        IllegalValueException,
                                        IllegalAttributeException,
                                        ConstraintViolationException,
                                        java.lang.CloneNotSupportedException
Adds the list or set of attributes to the pool. The hierarchical structure will be transfered into unique set paths. e.g. will be transfered to following set paths: "set1": "set2": "set2:set3":

Parameters:
collection - The collection, that contains the children to add
Returns:
boolean True/false if the function succeeded/failed
Throws:
java.text.ParseException - If an error occurs
IllegalNameException - If an error occurs
IllegalValueException - If an error occurs
IllegalAttributeException - If an error occurs
ConstraintViolationException - If an error occurs
java.lang.CloneNotSupportedException - If an error occurs

addAttributePaths

protected static boolean addAttributePaths(AttributeCollection collection,
                                           AttributeSet parentSet,
                                           java.lang.String path)
                                    throws java.text.ParseException,
                                           IllegalNameException,
                                           IllegalValueException,
                                           IllegalAttributeException,
                                           ConstraintViolationException,
                                           java.lang.CloneNotSupportedException
Adds the list or set of attributes to the pool. The hierarchical structure will be transfered into unique set paths.

Parameters:
collection - the collection, that contains the children to add
parentSet - the set to add the children to
path - the path of the collection
Returns:
boolean true if the function succeeded
Throws:
java.text.ParseException - If an error occurs
IllegalNameException - If an error occurs
IllegalValueException - If an error occurs
IllegalAttributeException - If an error occurs
ConstraintViolationException - If an error occurs
java.lang.CloneNotSupportedException - If an error occurs

getAttributes

public static AttributeList getAttributes()
                                   throws IllegalNameException,
                                          IllegalValueException,
                                          IllegalAttributeException,
                                          ConstraintViolationException
Returns all attributes in the pool.

Returns:
all attributes in the pool
Throws:
IllegalNameException - If an error occurs
IllegalValueException - If an error occurs
IllegalAttributeException - If an error occurs
ConstraintViolationException - If an error occurs

assertPath

protected static AttributeSet assertPath(AttributeCollection collection,
                                         java.lang.String path)
                                  throws IllegalNameException,
                                         IllegalValueException,
                                         IllegalAttributeException,
                                         ConstraintViolationException
Returns the attributeset at the location defined by the given path. Will create the attributeset, if it does not exist

Parameters:
collection - The collection of attributesets to look through
path - The path to look for
Returns:
Attributeset at the location defined by the given path.
Throws:
IllegalNameException - If an error occurs
IllegalValueException - If an error occurs
IllegalAttributeException - If an error occurs
ConstraintViolationException - If an error occurs

findLeafSet

protected static AttributeSet findLeafSet(AttributeSet set)
Finds the first leaf (set without subset) in the given set

Parameters:
set - the AttributeSet to look through.
Returns:
the first found leaf (never null).

isAttributeSet

protected static boolean isAttributeSet(Attribute attrib)
Checks, whether the given attribute is of type AttributeSet

Parameters:
attrib - The attribute to check
Returns:
True, if the type has been confirmed

isAttributeList

protected static boolean isAttributeList(Attribute attrib)
Checks, whether the given attribute is of type AttributeList

Parameters:
attrib - The attribute to check
Returns:
True, if the type has been confirmed

isAttribute

protected static boolean isAttribute(Attribute attrib)
Checks, whether the given attribute is of type Attribute

Parameters:
attrib - The attribute to check
Returns:
True, if the type has been confirmed


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