IBM Branch Transformation Toolkit Javadoc

com.ibm.dse.base
Class KeyedCollection

java.lang.Object
  extended bycom.ibm.dse.base.DataElement
      extended bycom.ibm.dse.base.DataCollection
          extended bycom.ibm.dse.base.KeyedCollection
All Implemented Interfaces:
java.lang.Cloneable, DSECloneable, Externalizable, java.io.Externalizable, java.io.Serializable, TypedData
Direct Known Subclasses:
SessionEntry, SessionTable

public class KeyedCollection
extends DataCollection

Instances of this class contain data elements ordered by insertion or definition. This class provides a protocol for accessing the data elements by name or by position, and for changing and removing these elements.

See Also:
Serialized Form

Field Summary
protected  Hashtable elements
           
protected  Hashtable nestedElements
           
(package private)  int nextItem
           
protected  java.util.Vector order
           
 
Fields inherited from class com.ibm.dse.base.DataElement
description, externalizer, name, parameters, state
 
Constructor Summary
KeyedCollection()
          This is the default constructor used to create a KeyedCollection object.
KeyedCollection(int hsize, int vsize)
          This is the constructor used to create a KeyedCollection object .
KeyedCollection(java.lang.String aName)
          This is the constructor used by the externalizer used to create a KeyedCollection object.
 
Method Summary
 void addElement(DataElement aDataElement)
          Add an entry to the hashtable of elements using as key the dataElement name.
 void addElement(java.lang.String aName, java.lang.Object aValue, java.lang.String aPath, java.lang.String aType)
          Adds a data element (instance of aType) to the KeyedCollection when the dynamic behavior is active.
 Hashtable calculeNestedElements()
          Gets the nested elements property (java.util.Hashtable) value.
 Hashtable calculeNestedQualifiedElements()
          Returns a Hashtable with the elements present at any level of this KeyedCollection.
 java.lang.Object clone()
          Returns a new KeyedCollection cloned from the current one
 java.lang.String getDynamic()
          Gets the dynamic property (String) value.
 DataElement getElementAt(int index)
          Returns the value of the element located at the index position.
 DataElement getElementAt(java.lang.String aName)
          Returns the data element identified by its name.
 DataElement getElementAtAnyLevel(java.lang.String aName)
          Returns the first element that matches aName at any level of depth of the keyedCollection.
protected  DataElement getElementAtFirstLevel(java.lang.String aName)
          Returns the element that matches aName.
 Hashtable getElements()
          Gets the elements property (java.util.Hashtable) value.
 java.util.Enumeration getEnumeration()
          Returns the elements of the keyedCollection as an Enumeration.
 int getIndexOf(int from, java.lang.String aName)
          Returns the position of the element aName.
 int getIndexOf(java.lang.String aName)
          Returns the position of the element aName.
 Hashtable getNestedElements()
          Gets the nested elements property (java.util.Hashtable) value.
 Hashtable getOrder()
          Gets the order property (java.util.Hashtable) value.
 java.util.Vector getOrderVector()
          Gets the order property (java.util.Vector) value.
 java.lang.Object getValue()
          Returns the elements of the keyedCollections.
 java.lang.Object initializeFrom(Tag aTag)
          Initialize a keyedCollection from its tag in XML.
 boolean isDynamic()
          Returns the boolean value of the dynamic property.
 void readExternal(java.io.ObjectInput s)
          Invokes the object creation from an ObjectInput.
 void removeAll()
          Removes all elements of the keyedCollection.
 DataElement removeElementAt(int index)
          Removes the element at the index indicated by the index parameter.
 DataElement removeElementAt(java.lang.String aName)
          Removes the named data element.
protected  DataElement removeElementAtFirstLevel(java.lang.String aName)
          Removes the element identified by aName.
