IBM Branch Transformation Toolkit Javadoc

com.ibm.btt.base
Class IndexedCollection

java.lang.Object
  extended bycom.ibm.btt.base.DataElement
      extended bycom.ibm.btt.base.DataCollection
          extended bycom.ibm.btt.base.IndexedCollection
All Implemented Interfaces:
java.lang.Cloneable, DSECloneable, Externalizable, java.io.Externalizable, java.io.Serializable, TypedData

public class IndexedCollection
extends DataCollection

This class contains a collection of elements of the same class ordered by index.

See Also:
Serialized Form

Field Summary
static java.lang.String defaultName
           
protected  Vector elements
           
 
Fields inherited from class com.ibm.btt.base.DataElement
description, externalizer, name, parameters, state
 
Constructor Summary
IndexedCollection()
          This is the default constructor used to create an IndexedCollection object.
IndexedCollection(java.lang.String aName)
          This constructor creates an IndexedCollection object with a specified name.
 
Method Summary
 void addElement(DataElement aDataElement)
          Adds an element at the end of the collection.
 void addElement(java.lang.String aName, java.lang.Object aValue, java.lang.String aType, int aPosition)
           
 java.lang.Object clone()
          Returns a new IndexedCollection cloned from the current one.
 DataElement createElement(boolean shareDescriptor)
          Returns a new DataElement to be inserted in the indexed collection that can share the same descriptors of the existing elements.
 DataElement createElementSharingDescriptors(DataElement sourceDataElement)
          Creates a new DataElement that shares the same descriptor than the DataElement passed.
 DataElement getDataElement()
          Gets the dataElement defined if the indexed collection size is zero.
 DataElement getElementAt(int anIdentifier)
          Returns the element located at the index anIdentifier.
 DataElement getElementAt(java.lang.String anIdentifier)
          Performs a recursive search of the element.
 java.util.Vector getElements()
          Returns the value of elements.
 Tag getElementSubTag()
          Sets the data element.
 java.util.Enumeration getEnumeration()
          Returns the IndexedCollection's elements as an Enumeration.
 java.lang.Object getValue()
          Returns the Indexed Collection's elements.
 java.lang.Object initializeFrom(Tag aTag)
          Initializes an IndexedCollection with the attributes in aTag.
 void nestedQualifiedElements(java.util.Hashtable theTable, java.lang.String Path)
          Adds as qualified name all elements of this IndexedCollection to the Hashtable passed by parameter.
 void readExternal(java.io.ObjectInput s)
          Invokes the object creation from an ObjectInput.
 void removeAll()
          Removes all elements.
 DataElement removeElementAt(int anIndex)
          Remove the element at the index marked by anIndex.
 DataElement removeElementAt(java.lang.String anIdentifier)
          Performs a recursive search for the element.
 void setDataElement(DataElement aDataElement)
          Sets the data element.
 void setElements(Vector aVector)
          Sets the value of elements.
 void setElementSubTag(Tag aSubTag)
          Sets the data element.
 void setValue(java.lang.Object aValue)
          Validates the value to be set and if it succeeds then sets the value to the IndexedCollection from a Vector of DataElements.
 int size()
          Returns the number of elements.
 java.lang.String toString()
          Returns a visual representation of this data.
 Vector toStrings()
          Returns a Vector containing a visual representation of this data.
 Vector toTags()
          Returns a Vector with the indexed collection represented as a Tag.
 DataElement tryGetElementAt(int anIdentifier)
          Returns the element located at the index anIdentifier.
 DataElement tryGetElementAt(java.lang.String anIdentifier)
          Performs a recursive search of the element.
 java.lang.Object tryGetValueAt(java.lang.String aCompositeKey)
          Returns the value of an element located in the path aCompositeKey.
 int trySetValueAt(java.lang.String aName, java.lang.Object aValue)
          Sets the value of an element located in the aCompositeKey path.
 java.lang.Object validate(java.lang.Object toValidate)
          Validates the object passed (that must be an indexed collection or a vector) and if successful, the object is returned, otherwise an appropriate exception is thrown.
 void writeExternal(java.io.ObjectOutput s)
          Provides concrete serialization handling for IndexedCollection.
 
Methods inherited from class com.ibm.btt.base.DataCollection
getValueAt, nestedElements, nestedElements, nestedFields, nestedKeyedCollections, setValueAt, validate
 
