IBM Branch Transformation Toolkit Javadoc

com.ibm.btt.base
Class FormatExternalizer

java.lang.Object
  extended bycom.ibm.btt.base.Externalizer
      extended bycom.ibm.btt.base.FormatExternalizer
All Implemented Interfaces:
Cache

public class FormatExternalizer
extends Externalizer

This class manages the externalization of formatted objects using the tags specified in the settings.tags.formats path and the formats definition file specified in DSE.INI (in the settings.files.format path).


Field Summary
 
Fields inherited from class com.ibm.btt.base.Externalizer
numberOfObjects, tagClassTable, tagInputStream, TYPE_CONTEXT, TYPE_DATA, TYPE_FORMAT, TYPE_OPERATION, TYPE_PROCESSOR, TYPE_SERVICE, TYPE_SETTINGS, TYPE_TYPE, TYPE_UNKNOWN, TYPE_VIEW
 
Constructor Summary
FormatExternalizer()
          This is the default constructor used to create a FormatExternalizer object.
FormatExternalizer(java.lang.String option, java.io.BufferedInputStream aIniStream)
          This constructor initializes an Externalizer object.
FormatExternalizer(java.lang.String option, java.lang.String pathAndFile)
          This constructor initializes an Externalizer object.
 
Method Summary
static void clearCache()
          This method empties the cache.
protected  java.lang.Object convertRealTagToObject(Tag aTag)
          Converts a tag to an object and initializes the object's attributes.
 java.lang.Object convertTagToObject(Tag aTag)
          Converts a Tag to an Object using the tagClassTable and initializes the Object's attributes.
protected  Externalizer createNewExternalizer()
          Returns a new externalizer for the generic format file.
 void end()
          Release resources from this externalizer.
static Hashtable getCache()
          Returns the Format element cache.
static Cacheable getFromCache(java.lang.String key)
          Removes the format element with id=key from the cache and returns it.
static boolean isCacheEnabled()
          Returns true if format element caching is enabled.
 boolean isDecorator(Tag aTag)
          Returns true if the tag is a decorator.
static void linkReferences(Tag grandParentTag, Tag parentTag, int parentRefTagIndex)
          Alters the tag structure of the tagInputStream for DSEFMTS by linking all references to their real tags.
protected static void linkReferences(Tag grandParentTag, Tag parentTag, int parentRefTagIndex, TagInputStream aTagInputStream)
          This method alters the tag structure of the tagInputStream for DSEFMTS by linking all references to their real tags.
static void linkRefFmt(Tag parentTag, Tag grandParentTag, int parentRefTagIndex)
          Deprecated. Replaced by linkRefFmt(Tag, Tag, int, TagInputStream).
static void linkRefFmt(Tag parentTag, Tag grandParentTag, int parentRefTagIndex, TagInputStream aTagInputStream)
          Replaces parentTag (refFmt tag) with its corresponding real tag.
 FormatElement linkToDecorators(FormatElement aFormat, Tag aTag)
          Makes the decorator FormatElement point to the format FormatElement if the decorator tag follows the format tag.
 void makeTagClassTable()
          Creates the tagClassTable using the values in DSE.INI file (path: settings.tags.formats).
static Tag overrideTagAttributes(Tag childTag, Vector subTags)
          Overrides a given tag with the attributes specified as param subtags in the given list of subtags.
static void putIntoCache(Cacheable format)
          Places the format element into the cache.
 void reset()
          Sets a new format externalizer to FormatElement.
 void reset(java.util.Enumeration listTagId)
          Resets the definition of tags in which tag id appears in listTagId.
 void reset(java.lang.String tagId)
          Resets the definition of the tag with id tagId.
protected  void reset(java.lang.String tagId, TagInputStream aTagInputStream)
          Resets the definition of the format entity with id equals to tagId.
static void setCacheEnabled(boolean newValue)
          Enables or disables the format element caching.
 
Methods inherited from class com.ibm.btt.base.Externalizer
addEntryInTagClassTable, clearCacheTable, getCachePolicyToApply, getCacheTable, getClasses, getFromCacheTable, getNumberOfObjects, getObjectsMaxNum, getObjectsPerTypeMaxNum, getObjectTypesMaxNum, getTagClassTable, getTagInputStream, getTagOutputStream, isCachingEnabled, isRunTime, putIntoCacheTable, readObject, readObject, readTag, rebuildCacheTable, setCachingEnabled, setNumberOfObjects, setObjectsMaxNum, setObjectsPerTypeMaxNum, setObjectTypesMaxNum, setRunTime, setTagClassTable, setTagInputStream, tagList, tagWithId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FormatExternalizer

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


