IBM WebSphere Multichannel Bank Transformation Toolkit Javadoc

com.ibm.btt.base
Interface Context

All Superinterfaces:
java.io.Externalizable, java.io.Serializable
All Known Implementing Classes:
ContextImpl, LocalContextImpl

This class is the basic repository of data and services.
 
 Instances of this class can be linked, or chained, in a tree of contexts, and
 the instances are capable of navigating over this tree, always in the upper
 direction. The instances of this class also can be passed as parameters of
 the format() and unformat() methods of a record format.


Method Summary
 void addChild(Context aNewChild)
          

Method Detail

addChild

void addChild(Context aNewChild)
              throws DSEInvalidRequestException
Adds a child specified by the parameter to the children list of current context. Both the child and parent must be local contexts. Or, both of them must be remote contexts.

Parameters:
aNewChild -
Throws:
DSEInvalidRequestException

addElement

void addElement(DataElement aDataElement)
                throws DSEInvalidRequestException
Adds an element to its keyedCollection.

Parameters:
aDataElement -
Throws:
DSEInvalidRequestException

chainTo

void chainTo(Context aContext)
             throws DSEInvalidRequestException
Chains this context to aContext. This method verifies the consistency of the resultant context tree and changes the parent and children attributes of its respective contexts.

Parameters:
aContext -
Throws:
DSEInvalidRequestException

clearKeyedCollection

void clearKeyedCollection()
                          throws DSEInvalidRequestException
Clears the context (current level only) by destroying the current keyed collection associated and replacing it with a new one.

Throws:
DSEInvalidRequestException

clearKeyedCollection

void clearKeyedCollection(boolean keepKCollStatus,
                          boolean clearOnlyValues)
                          throws java.io.IOException,
                                 DSEInvalidRequestException
This method clears both the typed and non-typed elements in the context keyed collection. It can clear only the elements of the kColl and keep the kColl attributes. For the kColl elements it is possible to clear only the values or to clear all the attributes.

Parameters:
keepKCollStatus - boolean (false - clear also the context kColl attributes; true - keep the context kColl attributes and clear only the kColl data elements)
clearOnlyValues - boolean (false - clear all attributes of the context kColl data elements; true - clear only kColl data elements values)
Throws:
java.io.IOException - - If keepKCollStatus or clearOnlyValues are false and the keyed collection has not been defined in the generic data file or in the generic types file
DSEInvalidRequestException

containsChild

boolean containsChild(java.lang.String aContextName)
                      throws DSEInvalidRequestException
Returns true if this context has a child with the name aContextName. It returns false otherwise.

Parameters:
aContextName -
Returns:
Throws:
DSEInvalidRequestException

externalizer

Externalizer externalizer()
Returns the externalizer instance of this class. This method can not be used in CHA Facade.

Returns:
Externalizer

fields

Vector fields()
              throws DSEInvalidRequestException
Returns all the data fields, which are addressable from this context. This includes all the data fields of this context and the upper context.

Returns:
Throws:
DSEInvalidRequestException

getAncestorByName

Context getAncestorByName(java.lang.String aContextName)
                          throws DSEInvalidRequestException
Searches the context tree for an ancestor Context named aContextName and returns the first matching context.

Parameters:
aContextName -
Returns:
Throws:
DSEInvalidRequestException

getChildrenAtAnyLevel

Vector getChildrenAtAnyLevel()
                             throws DSEInvalidRequestException
Get the children of a remote context at any level from the context tree.

Returns:
Throws:
DSEInvalidRequestException

getChildren

Vector getChildren()
                   throws DSEInvalidRequestException
Returns the children contexts of this one.

Returns:
Throws:
DSEInvalidRequestException

getContextByType

Context getContextByType(java.lang.String aTypeName)
                         throws DSEInvalidRequestException
Returns the first context that matches its type to aTypeName.

Parameters:
aTypeName -
Returns:
Throws:
DSEInvalidRequestException

getNextContextHorizontal