Methods inherited from class com.ibm.btt.base.DataElement
externalizer, getCompositeKey, getDescription, getDescriptor, getErrorInfo, getExternalizer, getKey, getName, getParameter, getParameters, getState, getTagName, isAmended, isCached, isSerializable, readExternal, readObject, removeExternal, setAmended, setCompositeKey, setDescription, setDescriptor, setErrorInfo, setExternalizer, setIsCached, setName, setParameter, setParameters, setSerializable, setState, validateObject, writeExternal
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

elements

protected Vector elements

defaultName

public static final java.lang.String defaultName
See Also:
Constant Field Values
Constructor Detail

IndexedCollection

public IndexedCollection()
This is the default constructor used to create an IndexedCollection object.


IndexedCollection

public IndexedCollection(java.lang.String aName)
                  throws java.io.IOException
This constructor creates an IndexedCollection object with a specified name.

Method Detail

addElement

public void addElement(DataElement aDataElement)
Adds an element at the end of the collection.

Parameters:
aDataElement - - The element to be added

addElement

public void addElement(java.lang.String aName,
                       java.lang.Object aValue,
                       java.lang.String aType,
                       int aPosition)
                throws DSEInvalidArgumentException,
                       java.lang.ClassNotFoundException,
                       java.lang.InstantiationException,
                       java.lang.IllegalAccessException
Throws:
DSEInvalidArgumentException
java.lang.ClassNotFoundException
java.lang.InstantiationException
java.lang.IllegalAccessException

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Returns a new IndexedCollection cloned from the current one.

Specified by:
clone in interface DSECloneable
Specified by:
clone in class DataElement
Returns:
com.ibm.btt.base.DataElement - The new indexed collection
Throws:
java.lang.CloneNotSupportedException

createElement

public DataElement createElement(boolean shareDescriptor)
                          throws DSEInvalidRequestException
Returns a new DataElement to be inserted in the indexed collection that can share the same descriptors of the existing elements.

Parameters:
shareDescriptor - - True if the descriptors can be shared
Returns:
com.ibm.btt.base.DataElement - The new DataElement
Throws:
DSEInvalidRequestException

createElementSharingDescriptors

public DataElement createElementSharingDescriptors(DataElement sourceDataElement)
                                            throws DSEInvalidRequestException
Creates a new DataElement that shares the same descriptor than the DataElement passed.

Parameters:
sourceDataElement -
Returns:
com.ibm.btt.base.DataElement - The new DataElement
Throws:
DSEInvalidRequestException

getDataElement

public DataElement getDataElement()
Gets the dataElement defined if the indexed collection size is zero.

Returns:
com.ibm.btt.base.DataElement

getElementAt

public DataElement getElementAt(int anIdentifier)
                         throws DSEObjectNotFoundException
Returns the element located at the index anIdentifier.

Throws:
DSEObjectNotFoundException

getElementAt

public DataElement getElementAt(java.lang.String anIdentifier)
                         throws DSEObjectNotFoundException
Performs a recursive search of the element. If it is the last element in the path, the method calls the getElementAt(int) method.

Overrides:
getElementAt in class DataElement
Parameters:
anIdentifier - java.lang.String
Returns:
DataElement
Throws:
DSEObjectNotFoundException

getElements

public java.util.Vector getElements()
Returns the value of elements.

Returns:
java.util.Vector

getElementSubTag

public Tag getElementSubTag()
Sets the data element.


getEnumeration

public java.util.Enumeration getEnumeration()
Returns the IndexedCollection's elements as an Enumeration.

Specified by:
getEnumeration in class DataCollection
Returns:
java.util.Enumeration

getValue

public java.lang.Object getValue()
Returns the Indexed Collection's elements. This method is implemented to provide polymorphism.

Specified by:
getValue in class DataElement
Returns:
java.lang.Object

initializeFrom

public java.lang.Object initializeFrom(Tag aTag)
                                throws java.io.IOException
Initializes an IndexedCollection with the attributes in aTag.

Parameters:
aTag - Externalization.Tag
Returns:
Externalizable
Throws:
java.io.IOException

nestedQualifiedElements

public void nestedQualifiedElements(java.util.Hashtable theTable,
                                    java.lang.String Path)
Adds as qualified name all elements of this IndexedCollection to the Hashtable passed by parameter. Each entry has as a key the qualified name of the DataElement and as value the DataElement object.

Overrides:
nestedQualifiedElements in class DataCollection
Parameters:
theTable - java.util.Hashtable
Path - String - The path where the IndexedCollection is

readExternal

public void readExternal(java.io.ObjectInput s)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Invokes the object creation from an ObjectInput.

