com.ibm.dse.base
Class KeyedCollection

java.lang.Object
  |
  +--com.ibm.dse.base.DataElement
        |
        +--com.ibm.dse.base.DataCollection
              |
              +--com.ibm.dse.base.KeyedCollection
Direct Known Subclasses:
CashDrawer, Counter, 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

Fields inherited from class com.ibm.dse.base.DataElement
description, name, state
 
Constructor Summary
KeyedCollection()
          This is the default 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 Hastable 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 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.lang.Object getValue()
          Returns the elements of the keyedCollections.
 java.lang.Object initializeFrom(Tag aTag)
          Initialize a keyedCollection from its tag in SGML.
 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()
          Remove 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(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.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 call 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.
 java.lang.String toString()
          Returns a visual representation of the keyedCollection.
 Vector toStrings()
          Returns a visual representation of the keyedCollection.
 java.lang.Object validate(java.lang.Object toValidate)
          Validates the object passing it to its descriptor and if successful, the object is returned, otherwise an appropriate exception is thrown.
 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
 
Methods inherited from class com.ibm.dse.base.DataElement
externalizer, getDescription, getDescriptor, getErrorInfo, getExternalizer, getKey, getName, getState, getTagName, readExternal, readObject, removeExternal, setDescription, setDescriptor, setErrorInfo, setExternalizer, setName, setState, toTags, writeExternal
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

KeyedCollection

public KeyedCollection()
This is the default 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 Hastable 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
Overrides:
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.
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 by its name. It is found by the path indicated in the aName parameter. The path are 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
Returns:
DataElement

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
Returns:
com.ibm.dse.base.DataElement

getElementAtFirstLevel

protected DataElement getElementAtFirstLevel(java.lang.String aName)
                                      throws DSEObjectNotFoundException
Returns the element that matches aName. This method only search in this first level, not in other levels of depth.
Parameters:
aName - java.lang.String
Returns:
DataElement

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.
Overrides:
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 frm int param aName String

getIndexOf

public int getIndexOf(java.lang.String aName)
Returns the position of the element aName.
Parameters:
String - theName
Returns:
int

getNestedElements

public Hashtable getNestedElements()
Gets the nested elements property (java.util.Hashtable) value.
Returns:
The nestedElements property value.

getOrder

public Hashtable getOrder()
Gets the order property (java.util.Hashtable) value.
Returns:
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.
Overrides:
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 SGML.
Parameters:
aTag - Tag
Returns:
java.lang.Object

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.
Overrides:
readExternal in class DataElement
Parameters:
s - java.io.ObjectInput
Throws:
java.io.IOException. -  
java.lang.ClassNotFoundException. -  

removeAll

public void removeAll()
Remove 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. -  

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 path are set by identifier strings separated by a period (.). An asterisk (*) specifies a search in any level of depth in this keyed collection.
Overrides:
removeElementAt in class DataElement
Parameters:
aName - java.lang.String
Returns:
DataElement

removeElementAtFirstLevel

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

reorderElements

protected void reorderElements(int from)
                        throws DSEObjectNotFoundException
Reorders all the elements from the index indicated by the from parameter to the last element.
Parameters:
from - int
Throws:
com.ibm.dse.base.DSEObjectNotFoundException. -  

setDynamic

public void setDynamic(java.lang.String aValue)
Sets the dynamic property (java.lang.String) value.
Parameters:
String - aValue The new value for the property.
See Also:
getDynamic()

setElements

public void setElements(Hashtable anElements)
Sets the elements property (java.util.Hashtable) value.
Parameters:
elements - The new value for the property.
See Also:
getElements()

setOrder

public void setOrder(Hashtable 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. 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 will be 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 call the addElement method to create the DataElement aName with the value aValue
Overrides:
setValueAt in class DataCollection
Parameters:
aName - java.lang.String
aKeyedCollection - KeyedCollection
aType - java.lang.String
Throws:
com.ibm.dse.base.DSEInvalidArgumentException. -  
com.ibm.dse.base.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
aKeyedCollection - KeyedCollection
aType - java.lang.String
Throws:
DSEInvalidArgumentException -  
com.ibm.dse.base.DSEObjectNotFoundException. -  

size

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

toString

public java.lang.String toString()
Returns a visual representation of the keyedCollection.
Overrides:
toString in class java.lang.Object
Returns:
java.lang.String

toStrings

public Vector toStrings()
Returns a visual representation of the keyedCollection.
Overrides:
toStrings in class DataElement
Returns:
Vector

validate

public java.lang.Object validate(java.lang.Object toValidate)
                          throws DSETypeException
Validates the object passing it to its descriptor and if successful, the object is returned, otherwise an appropriate exception is thrown. In the last case the exception thrown will have information about all the elements that have not been validated inside the KeyedCollection.
Overrides:
validate in class DataElement
Parameters:
toValidate - java.lang.Object
Returns:
java.lang.Object
Throws:
DSETypeException - If the object has not been validated

writeExternal

public void writeExternal(java.io.ObjectOutput s)
                   throws java.io.IOException
Provides concrete serialization handling for KeyedCollection.
Overrides:
writeExternal in class DataElement
Parameters:
s - java.io.ObjectOutput
Throws:
java.io.IOException. -