context.arch.storage
Class Attributes

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.AbstractList
          extended byjava.util.Vector
              extended bycontext.arch.storage.Attributes
All Implemented Interfaces:
java.lang.Cloneable, java.util.Collection, java.util.List, java.util.RandomAccess, java.io.Serializable

public class Attributes
extends java.util.Vector

This class is a container for a group of related attributes. Attributes can be added, removed, and found in the container.

See Also:
Serialized Form

Field Summary
static java.lang.String ALL
          Tag to indicate all attributes are to be used
static java.lang.String ATTRIBUTES
          Tag for attributes
static char SEPARATOR
          Connector for nested attributes
static java.lang.String SEPARATOR_STRING
          Connector for nested attributes - String
 
Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
Attributes()
          Empty constructor
Attributes(DataObject data)
          Constructor that takes a DataObject as a parameter.
 
Method Summary
 void addAttribute(Attribute att)
          Adds the given Attribute object to the container.
 void addAttribute(java.lang.String name)
          Adds the given attribute name.
 void addAttribute(java.lang.String name, Attributes attributes)
          Adds the given attribute name and value to the container.
 void addAttribute(java.lang.String name, Attributes attributes, java.lang.String type)
          Adds the given attribute name, subAttributes and type to the container
 void addAttribute(java.lang.String name, java.lang.String type)
          Adds the given attribute name and data type
 void addAttributeNameValue(AttributeNameValue att)
          Adds the given AttributeNameValue object to the container.
 void addAttributeNameValue(java.lang.String name)
          Adds the given attribute name.
 void addAttributeNameValue(java.lang.String name, java.lang.Object value)
          Adds the given attribute name and value to the container.
 void addAttributeNameValue(java.lang.String name, java.lang.Object value, java.lang.String type)
          Adds the given attribute name, value and type to the container
 void addAttributes(Attributes atts)
          Adds the given Attributes object to the container.
protected  Attributes create()
           
 boolean equals(Attributes attributes)
          Return true if both Attributes objects are equal
 Attribute getAttribute(java.lang.String name)
          This method returns the Attribute with the given name from this list of Attributes.
 Attribute getAttribute(java.lang.String name, java.lang.String prefix)
          This method returns the Attribute with the given name from this list of Attributes.
 Attribute getAttributeAt(int index)
          Returns the Attribute object at the given index
 AttributeNameValue getAttributeNameValue(java.lang.String name)
          This method returns the AttributeNameValue with the given name from this list of AttributeNameValues.
 AttributeNameValue getAttributeNameValue(java.lang.String name, java.lang.String prefix)
          This method returns the AttributeNameValue with the given name from this list of AttributeNameValue.
 Attributes getSubset(Attributes filterAtts)
          This method takes an Attributes containing the list of attributes (names) wanted and it filters all the rest out from this Attributes object.
 boolean hasAttribute(Attribute att)
          Determines whether the given Attribute object is in the container
 boolean hasAttribute(java.lang.String name, Attributes attributes)
          Determines whether the given attribute name and subAttributes are in the container, using the default datatype.
 boolean hasAttribute(java.lang.String name, Attributes attributes, java.lang.String type)
          Determines whether the given attribute name, subAttributes and type are in the container,
 int indexOfAttribute(Attribute att)
          Returns the index at which the Attribute object occurs
 int indexOfAttribute(java.lang.String name, Attributes attributes)
          Returns the index at which the given attribute name and subAttributes occurs, using the default datatype
 int indexOfAttribute(java.lang.String name, Attributes attributes, java.lang.String type)
          Returns the index at which the given attribute name, subAttributes and type occurs.
 int numAttributes()
          Returns the number of Attributes in the container return the number of Attributes in the container
 void removeAttribute(java.lang.String name)
          This method removes the Attribute with the given name from this list of Attributes.
 Attribute removeAttribute(java.lang.String name, java.lang.String prefix)
          This method removes the Attribute with the given name from this list of Attributes.
 void removeAttributeAt(int index)
          Removes the Attribute object at the given index