protected  void reorderElements(int from)
          Reorders all the elements from the index indicated by the from parameter to the last element.
 void setDynamic(boolean aValue)
          Sets the dynamic property value.
 void setDynamic(java.lang.String aValue)
          Sets the dynamic property (java.lang.String) value.
 void setElements(Hashtable anElements)
          Sets the elements property (java.util.Hashtable) value.
 void setOrder(Hashtable anOrder)
          Sets the order property (java.util.Vector) value from a Hashtable.
 void setOrder(java.util.Vector anOrder)
          Sets the order property (java.util.Hashtable) value.
 void setValue(java.lang.Object aValue)
          Sets the value to the KeyedCollection from a Hashtable.
 void setValueAt(java.lang.String aName, java.lang.Object aValue)
          This method calls the addElement method to create the DataElement aName with the value aValue.
 void setValueAt(java.lang.String aName, java.lang.Object aValue, java.lang.String aType)
          Calls the addElement() method to create the aName DataElement (instance of aType) with its value set to aValue.
 int size()
          Returns the number of elements in the keyedCollection.
static java.lang.String stringValueOf(int i)
          Returns the String of _stringValueOfInt[] using the relevant index.
 java.lang.String toString()
          Returns a visual representation of the keyedCollection.
 Vector toStrings()
          Returns a visual representation of the keyedCollection.
 DataElement tryGetElementAt(java.lang.String aName)
          Returns the data element identified by its name.
 DataElement tryGetElementAtAnyLevel(java.lang.String aName)
          Returns the first element that matches aName at any level of depth of the keyedCollection.
protected  DataElement tryGetElementAtFirstLevel(java.lang.String aName)
          Returns the element that matches aName.
 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)
          This method call the addElement method to create the DataElement aName with the value aValue.
 void writeExternal(java.io.ObjectOutput s)
          Provides concrete serialization handling for KeyedCollection.
 
Methods inherited from class com.ibm.dse.base.DataCollection
getValueAt, nestedElements, nestedElements, nestedFields, nestedKeyedCollections, nestedQualifiedElements, validate
 
Methods inherited from class com.ibm.dse.base.DataElement
externalizer, getDescription, getDescriptor, getErrorInfo, getExternalizer, getKey, getName, getParameter, getParameters, getState, getTagName, isAmended, readExternal, readObject, removeExternal, setAmended, setDescription, setDescriptor, setErrorInfo, setExternalizer, setName, setParameter, setParameters, setState, toTags, validate, validateObject, writeExternal
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

nextItem

int nextItem

elements

protected Hashtable elements

nestedElements

protected Hashtable nestedElements

order

protected java.util.Vector order
Constructor Detail

KeyedCollection

public KeyedCollection()
This is the default constructor used to create a KeyedCollection object.


KeyedCollection

public KeyedCollection(int hsize,
                       int vsize)
This is the constructor used to create a KeyedCollection object .


KeyedCollection

public KeyedCollection(java.lang.String aName)
                throws java.io.IOException
This is the constructor used by the externalizer used to create a KeyedCollection object.

Parameters:
aName - java.lang.String
Method Detail

addElement

public void addElement(DataElement aDataElement)
Add an entry to the hashtable of elements using as key the dataElement name.

Parameters:
aDataElement - DataElement

addElement

public void addElement(java.lang.String aName,
                       java.lang.Object aValue,
                       java.lang.String aPath,
                       java.lang.String aType)
                throws DSEInvalidArgumentException,
                       java.lang.ClassNotFoundException,
                       java.lang.InstantiationException,
                       java.lang.IllegalAccessException
Adds a data element (instance of aType) to the KeyedCollection when the dynamic behavior is active. This method adds the element to the position pointed to by the aPath parameter with its initial value set to aValue.

Parameters:
aName - java.lang.String. - The Name of the DataElement
aValue - Object. - The Value of the DataElement
aPath - java.lang.String. - The Path to the DataElement
aType - java.lang.String - The Type of the DataElement
Throws:
DSEInvalidArgumentException
java.lang.ClassNotFoundException
java.lang.InstantiationException
java.lang.IllegalAccessException

calculeNestedElements

public Hashtable calculeNestedElements()
Gets the nested elements property (java.util.Hashtable) value.

Returns:
- The nestedElements property value

calculeNestedQualifiedElements

public Hashtable calculeNestedQualifiedElements()
Returns a Hashtable with the elements present at any level of this KeyedCollection. Each entry has as key the qualified name of the DataElement and as value the DataElement object.

Returns:
Hashtable

clone

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

Specified by:
clone in interface DSECloneable
Specified by:
clone in class DataElement
Returns:
java.lang.Object
Throws:
java.lang.CloneNotSupportedException

getDynamic

