com.ibm.dse.base
Class FormatExternalizer

java.lang.Object
  |
  +--com.ibm.dse.base.Externalizer
        |
        +--com.ibm.dse.base.FormatExternalizer

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).


Fields inherited from class com.ibm.dse.base.Externalizer
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
 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()
          This method returns the Format element cache.
static java.lang.Object getFromCache(java.lang.String key)
          This method will remove a format element with id=key from the cache and return it.
static boolean isCacheEnabled()
          Returns true if format element caching is possible.
 boolean isDecorator(Tag aTag)
          Returns true if the tag is a decorator.
static void linkReferences(Tag grandParentTag, Tag parentTag, int parentRefTagIndex)
          This method 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)
          This method 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(FormatElement format)
          This method will place the format element 'format' into the cache.
 void reset()
          Sets a new format externalizer to FormatElement.
 void reset(java.util.Enumeration listTagId)
          Resets the definition of tags 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)
          This method enables or disables the format element caching.
 
Methods inherited from class com.ibm.dse.base.Externalizer
getClasses, getTagClassTable, getTagInputStream, getTagOutputStream, isRunTime, readObject, readObject, readTag, 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 should 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
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 should 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
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

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

createNewExternalizer

protected Externalizer createNewExternalizer()
                                      throws java.io.IOException,
                                             DSEObjectNotFoundException
Returns a new externalizer for the generic format file.
Returns:
com.ibm.dse.base.Externalizer
Throws:
java.io.IOException -  
DSEObjectNotFoundException -  

end

public void end()
Release resources from this externalizer
Overrides:
end in class Externalizer

getCache

public static Hashtable getCache()
This method returns the Format element cache.
Returns:
com.ibm.dse.base.Hashtable

getFromCache

public static java.lang.Object getFromCache(java.lang.String key)
                                     throws java.io.IOException
This method will remove a format element with id=key from the cache and return it. If there are no elements in the cache with id=key, then null is returned.
Parameters:
key - java.lang.String
Returns:
java.lang.Object
Throws:
java.io.IOException -  

isCacheEnabled

public static boolean isCacheEnabled()
Returns true if format element caching is possible. Returns false if it is not possible.
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
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. The grandParentTag has the parentTag as one of its subtags. The parentTag is the tag that is currently being checked for references. The parentRefTagIndex is the index of the parentTag in the subtags vector of grandParentTag.
Parameters:
grandParentTag - com.ibm.dse.base.Tag
parentTag - com.ibm.dse.base.Tag
parentRefTagIndex - int
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. The grandParentTag has the parentTag as one of its subtags. The parentTag is the tag that is currently being checked for references. The parentRefTagIndex is the index of the parentTag in the subtags vector of grandParentTag. The aTagInputStream is the input stream where references are searched.
Parameters:
grandParentTag - com.ibm.dse.base.Tag
parentTag - com.ibm.dse.base.Tag
parentRefTagIndex - int
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.

linkRefFmt

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

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

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.dse.base.Tag
subTags - com.ibm.dse.base.Vector
Returns:
com.ibm.dse.base.Tag

putIntoCache

public static void putIntoCache(FormatElement format)
                         throws java.io.IOException
This method will place the format element 'format' into the cache. The format element will be keyed with the format name in the cache.
Parameters:
key - java.lang.String
value - java.lang.Object
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 neither 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 by parameter. If the tag doesn't exist in the TagInputStream but exists in memory then memory definition is deleted. If the tag doesn't exist neither in the TagInputStream nor in memory then an exception is thrown. If the tag exists in the TagInputStream but doesn't exist in memory then the new definition is added to memory. If the tag exists both in the TagInputStream and in memory then the memory definition is updated with the TagInputStream definition.
Parameters:
tagId - java.lang.String
aTagInputStream - com.ibm.dse.base.TagInputStream
Throws:
java.io.IOException -  

reset

public void reset(java.util.Enumeration listTagId)
           throws java.io.IOException,
                  DSEObjectNotFoundException
Resets the definition of tags which tag id appears in listTagId. The new definition 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 neither 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)
This method enables or disables the format element caching. if newValue = true, then object caching is enabled. if newValue = false, then object caching is disabled.
Parameters:
newValue - boolean