FormatExternalizer

public FormatExternalizer(java.lang.String option,
                          java.io.BufferedInputStream aIniStream)
                   throws java.io.IOException
This constructor initializes an Externalizer object. The option parameter must be Memory or File. Memory indicates that all tags are to be stored in memory. This is the recommended option for small tag files. File indicates that the tag file is read each time a tag is needed. This is the recommended option for large tag files.

Parameters:
option - java.lang.String - Must be Memory or File
aIniStream - java.io.BufferedInputStream - Containing the input data

FormatExternalizer

public FormatExternalizer(java.lang.String option,
                          java.lang.String pathAndFile)
                   throws java.io.IOException
This constructor initializes an Externalizer object. The option parameter must be Memory or File. Memory indicates that all tags are to be stored in memory. This is the recommended option for small tag files. File indicates that the tag file is read each time a tag is needed. This is the recommended option for large tag files.

Parameters:
option - java.lang.String - Must be Memory or File
pathAndFile - java.lang.String - Specifying the name and path of the formats definition file
Method Detail

clearCache

public static void clearCache()
This method empties the cache.


convertRealTagToObject

protected java.lang.Object convertRealTagToObject(Tag aTag)
                                           throws java.io.IOException
Converts a tag to an object and initializes the object's attributes. Users can specify where to find the Format using the full package name in the Format tag, in the initialization file, or using the "implClass" attribute. To work properly, the class that provides the instance must have a constructor with no arguments.

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

convertTagToObject

public java.lang.Object convertTagToObject(Tag aTag)
                                    throws java.io.IOException
Converts a Tag to an Object using the tagClassTable and initializes the Object's attributes.

Overrides:
convertTagToObject in class Externalizer
Parameters:
aTag - Tag
Returns:
java.lang.Object
Throws:
java.io.IOException

createNewExternalizer

protected Externalizer createNewExternalizer()
                                      throws java.io.IOException,
                                             DSEObjectNotFoundException
Returns a new externalizer for the generic format file.

Returns:
com.ibm.btt.base.Externalizer
Throws:
java.io.IOException
DSEObjectNotFoundException

end

public void end()
Release resources from this externalizer.

Specified by:
end in class Externalizer

getCache

public static Hashtable getCache()
Returns the Format element cache.

Returns:
com.ibm.btt.base.Hashtable

getFromCache

public static Cacheable getFromCache(java.lang.String key)
                              throws java.io.IOException
Removes the format element with id=key from the cache and returns it. If there are no elements in the cache with id=key, this method returns null.

Parameters:
key - java.lang.String
Returns:
com.ibm.btt.base.Cacheable
Throws:
java.io.IOException

isCacheEnabled

public static boolean isCacheEnabled()
Returns true if format element caching is enabled.

Returns:
boolean

isDecorator

public boolean isDecorator(Tag aTag)
Returns true if the tag is a decorator.

Parameters:
aTag - Tag
Returns:
boolean

linkReferences

public static void linkReferences(Tag grandParentTag,
                                  Tag parentTag,
                                  int parentRefTagIndex)
                           throws java.io.IOException,
                                  DSEObjectNotFoundException
Alters the tag structure of the tagInputStream for DSEFMTS by linking all references to their real tags. This method replaces all refFmt tags from DSEFMTS with their corresponding real tags.

Parameters:
grandParentTag - com.ibm.btt.base.Tag - The tag that has the parentTag as one of its subtags
parentTag - com.ibm.btt.base.Tag - The tag that is currently being checked for references
parentRefTagIndex - int - The index of the parentTag in the subtags Vector of grandParentTag
Throws:
java.io.IOException
DSEObjectNotFoundException

linkReferences

protected static void linkReferences(Tag grandParentTag,
                                     Tag parentTag,
                                     int parentRefTagIndex,
                                     TagInputStream aTagInputStream)
                              throws java.io.IOException,
                                     DSEObjectNotFoundException
This method alters the tag structure of the tagInputStream for DSEFMTS by linking all references to their real tags. This method replaces all refFmt tags from DSEFMTS with their corresponding real tags located at the tagInputStream passed by parameter.

Parameters:
grandParentTag - com.ibm.btt.base.Tag - The tag that has the parentTag as one of its subtags
parentTag - com.ibm.btt.base.Tag - The tag that is currently being checked for references
parentRefTagIndex - int - The index of the parentTag in the subtags vector of grandParentTag
aTagInputStream - - The input stream in which references are searched
Throws:
java.io.IOException
DSEObjectNotFoundException