public java.lang.String getDynamic()
Gets the dynamic property (String) value.

Returns:
The dynamic property value as String
See Also:
setDynamic(java.lang.String)

getElementAt

public DataElement getElementAt(int index)
                         throws DSEObjectNotFoundException
Returns the value of the element located at the index position.

Parameters:
index - int
Returns:
com.ibm.dse.base.DataElement
Throws:
DSEObjectNotFoundException

getElementAt

public DataElement getElementAt(java.lang.String aName)
                         throws DSEObjectNotFoundException
Returns the data element identified by its name. It is found by the path indicated in the aName parameter. The path is set by identifier strings separated by a period (.). An asterisk (*) specifies a search in any level of depth in this keyed collection.

Overrides:
getElementAt in class DataElement
Parameters:
aName - java.lang.String the path and name of the data element to be retrieved
Returns:
DataElement
Throws:
DSEObjectNotFoundException

getElementAtAnyLevel

public DataElement getElementAtAnyLevel(java.lang.String aName)
                                 throws DSEObjectNotFoundException
Returns the first element that matches aName at any level of depth of the keyedCollection.

Parameters:
aName - java.lang.String - The name of the data element to be retrieved
Returns:
com.ibm.dse.base.DataElement
Throws:
DSEObjectNotFoundException

getElementAtFirstLevel

protected DataElement getElementAtFirstLevel(java.lang.String aName)
                                      throws DSEObjectNotFoundException
Returns the element that matches aName. This method only searches in this first level and not in other levels.

Parameters:
aName - java.lang.String
Returns:
DataElement
Throws:
DSEObjectNotFoundException

getElements

public Hashtable getElements()
Gets the elements property (java.util.Hashtable) value.

Returns:
The elements property value
See Also:
setElements(com.ibm.dse.base.Hashtable)

getEnumeration

public java.util.Enumeration getEnumeration()
Returns the elements of the keyedCollection as an Enumeration.

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

getIndexOf

public int getIndexOf(int from,
                      java.lang.String aName)
Returns the position of the element aName. The search begins at the position indicated by the from parameter.

Returns:
int param from int - The position from which to start the search for the data element param aName String - The name of the data element to be retrieved

getIndexOf

public int getIndexOf(java.lang.String aName)
Returns the position of the element aName.

Returns:
int

getNestedElements

public Hashtable getNestedElements()
Gets the nested elements property (java.util.Hashtable) value.

Returns:
java.util.Hashtable - The nestedElements property value

getOrder

public Hashtable getOrder()
Gets the order property (java.util.Hashtable) value.

Returns:
java.util.Hashtable - The order property value
See Also:
setOrder(com.ibm.dse.base.Hashtable)

getOrderVector

public java.util.Vector getOrderVector()
Gets the order property (java.util.Vector) value.

Returns:
java.util.Vector - The order property value
See Also:
setOrder(com.ibm.dse.base.Hashtable)

getValue

public java.lang.Object getValue()
Returns the elements of the keyedCollections. 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
Initialize a keyedCollection from its tag in XML.

Parameters:
aTag - Tag
Returns:
java.lang.Object
Throws:
java.io.IOException

isDynamic

public boolean isDynamic()
Returns the boolean value of the dynamic property.

Returns:
boolean

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.lang.ClassNotFoundException
java.io.IOException

removeAll

public void removeAll()
Removes all elements of the keyedCollection.


removeElementAt

public DataElement removeElementAt(int index)
                            throws DSEObjectNotFoundException
Removes the element at the index indicated by the index parameter.

Parameters:
index - int
Returns:
com.ibm.dse.base.DataElement
Throws:
com.ibm.dse.base.DSEObjectNotFoundException.
DSEObjectNotFoundException

removeElementAt

public DataElement removeElementAt(java.lang.String aName)
                            throws DSEObjectNotFoundException
Removes the named data element. It is found by the path indicated in the aName parameter. The paths are set by identifier strings separated by a period (.). For security reasons the asterisk (*) is not allowed in the path aName.

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

removeElementAtFirstLevel

protected DataElement removeElementAtFirstLevel(java.lang.String aName)
                                         throws DSEObjectNotFoundException
Removes the element identified by aName.

Parameters:
aName - java.lang.String
Returns:
DataElement
Throws:
DSEObjectNotFoundException