Specified by:
readExternal in interface java.io.Externalizable
Overrides:
readExternal in class DataElement
Parameters:
s - java.io.ObjectInput
Throws:
java.io.IOException.
java.lang.ClassNotFoundException.
java.io.IOException
java.lang.ClassNotFoundException

removeAll

public void removeAll()
Removes all elements.


removeElementAt

public DataElement removeElementAt(int anIndex)
                            throws DSEObjectNotFoundException
Remove the element at the index marked by anIndex.

Parameters:
anIndex - int
Returns:
DataElement
Throws:
DSEObjectNotFoundException

removeElementAt

public DataElement removeElementAt(java.lang.String anIdentifier)
                            throws DSEObjectNotFoundException
Performs a recursive search for the element. If it is the last element in the path, this method calls the removeElementAt(int) method.

Overrides:
removeElementAt in class DataElement
Parameters:
anIdentifier - java.lang.String
Returns:
DataElement
Throws:
DSEObjectNotFoundException

setDataElement

public void setDataElement(DataElement aDataElement)
Sets the data element.

Parameters:
aDataElement - com.ibm.btt.base.DataElement

setElements

public void setElements(Vector aVector)
Sets the value of elements.

Parameters:
aVector - java.util.Vector

setElementSubTag

public void setElementSubTag(Tag aSubTag)
Sets the data element.


setValue

public void setValue(java.lang.Object aValue)
              throws DSEInvalidArgumentException
Validates the value to be set and if it succeeds then sets the value to the IndexedCollection from a Vector of DataElements. The elements attribute will contain a cloned Vector from the Vector passed by parameter. The subTag attribute will contain a Tag Object constructed from "toString()" representation of first vector's element. The DataElement attribute will contain a new DataElement build from the subTag attribute.

Overrides:
setValue in class DataCollection
Parameters:
aValue - java.lang.Object - Must be a Vector of DataElements
Throws:
DSEInvalidArgumentException - - The parameter is not a Vector

size

public int size()
Returns the number of elements.

Returns:
int

toString

public java.lang.String toString()
Returns a visual representation of this data.

Returns:
String

toStrings

public Vector toStrings()
Returns a Vector containing a visual representation of this data.

Specified by:
toStrings in interface Externalizable
Overrides:
toStrings in class DataElement
Returns:
Vector

toTags

public Vector toTags()
              throws java.io.IOException
Returns a Vector with the indexed collection represented as a Tag.

Specified by:
toTags in interface Externalizable
Overrides:
toTags in class DataElement
Returns:
Tag
Throws:
java.io.IOException

tryGetElementAt

public DataElement tryGetElementAt(int anIdentifier)
Returns the element located at the index anIdentifier.


tryGetElementAt

public DataElement tryGetElementAt(java.lang.String anIdentifier)
Performs a recursive search of the element. If it is the last element in the path, the method calls the getElementAt(int) method.

Overrides:
tryGetElementAt in class DataElement
Parameters:
anIdentifier - java.lang.String
Returns:
DataElement

tryGetValueAt

public java.lang.Object tryGetValueAt(java.lang.String aCompositeKey)
Returns the value of an element located in the path aCompositeKey. Returns null if the element is not found or if it is found but has a null value.

Parameters:
aCompositeKey - java.lang.String
Returns:
java.lang.Object

trySetValueAt

public int trySetValueAt(java.lang.String aName,
                         java.lang.Object aValue)
                  throws DSEInvalidArgumentException
Sets the value of an element located in the aCompositeKey path.

Returns:
int, 0:success; -1:DSEObjectNotFoundException
Throws:
DSEInvalidArgumentException

validate

public java.lang.Object validate(java.lang.Object toValidate)
                          throws DSETypeException
Validates the object passed (that must be an indexed collection or a vector) and if successful, the object is returned, otherwise an appropriate exception is thrown.

Overrides:
validate in class DataElement
Returns:
java.lang.Object
Throws:
DSETypeException - - Thrown if the validation is unsuccessful

writeExternal

public void writeExternal(java.io.ObjectOutput s)
                   throws java.io.IOException
Provides concrete serialization handling for IndexedCollection.

Specified by:
writeExternal in interface java.io.Externalizable
Overrides:
writeExternal in class DataElement
Parameters:
s - java.io.ObjectOutput
Throws:
java.io.IOException

IBM Branch Transformation Toolkit Javadoc

(c) Copyright IBM Corporation 1998, 2005