Context getNextContextHorizontal()
                                 throws DSEInvalidRequestException
The method used to iterate over the context tree.

Returns:
Throws:
DSEInvalidRequestException

getNextContextVertical

Context getNextContextVertical(Context parentContext)
                               throws DSEInvalidRequestException
Search the context tree from Vertical direction

Parameters:
parentContext -
Returns:
Throws:
DSEInvalidRequestException

getElementAt

DataElement getElementAt(java.lang.String aCompositeKey)
                         throws DSEObjectNotFoundException
Returns the element of its keyedCollection,or keyedCollections of the upper contexts which is located at aCompositeKey path.

Parameters:
aCompositeKey -
Returns:
Throws:
DSEObjectNotFoundException

getKeyedCollection

KeyedCollection getKeyedCollection()
                                   throws DSEInvalidRequestException
Returns the keyedCollection attribute.

Returns:
Throws:
DSEInvalidRequestException

getName

java.lang.String getName()
Return the name attribute.


getParent

Context getParent()
                  throws DSEInvalidRequestException
Returns the parent attribute.

Returns:
Throws:
DSEInvalidRequestException

getTagName

java.lang.String getTagName()
Returns a String used by the externalizer. This method can not be call in CHA Facade

Returns:
java.lang.String

getType

java.lang.String getType()
                         throws DSEInvalidRequestException
Returns the "type" attribute.

Returns:
Throws:
DSEInvalidRequestException

getValueAt

java.lang.Object getValueAt(java.lang.String aCompositeKey)
                            throws DSEObjectNotFoundException
Returns the value of the element of its keyedCollection, or keyedCollections of the upper contexts, located in the "aCompositeKey" path.

Parameters:
aCompositeKey -
Returns:
Throws:
DSEObjectNotFoundException

hasChildren

boolean hasChildren()
                    throws DSEInvalidRequestException
Returns true if this context has any children.

Returns:
Throws:
DSEInvalidRequestException

initializeFrom

java.lang.Object initializeFrom(Tag aTag)
                                throws java.io.IOException,
                                       DSEException
Initializes a Context with the Tag attributes. This method can not be executed in CHA Facade

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

isAddToDynamicKColl

boolean isAddToDynamicKColl()
                            throws DSEInvalidRequestException
Returns the value of the addToDynamicKColl property.

Returns:
Throws:
DSEInvalidRequestException

isChained

boolean isChained()
                  throws DSEInvalidRequestException
Returns true if this context is in the context tree.

Returns:
Throws:
DSEInvalidRequestException

isRoot

boolean isRoot()
               throws DSEInvalidRequestException
Returns true if this context is the root context.

Returns:
Throws:
DSEInvalidRequestException

prune

void prune()
           throws DSEInvalidRequestException,
                  DSEObjectNotFoundException
Removes this context and its children from the context tree from both memory and DB.

Throws:
DSEInvalidRequestException
DSEObjectNotFoundException

readExternal

void readExternal()
                  throws java.io.IOException
Initializes a dataElement with its external value. This instance requires an id (name) and the Externalizer and its tagInputStream are initialized.

Throws:
java.io.IOException

readExternal

void readExternal(TagInputStream aTIS)
                  throws java.io.IOException
Initializes this instance with values read from a file. Call this method only when the Externalizer has not initialized its tagStream. Once the tagStream is initialized, the method to call is readExternal()

Parameters:
aTIS -
Throws:
java.io.IOException

readExternal

void readExternal(java.io.ObjectInput s)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Invokes the object creation from an ObjectInput. The ObjectInput has a context and all of its children.

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

readFromStream

void readFromStream(java.io.ObjectInput s)
                    throws java.io.IOException,
                           java.lang.ClassNotFoundException
Invokes the object creation from an ObjectInput. The ObjectInput has a context and all of its children.

Parameters:
s - java.io.ObjectInput
Throws:
java.io.IOException.
java.lang.ClassNotFoundException.
java.io.IOException
java.lang.ClassNotFoundException