linkRefFmt

public static void linkRefFmt(Tag parentTag,
                              Tag grandParentTag,
                              int parentRefTagIndex)
                       throws java.io.IOException,
                              DSEObjectNotFoundException
Deprecated. Replaced by linkRefFmt(Tag, Tag, int, TagInputStream).

This method replaces parentTag (refFmt tag) with its corresponding real tag.

Throws:
java.io.IOException
DSEObjectNotFoundException

linkRefFmt

public static void linkRefFmt(Tag parentTag,
                              Tag grandParentTag,
                              int parentRefTagIndex,
                              TagInputStream aTagInputStream)
                       throws java.io.IOException,
                              DSEObjectNotFoundException
Replaces parentTag (refFmt tag) with its corresponding real tag.

Throws:
java.io.IOException
DSEObjectNotFoundException

linkToDecorators

public FormatElement linkToDecorators(FormatElement aFormat,
                                      Tag aTag)
                               throws java.io.IOException
Makes the decorator FormatElement point to the format FormatElement if the decorator tag follows the format tag. This method provides a way of linking a non-decorator format and all its related decorators.

Parameters:
aFormat - FormatElement
aTag - Tag
Returns:
FormatElement
Throws:
java.io.IOException

makeTagClassTable

public void makeTagClassTable()
Creates the tagClassTable using the values in DSE.INI file (path: settings.tags.formats).

Overrides:
makeTagClassTable in class Externalizer

overrideTagAttributes

public static Tag overrideTagAttributes(Tag childTag,
                                        Vector subTags)
Overrides a given tag with the attributes specified as param subtags in the given list of subtags.

Parameters:
childTag - com.ibm.btt.base.Tag
subTags - com.ibm.btt.base.Vector
Returns:
com.ibm.btt.base.Tag

putIntoCache

public static void putIntoCache(Cacheable format)
                         throws java.io.IOException
Places the format element into the cache. The format element is keyed by its name in the cache.

Parameters:
format - com.ibm.btt.base.Cacheable
Throws:
java.io.IOException

reset

public void reset()
           throws java.io.IOException,
                  DSEObjectNotFoundException
Sets a new format externalizer to FormatElement.

Throws:
java.io.IOException
DSEObjectNotFoundException

reset

public void reset(java.lang.String tagId)
           throws java.io.IOException,
                  DSEObjectNotFoundException
Resets the definition of the tag with id tagId. The new definition is read and its references solved from the file associated with this externalizer. If the tag doesn't exist in the file but exists in memory, then memory definition is deleted. If the tag doesn't exist in the file nor in memory, then an exception is thrown. If the tag exists in the file but doesn't exist in memory, then the new definition is added to memory. If the tag exists both in the file and in memory, then the memory definition is updated with the file definition.

Parameters:
tagId - java.lang.String - The id of the tag to reset
Throws:
java.io.IOException
DSEObjectNotFoundException

reset

protected void reset(java.lang.String tagId,
                     TagInputStream aTagInputStream)
              throws java.io.IOException
Resets the definition of the format entity with id equals to tagId. The new definition is obtained from the "TagInputStream" passed as a parameter. If the tag doesn't exist in the file but exists in memory, then memory definition is deleted. If the tag doesn't exist in the file nor in memory, then an exception is thrown. If the tag exists in the file but doesn't exist in memory, then the new definition is added to memory. If the tag exists both in the file and in memory, then the memory definition is updated with the file definition.

Parameters:
tagId - java.lang.String
aTagInputStream - com.ibm.btt.base.TagInputStream
Throws:
java.io.IOException

reset

public void reset(java.util.Enumeration listTagId)
           throws java.io.IOException,
                  DSEObjectNotFoundException
Resets the definition of tags in which tag id appears in listTagId. The new definitions are read and its references solved from the file associated with this externalizer. If the tag doesn't exist in the file, but exists in memory, then memory definition is deleted. If the tag doesn't exist in the file nor in memory, then an exception is thrown. If the tag exists in the file, but doesn't exist in memory, then the new definition is added to memory. If the tag exists both in the file and in memory, then the memory definition is updated with the file definition.

Parameters:
listTagId - java.util.Enumeration
Throws:
java.io.IOException
DSEObjectNotFoundException

setCacheEnabled

public static void setCacheEnabled(boolean newValue)
Enables or disables the format element caching.

Parameters:
newValue - boolean - True to enable object caching

IBM Branch Transformation Toolkit Javadoc

(c) Copyright IBM Corporation 1998, 2005