protected  void replaceOrAdd(Attribute att)
          guarantees that only one attribute of a given name resides in an Attributes.
 java.lang.String toAString()
          A printable version of this class.
 DataObject toDataObject()
          Converts to a DataObject.
 java.util.Hashtable toTypesHashtable()
          Converts the attributes name-type pairs to a hashtable where the keys are the names and the values are the types.
 java.util.Hashtable toTypesHashtable(java.lang.String prefix)
          Converts the attributes name-type pairs to a hashtable where the keys are the names and the values are the types.
 
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeRange, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, toString, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
iterator, listIterator, listIterator
 

Field Detail

SEPARATOR

public static final char SEPARATOR
Connector for nested attributes

See Also:
Constant Field Values

SEPARATOR_STRING

public static final java.lang.String SEPARATOR_STRING
Connector for nested attributes - String


ATTRIBUTES

public static final java.lang.String ATTRIBUTES
Tag for attributes

See Also:
Constant Field Values

ALL

public static final java.lang.String ALL
Tag to indicate all attributes are to be used

See Also:
Constant Field Values
Constructor Detail

Attributes

public Attributes()
Empty constructor


Attributes

public Attributes(DataObject data)
Constructor that takes a DataObject as a parameter. The DataObject is expected to contain an tag. The constructor stores the encoded data in an Attributes object.

Parameters:
data - DataObject that contains the attribute name (and possibly type) info
Method Detail

toDataObject

public DataObject toDataObject()
Converts to a DataObject.

Returns:
Attributes object converted to an DataObject

addAttribute

public void addAttribute(Attribute att)
Adds the given Attribute object to the container.

Parameters:
att - Attribute to add

addAttribute

public void addAttribute(java.lang.String name)
Adds the given attribute name.

Parameters:
name - Name of the attribute to add

addAttribute

public void addAttribute(java.lang.String name,
                         java.lang.String type)
Adds the given attribute name and data type

Parameters:
name - Name of the attribute to add
type - Datatype of the attribute to add

addAttribute

public void addAttribute(java.lang.String name,
                         Attributes attributes)
Adds the given attribute name and value to the container. It uses a default datatype.

Parameters:
name - Name of the attribute to add
attributes - SubAttributes of the attribute to add

addAttribute

public void addAttribute(java.lang.String name,
                         Attributes attributes,
                         java.lang.String type)
Adds the given attribute name, subAttributes and type to the container

Parameters:
name - Name of the attribute to add
attributes - SubAttributes of the attribute to add
type - Datatype of the attribute to add

replaceOrAdd

protected void replaceOrAdd(Attribute att)
guarantees that only one attribute of a given name resides in an Attributes. Note that this does not preclude multiple items of the same type.

Parameters:
att -

addAttributes

public void addAttributes(Attributes atts)
Adds the given Attributes object to the container.

Parameters:
atts - Attributes to add

addAttributeNameValue

public void addAttributeNameValue(AttributeNameValue att)
Adds the given AttributeNameValue object to the container.

Parameters:
att - AttributeNameValue to add

addAttributeNameValue

public void addAttributeNameValue(java.lang.String name)
Adds the given attribute name.

Parameters:
name - Name of the attribute to add

addAttributeNameValue

public void addAttributeNameValue(java.lang.String name,
                                  java.lang.Object value)
Adds the given attribute name and value to the container. It uses a default datatype.

Parameters:
name - Name of the attribute to add
value - Value of the attribute to add

addAttributeNameValue

public void addAttributeNameValue(java.lang.String name,
                                  java.lang.Object value,
                                  java.lang.String type)
Adds the given attribute name, value and type to the container

Parameters:
name - Name of the attribute to add
value - Value of the attribute to add
type - Datatype of the attribute to add

getAttributeAt

public Attribute getAttributeAt(int index)
Returns the Attribute object at the given index

Parameters:
index - Index into the container
Returns:
Attribute at the specified index

removeAttributeAt

public void removeAttributeAt(int index)
Removes the Attribute object at the given index

Parameters:
index - Index into the container

hasAttribute

public boolean hasAttribute(Attribute att)
Determines whether the given Attribute object is in the container

Parameters:
att - Attribute to check
Returns:
whether Attribute is in the container

hasAttribute