removeAt

DataElement removeAt(java.lang.String aCompositeKey)
                     throws DSEObjectNotFoundException,
                            DSEInvalidRequestException
Removes aCompositeKey element of its keyedCollection.

Parameters:
aCompositeKey -
Returns:
Throws:
DSEObjectNotFoundException
DSEInvalidRequestException

removeAtAnyLevel

DataElement removeAtAnyLevel(java.lang.String aCompositeKey)
                             throws DSEObjectNotFoundException,
                                    DSEInvalidRequestException
Removes an element of its keyedCollection, or the keyedCollections in the upper contexts, located in the aCompositeKey path.

Parameters:
aCompositeKey -
Returns:
Return null if the dataElment specified by parameter aCompositeKey is not able to removed. return the dataElment specified by parameter aCompositeKey if the dataElment is removed successfully.
Throws:
DSEObjectNotFoundException
DSEInvalidRequestException

removeChild

void removeChild(Context aContext)
                 throws DSEObjectNotFoundException,
                        DSEInvalidRequestException
Removes a child of this context from the context tree. If the child that will be removed contains children, please do not use this method. Otherwise, we will leave the child's children be orphan.

Parameters:
aContext -
Throws:
DSEObjectNotFoundException
DSEInvalidRequestException

removeInstance

void removeInstance()
                    throws DSEInvalidRequestException
The method used to remove the current context if it is a remote context. Since this method do not maintain the relationship among contexts, our customers are advised not to use it in the application code. Use prune() method, instead.

Throws:
DSEInvalidRequestException

removeChild

void removeChild(java.lang.String childInstanceID)
                 throws DSEInvalidRequestException
Remove the child-parent relationship between this context and its child context specified by the parameter childInstanceID

Parameters:
childInstanceID -
Throws:
DSEInvalidRequestException

removeExternal

void removeExternal()
                    throws java.io.IOException
Removes the object's tags from the file in which the object is externalized.

Throws:
java.io.IOException

setAddToDynamicKColl

void setAddToDynamicKColl(boolean newValue)
                          throws DSEInvalidRequestException
Sets the value of the addToDynamicKColl property.

Parameters:
newValue -
Throws:
DSEInvalidRequestException

setChildren

void setChildren(Vector aChildrenCollection)
                 throws DSEInvalidRequestException
Sets the children property. If a remote Context calls this method, do nothing.

Parameters:
aChildrenCollection -
Throws:
DSEInvalidRequestException

setKeyedCollection

void setKeyedCollection(KeyedCollection aKeyedCollection)
                        throws DSEInvalidRequestException
Sets the attribute keyedCollection.

Parameters:
aKeyedCollection -
Throws:
DSEInvalidRequestException

setName

void setName(java.lang.String aContextName)
Sets the name property of this context.


setType

void setType(java.lang.String aContextType)
             throws DSEInvalidRequestException
Sets the type property of this context.

Parameters:
aContextType -
Throws:
DSEInvalidRequestException

setValueAt

int setValueAt(SortedTable aSortedTable)
               throws DSEInvalidRequestException
The function is similiar to setValueAt(String, Object) except that set pairs of keys and values stored in aSortedTable via one method. Behind this method, when this context is a distributed context, the pairs of keys and values stored in aSortedTable will be sent to CHA server a time, thus improving performance.

Parameters:
aSortedTable -
Returns:
int = 0 : success int = 1,2,...,n: a value is failed to set which is indicated by return int value. For example, if return value is 1, the first value in aSortedTable can not be set successfully. if return value is 2, the first value is set successfully, but the second value is failed to be set and subsequent pairs of the keys and values will not be set .
Throws:
DSEInvalidRequestException

toString

java.lang.String toString()
Returns an XML representation of this context.

Overrides:
toString in class java.lang.Object
Returns:
java.lang.String

toStrings

Vector toStrings()
Returns a visual representation of this context.

Returns:
Vector

toTags

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

Returns:
Vector
Throws:
java.io.IOException

