IBM Branch Transformation Toolkit Javadoc

com.ibm.dse.base
Class FormatElement

java.lang.Object
  extended bycom.ibm.dse.base.FormatElement
All Implemented Interfaces:
Cacheable, Externalizable, java.io.Externalizable, java.io.Serializable
Direct Known Subclasses:
ConstantFormat, FieldFormat, FormatDecorator, IndexedCollectionFormat, KeyedCollectionFormat, TypedDataElementFormat

public abstract class FormatElement
extends java.lang.Object
implements Externalizable, Cacheable

This is the abstract parent class of the formats.

See Also:
Serialized Form

Field Summary
 java.lang.String dataElementName
           
(package private) static Externalizer externalizer
           
 java.lang.String name
           
 
Constructor Summary
FormatElement()
           
 
Method Summary
 java.lang.String exceptionInfo()
          Gets the class name.
 Externalizer externalizer()
          Returns the instance of the externalizer for this class.
 java.lang.String[] extract(java.lang.String aString)
          Extracts (strips) the substring corresponding to the format element from the input String and returns it and the remaining String as the elements of an array.
 java.lang.String format(Context aContext)
          Throws an Exception.
abstract  java.lang.String format(DataElement aDataElement)
          Format abstract class.
 java.lang.String format(Operation anOperation)
          Formats the context of this operation.
 java.lang.String getDataElementName()
          Returns the value of dataElementName.
static Externalizer getExternalizer()
          Gets the Externalizer.
 java.lang.String getName()
          Returns the value of name.
 java.lang.String getTagName()
          Gets a tag name.
abstract  java.lang.Object initializeFrom(Tag aTag)
          Initializes a FormatElement with the Tag attributes.
 boolean isCacheable()
          This method finds out if THIS particular object can be cached.
 java.lang.Boolean isConstant()
          Returns false.
 boolean isItConstant()
          Returns false.
 void readExternal()
          Initializes a data element with its external value.
 void readExternal(java.io.ObjectInput s)
          Invokes the object creation from an ObjectInput.
static java.lang.Object readObject(java.lang.String name)
          Instantiates a Format called "name" from the definitions file.
 void reinitialize()
          This method will reinitialize THIS object.
 void removeExternal()
          Removes the tags for this object from the definitions file.
 FormatElement rootDecorated()
          Returns this element.
 void setDataElementName(java.lang.String aDataElementName)
          Sets the value of dataElementName.
static void setExternalizer(Externalizer anExternalizer)
          Sets the Externalizer.
 void setName(java.lang.String aName)
          Returns the value of name.
 void setSize(int anInt)
          Does nothing.
 java.lang.String toString()
          Returns a visual representation of this format element.
 Vector toStrings()
          Returns a visual representation of this format element.
 Vector toTags()
          Returns a Vector with the FormatElement represented as a Tag.
 DataElement unformat(java.lang.String aString, Context aContext)
          Throws an Exception.
abstract  DataElement unformat(java.lang.String aString, DataElement aDataElement)
          Unformat abstract method.
 DataElement unformat(java.lang.String aString, Operation anOperation)
          Unformats the context of this operation.
 void writeExternal()
          Writes this instance converted in tags in a file.
 void writeExternal(java.io.ObjectOutput s)
          Provides concrete serialization handling for FormatElement.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

dataElementName

public java.lang.String dataElementName

name

public java.lang.String name

externalizer

static Externalizer externalizer
Constructor Detail

FormatElement

public FormatElement()
Method Detail

exceptionInfo

public java.lang.String exceptionInfo()
Gets the class name.

Returns:
String

externalizer

public Externalizer externalizer()
Returns the instance of the externalizer for this class.

Specified by:
externalizer in interface Externalizable
Returns:
com.ibm.dse.base.Externalizer

extract

public java.lang.String[] extract(java.lang.String aString)
                           throws DSEInvalidArgumentException
Extracts (strips) the substring corresponding to the format element from the input String and returns it and the remaining String as the elements of an array. This method is called by the unformat() method of the collections formats such as RecordFormat and IndexedCollectionFormat. The default behavior is to accept the whole input String.

Returns:
String[]
Throws:
DSEInvalidArgumentException

format

public java.lang.String format(Context aContext)
                        throws DSEInvalidClassException,
                               DSEInvalidRequestException,
                               DSEInvalidArgumentException
Throws an Exception. Only KeyedCollectionFormats can format a Context. This method is implemented for polymorphism.

Parameters:
aContext - com.ibm.dse.base.Context
Returns:
java.lang.String
Throws:
DSEInvalidClassException
DSEInvalidRequestException
DSEInvalidArgumentException

format

public abstract java.lang.String format(DataElement aDataElement)
                                 throws DSEInvalidClassException,
                                        DSEInvalidRequestException,
                                        DSEInvalidArgumentException
Format abstract class.

Parameters:
aDataElement - DataElement
Returns:
String
Throws:
DSEInvalidClassException
DSEInvalidRequestException
DSEInvalidArgumentException

format

public java.lang.String format(Operation anOperation)
                        throws DSEInvalidClassException,
                               DSEInvalidRequestException,
                               DSEInvalidArgumentException
Formats the context of this operation.

