context.arch.storage
Class Attributes

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--java.util.Vector
                    |
                    +--context.arch.storage.Attributes

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 addAttributes(Attributes atts)
          Adds the given Attributes object to the container.
 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
 Attributes getSubset(Attributes atts)
          This method takes a DataObject 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
 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
 

Field Detail

SEPARATOR

public static final char SEPARATOR
Connector for nested attributes

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

ALL

public static final java.lang.String ALL
Tag to indicate all attributes are to be used
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

addAttributes

public void addAttributes(Attributes atts)
Adds the given Attributes object to the container.
Parameters:
atts - Attributes 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

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 atts)
This method takes a DataObject containing the list of attributes (names) wanted and it filters all the rest out from this Attributes object.
Parameters:
atts - Attributes object containing the attributes to return
Returns:
filtered Attributes object

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