tryGetElementAt

DataElement tryGetElementAt(java.lang.String aCompositeKey)
Returns the element of its keyedCollection, or keyedCollections of the upper contexts which is located at aCompositeKey path. If the element does not exist or some network errors occur, return null.

Parameters:
aCompositeKey -
Returns:
Throws:
DSEObjectNotFoundException

tryGetValueAt

java.lang.Object tryGetValueAt(java.lang.String aCompositeKey)
Returns the value of the element of its keyedCollection, or keyedCollections of the upper contexts, located in the aCompositeKey path. Returns null if the element is not found or if it is found but has a null value.

Parameters:
aCompositeKey -
Returns:
Throws:
DSEObjectNotFoundException

unchain

void unchain()
             throws DSEInvalidRequestException,
                    DSEObjectNotFoundException
Removes this context and all its children from the context tree. Also maintains the consistency of the context tree.

Throws:
DSEInvalidRequestException
DSEObjectNotFoundException

writeExternal

void writeExternal()
                   throws java.io.IOException
Writes this instance to a file using tags.

Throws:
java.io.IOException

writeExternal

void writeExternal(java.io.ObjectOutput s)
                   throws java.io.IOException
Provides concrete serialization handling for contexts. This method serializes the current context and all its children.

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

writeToStream

void writeToStream(java.io.ObjectOutput s)
                   throws java.io.IOException
Provides concrete serialization handling for contexts. This method serializes the current context and all its children.

Parameters:
s - java.io.ObjectOutput
Throws:
java.io.IOException

getInstanceID

java.lang.String getInstanceID()
Returns the instanceID.

Returns:
String

setInstanceID

void setInstanceID(java.lang.String anInstanceID)
                   throws DSEInvalidArgumentException
Sets the instanceID for a local context which must not predefined in the configuration file such as dsectxt.xml.

Parameters:
anInstanceID -
Throws:
DSEInvalidArgumentException

getMode

int getMode()
Returns the mode.

Returns:
int

setKCollDynamic

void setKCollDynamic(boolean aValue)
                     throws DSEInvalidRequestException
Set the value to the attribute dynamic for the keyedCollection in this context.

Parameters:
aValue -
Throws:
DSEInvalidRequestException

trySetElementAt

int trySetElementAt(java.lang.String aCompositeKey,
                    java.io.Serializable aValue)
Set the value of the element of its keyedCollection, or keyedCollections of the upper contexts which is located at aCompositeKey path. If the dataElement can be found in the current context or its upper contexts, set its value and return int 1. Otherwise, return -1 saying this dataElement does not exist.

Parameters:
aCompositeKey -
aValue -
Returns:
Throws:
DSEInvalidRequestException

setValueAt

void setValueAt(java.lang.String aCompositeKey,
                java.lang.Object aDataValue)
                throws DSEInvalidArgumentException,
                       DSEObjectNotFoundException,
                       DSEInvalidRequestException
Sets the value of the element of its keyedCollection, or keyedCollections of the upper contexts, located in the aCompositeKey path. When the KeyedCollection of the Context is dynamic, this method has different behavior depending on value of addToDynamicKColl property. If addToDynamicKColl is false, this method first looks for the aCompositekey element in the hierarchy. If the method finds it, the method modifies its value. If the method does not find the element, the method creates it dynamically. When addToDynamicKColl is true, this method either creates a new element in the current context or overwrites the existing element without checking the existence of the element in upper contexts.

Parameters:
aCompositeKey -
aDataValue -
Throws:
DSEInvalidArgumentException
DSEObjectNotFoundException
DSEInvalidRequestException

isReadOnly

boolean isReadOnly()
                   throws DSEInvalidRequestException
If the definition of this context in dsetxt.xml has the attribute readonly="true", this method will return true, otherwise, false is returned.

Returns:
Throws:
DSEInvalidRequestException

getLevel

java.lang.String getLevel()
                          throws DSEInvalidRequestException