reorderElements

protected void reorderElements(int from)
Reorders all the elements from the index indicated by the from parameter to the last element.

Parameters:
from - int
Throws:
DSEObjectNotFoundException

setDynamic

public void setDynamic(java.lang.String aValue)
Sets the dynamic property (java.lang.String) value.

See Also:
getDynamic()

setDynamic

public void setDynamic(boolean aValue)
Sets the dynamic property value.

See Also:
getDynamic()

setElements

public void setElements(Hashtable anElements)
Sets the elements property (java.util.Hashtable) value.

See Also:
getElements()

setOrder

public void setOrder(Hashtable anOrder)
Sets the order property (java.util.Vector) value from a Hashtable.

See Also:
getOrder()

setOrder

public void setOrder(java.util.Vector anOrder)
Sets the order property (java.util.Hashtable) value.

Parameters:
anOrder - - The new value for the property
See Also:
getOrder()

setValue

public void setValue(java.lang.Object aValue)
              throws DSEInvalidArgumentException
Sets the value to the KeyedCollection from a Hashtable. This method first initializes the KeyedCollection and then, with the value of the parameter, gives a new value to the KeyedCollection. The nextItem, elements, netedElements and order attributes are modified.

Overrides:
setValue in class DataCollection
Parameters:
aValue - java.lang.Object - Must be a Hastable. The keys are Strings that represent the names of the dataelement and the values of this keys are the DataElements Objects.
Throws:
DSEInvalidArgumentException - - The parameter is not a Hashtable Object

setValueAt

public void setValueAt(java.lang.String aName,
                       java.lang.Object aValue)
                throws DSEInvalidArgumentException,
                       DSEObjectNotFoundException
This method calls the addElement method to create the DataElement aName with the value aValue.

Overrides:
setValueAt in class DataCollection
Parameters:
aName - java.lang.String
Returns:
java.lang.Object
Throws:
DSEInvalidArgumentException
DSEObjectNotFoundException

setValueAt

public void setValueAt(java.lang.String aName,
                       java.lang.Object aValue,
                       java.lang.String aType)
                throws DSEInvalidArgumentException,
                       DSEObjectNotFoundException
Calls the addElement() method to create the aName DataElement (instance of aType) with its value set to aValue.

Parameters:
aName - java.lang.String
aType - java.lang.String
Throws:
DSEInvalidArgumentException
com.ibm.dse.base.DSEObjectNotFoundException.
DSEObjectNotFoundException

size

public int size()
Returns the number of elements in the keyedCollection.

Returns:
int

stringValueOf

public static java.lang.String stringValueOf(int i)
Returns the String of _stringValueOfInt[] using the relevant index.

Parameters:
i - int
Returns:
java.lang.String

toString

public java.lang.String toString()
Returns a visual representation of the keyedCollection.

Returns:
java.lang.String

toStrings

public Vector toStrings()
Returns a visual representation of the keyedCollection.

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

tryGetElementAt

public DataElement tryGetElementAt(java.lang.String aName)
Returns the data element identified by its name. It is found by the path indicated in the aName parameter. The path is set by identifier strings separated by a period (.). An asterisk (*) specifies a search in any level of depth in this keyed collection.

Overrides:
tryGetElementAt in class DataElement
Parameters:
aName - java.lang.String - The path and name of the data element to be retrieved
Returns:
DataElement

tryGetElementAtAnyLevel

public DataElement tryGetElementAtAnyLevel(java.lang.String aName)
Returns the first element that matches aName at any level of depth of the keyedCollection.

Parameters:
aName - java.lang.String - The name of the data element to be retrieved
Returns:
com.ibm.dse.base.DataElement

tryGetElementAtFirstLevel

protected DataElement tryGetElementAtFirstLevel(java.lang.String aName)
Returns the element that matches aName. This method only searches in this first level and not in other levels.

Parameters:
aName - 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
This method call the addElement method to create the DataElement aName with the value aValue.

Parameters:
aName - java.lang.String
Returns:
int, 0:success; -1:DSEObjectNotFoundException
Throws:
com.ibm.dse.base.DSEInvalidArgumentException.
com.ibm.dse.base.DSEObjectNotFoundException.
DSEInvalidArgumentException

writeExternal

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

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