Parameters:
anOperation - com.ibm.dse.base.Operation
Returns:
java.lang.String
Throws:
DSEInvalidClassException
DSEInvalidRequestException
DSEInvalidArgumentException

getDataElementName

public java.lang.String getDataElementName()
Returns the value of dataElementName.

Returns:
java.lang.String

getExternalizer

public static Externalizer getExternalizer()
Gets the Externalizer.

Returns:
com.ibm.dse.base.Externalizer

getName

public java.lang.String getName()
Returns the value of name.

Specified by:
getName in interface Externalizable
Returns:
java.lang.String

getTagName

public java.lang.String getTagName()
Gets a tag name.

Returns:
java.lang.String

initializeFrom

public abstract java.lang.Object initializeFrom(Tag aTag)
                                         throws java.io.IOException,
                                                DSEException
Initializes a FormatElement with the Tag attributes.

Specified by:
initializeFrom in interface Externalizable
Parameters:
aTag - com.ibm.dse.base.Tag
Returns:
data.DataElement
Throws:
java.io.IOException
DSEException

isCacheable

public boolean isCacheable()
This method finds out if THIS particular object can be cached.

Specified by:
isCacheable in interface Cacheable
Returns:
boolean

isConstant

public java.lang.Boolean isConstant()
Returns false. It is not a constant. It is recommended to use boolean isItConstant() instead of this method.

Returns:
Boolean

isItConstant

public boolean isItConstant()
Returns false. It is not a constant.

Returns:
Boolean

readExternal

public void readExternal()
                  throws java.io.IOException
Initializes a data element with its external value. To work properly, the data element must have an ID (name) and the Externalizer and its tagInputStream are initialized.

Specified by:
readExternal in interface Externalizable
Throws:
java.io.IOException

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
Parameters:
s - java.io.ObjectInput
Throws:
java.io.IOException
java.lang.ClassNotFoundException

readObject

public static java.lang.Object readObject(java.lang.String name)
                                   throws java.io.IOException
Instantiates a Format called "name" from the definitions file.

Parameters:
name - java.lang.String
Returns:
java.lang.Object
Throws:
java.io.IOException

reinitialize

public void reinitialize()
This method will reinitialize THIS object. It should be called immediately after being extracted from the cache.

Specified by:
reinitialize in interface Cacheable

removeExternal

public void removeExternal()
                    throws java.io.IOException
Removes the tags for this object from the definitions file.

Specified by:
removeExternal in interface Externalizable
Throws:
java.io.IOException

rootDecorated

public FormatElement rootDecorated()
Returns this element. It is implemented to provide polymorphism.


setDataElementName

public void setDataElementName(java.lang.String aDataElementName)
Sets the value of dataElementName.

Parameters:
aDataElementName - java.lang.String

setExternalizer

public static void setExternalizer(Externalizer anExternalizer)
Sets the Externalizer.

Parameters:
anExternalizer - com.ibm.dse.base.Externalizer

setName

public void setName(java.lang.String aName)
Returns the value of name.

Specified by:
setName in interface Externalizable
Parameters:
aName - java.lang.String

setSize

public void setSize(int anInt)
Does nothing. Necessary to implement removeDecoration() on SelfLength

Parameters:
anInt - int

toString

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

Returns:
java.lang.String

toStrings

public Vector toStrings()
Returns a visual representation of this format element.

Specified by:
toStrings in interface Externalizable
Returns:
com.ibm.dse.base.Vector

toTags

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

Specified by:
toTags in interface Externalizable
Returns:
com.ibm.dse.base.Vector
Throws:
java.io.IOException

unformat

public DataElement unformat(java.lang.String aString,
                            Context aContext)
                     throws DSEInvalidRequestException,
                            DSEInvalidArgumentException
Throws an Exception. Only KeyedCollectionFormats can unformat a Context. This method is implemented for polymorphism.

Parameters:
aContext - com.ibm.dse.base.Context
Returns:
com.ibm.dse.base.DataElement
Throws:
DSEInvalidRequestException
DSEInvalidArgumentException

unformat

public abstract DataElement unformat(java.lang.String aString,
                                     DataElement aDataElement)
                              throws DSEInvalidRequestException,
                                     DSEInvalidArgumentException
Unformat abstract method. To be implemented by the subclasses.

Throws:
DSEInvalidRequestException
DSEInvalidArgumentException

unformat

public DataElement unformat(java.lang.String aString,
                            Operation anOperation)
                     throws DSEInvalidRequestException,
                            DSEInvalidArgumentException
Unformats the context of this operation.

Parameters:
aString - java.lang.String
anOperation - com.ibm.dse.base.Operation
Returns:
com.ibm.dse.base.DataElement
Throws:
DSEInvalidRequestException
DSEInvalidArgumentException

writeExternal

public void writeExternal()
                   throws java.io.IOException
Writes this instance converted in tags in a file. It should be called when the Externalizer has not initialized its tagStream. Once the tagStream is initialized, the method to call is writeExternal().

Specified by:
writeExternal in interface Externalizable
Throws:
java.io.IOException

writeExternal

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

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

IBM Branch Transformation Toolkit Javadoc

(c) Copyright IBM Corporation 1998, 2005