We can define an attribute --level-- in dsectxt.xml file to indicate level of the context. The context can be devided into two levels:root, normal.

Returns:
"root", "normal". If this attribute is not difined, return normal level ;
Throws:
DSEInvalidRequestException

setReadOnly

void setReadOnly(boolean isReadOnly)
Set the value for readonly attribute for this context.

Parameters:
isReadOnly -

setSerializableLevel

void setSerializableLevel(int i)
                          throws DSEInvalidRequestException
Set the value of variable serializableLevel. If serializableLevel = 0, serialize the local context and its parent and its children If serializableLevel = 1, serialize the local context and its parent If serializableLevel = -1, serialize the local context and its children

Parameters:
i -
Throws:
DSEInvalidRequestException

setSerializeParentsAndChildren

void setSerializeParentsAndChildren(boolean b)
Set the value of variable serializeParentsAndChildren When the local context will be serialized, if serializeParentsAndChildren = true, the parents and children of the local context will be serialized. If serializeParentsAndChildren = false, they will not be serialized. The default value of serializeParentsAndChildren is true.

Parameters:
b -

commit

void commit()
            throws DSEInvalidRequestException
Commit a context and all its children and childrenĄŻ children into db, and remove these contexts from memory.

Parameters:
instanceID -
Throws:
DSEInvalidRequestException

getParentInstanceID

java.lang.String getParentInstanceID()
                                     throws DSEInvalidRequestException
Deprecated. This method is restricted to used in CHA server side. It would result in incorrect result if it is used ouside CHA server side. The preferred way to get the parent instance ID of a context is to call getParent().getInstanceID().

Returns:
String
Throws:
DSEInvalidRequestException

setParentInstanceID

void setParentInstanceID(java.lang.String string)
                         throws DSEInvalidRequestException
Deprecated. This method is restricted to used in CHA server side. It would result in incorrect result if it is used ouside CHA server side. The preferred way to set a parent of a context is to call chainTo().

Parameters:
string -
Throws:
DSEInvalidRequestException

getChildInstanceIDs

Vector getChildInstanceIDs()
                           throws DSEInvalidRequestException
Deprecated. This method is restricted to used in CHA server side. It would result in incorrect result if it is used ouside CHA server side. The preferred way to get children of a context is to call getChildren().

Returns:
Vector
Throws:
DSEInvalidRequestException

setMode

void setMode(int mode)
Deprecated. This method is restricted to used in CHA server side. It would result in incorrect result if it is used ouside CHA server side.

Parameters:
mode - The mode to set.

getParentName

java.lang.String getParentName()
                               throws DSEInvalidRequestException
Returns:
Returns the parentName defined in context definition.
Throws:
DSEInvalidRequestException

convertToByte

byte[] convertToByte()
                     throws java.io.IOException
Convert this context as an array of bytes.

Returns:
Throws:
java.io.IOException

setDirty

void setDirty(boolean aDirty)
Set the dirty value of context.

Parameters:
dirty -

isDirty

boolean isDirty()
Check if the context is dirty, if it is dirty it can be commited to persistence

Parameters:
dirty -

setRemote

java.lang.String setRemote()
                           throws DSEInvalidRequestException
Change the mode of this context to remote

Throws:
DSEInvalidRequestException

addService

void addService(Service aService,
                java.lang.String aServiceName,
                java.lang.String aServiceType)
                throws DSEInvalidRequestException
Add the service to context

Throws:
DSEInvalidRequestException

getServices

Hashtable getServices()
Get the service from context


getService

Service getService(java.lang.String aServiceName)
                   throws DSEObjectNotFoundException
Get the service by service ID

Throws:
DSEObjectNotFoundException

stopServicesInChildren

void stopServicesInChildren()
                            throws DSEInvalidRequestException
Throws:
DSEInvalidRequestException

stopServices

void stopServices()

IBM WebSphere Multichannel Bank Transformation Toolkit Javadoc

(c) Copyright IBM Corporation 1998, 2009