public boolean hasAttribute(java.lang.String name,
                            Attributes attributes)
Determines whether the given attribute name and subAttributes are in the container, using the default datatype.

Parameters:
name - Name of the attribute to check
attributes - SubAttributes of the attribute to check
Returns:
whether the given attribute name and subAttributes are in the container

hasAttribute

public boolean hasAttribute(java.lang.String name,
                            Attributes attributes,
                            java.lang.String type)
Determines whether the given attribute name, subAttributes and type are in the container,

Parameters:
name - Name of the attribute to check
attributes - SubAttributes of the attribute to check
type - Datatype of the attribute to check
Returns:
whether the given attribute name, subAttributes and type are in the container

indexOfAttribute

public int indexOfAttribute(Attribute att)
Returns the index at which the Attribute object occurs

Parameters:
att - Attribute to look for
Returns:
index of the specified Attribute

indexOfAttribute

public int indexOfAttribute(java.lang.String name,
                            Attributes attributes)
Returns the index at which the given attribute name and subAttributes occurs, using the default datatype

Parameters:
name - Name of the attribute to look for
attributes - SubAttributes of the attribute to look for
Returns:
index of the specified Attribute

indexOfAttribute

public int indexOfAttribute(java.lang.String name,
                            Attributes attributes,
                            java.lang.String type)
Returns the index at which the given attribute name, subAttributes and type occurs.

Parameters:
name - Name of the attribute to look for
attributes - SubAttributes of the attribute to look for
type - Datatype of the attribute to look for
Returns:
index of the specified Attribute

numAttributes

public int numAttributes()
Returns the number of Attributes in the container return the number of Attributes in the container


getAttribute

public Attribute getAttribute(java.lang.String name)
This method returns the Attribute with the given name from this list of Attributes.

Parameters:
name - of the Attribute to return
Returns:
Attribute with the given name

getAttribute

public Attribute getAttribute(java.lang.String name,
                              java.lang.String prefix)
This method returns the Attribute with the given name from this list of Attributes.

Parameters:
name - of the Attribute to return
prefix - Structure name to use
Returns:
Attribute with the given name

getAttributeNameValue

public AttributeNameValue getAttributeNameValue(java.lang.String name)
This method returns the AttributeNameValue with the given name from this list of AttributeNameValues.

Parameters:
name - of the AttributeNameValue to return
Returns:
AttributeNameValue with the given name

getAttributeNameValue

public AttributeNameValue getAttributeNameValue(java.lang.String name,
                                                java.lang.String prefix)
This method returns the AttributeNameValue with the given name from this list of AttributeNameValue.

Parameters:
name - of the AttributeNameValue to return
prefix - Structure name to use
Returns:
AttributeNameValue with the given name

removeAttribute

public void removeAttribute(java.lang.String name)
This method removes the Attribute with the given name from this list of Attributes. It's up to the caller to make sure the Attribute exists.

Parameters:
name - of the Attribute to remove

removeAttribute

public Attribute removeAttribute(java.lang.String name,
                                 java.lang.String prefix)
This method removes the Attribute with the given name from this list of Attributes. It's up to the caller to make sure the Attribute exists.

Parameters:
name - of the Attribute to remove
prefix - Structure name to use

getSubset

public Attributes getSubset(Attributes filterAtts)
This method takes an Attributes containing the list of attributes (names) wanted and it filters all the rest out from this Attributes object.

Returns:
filtered Attributes object

create

protected Attributes create()

toTypesHashtable

public java.util.Hashtable toTypesHashtable()
Converts the attributes name-type pairs to a hashtable where the keys are the names and the values are the types. AKD - problem if two attributes have same name but different types


toTypesHashtable

public java.util.Hashtable toTypesHashtable(java.lang.String prefix)
Converts the attributes name-type pairs to a hashtable where the keys are the names and the values are the types. This method allows the use of a prefix for structures. AKD - problem if two attributes have same name but different types


toAString

public java.lang.String toAString()
A printable version of this class.

Returns:
String version of this class

equals

public boolean equals(Attributes attributes)
Return true if both Attributes objects are equal

Parameters:
attributes -
Returns:
boolean