IBM Branch Transformation Toolkit Javadoc

com.ibm.dse.base
Class Externalizer

java.lang.Object
  extended bycom.ibm.dse.base.Externalizer
All Implemented Interfaces:
Cache
Direct Known Subclasses:
ContextExternalizer, DataExternalizer, FormatExternalizer, OperationExternalizer, ProcessorExternalizer, ServiceExternalizer, ViewExternalizer

public abstract class Externalizer
extends java.lang.Object
implements Cache

This class manages the externalization of any toolkit objects. Subclasses deal with the particularities of the different elements such as different tags and different references. See also the class "TagInputStream."


Field Summary
protected  long numberOfObjects
           
 Hashtable tagClassTable
           
 TagInputStream tagInputStream
           
static java.lang.String TYPE_CONTEXT
           
static java.lang.String TYPE_DATA
           
static java.lang.String TYPE_FORMAT
           
static java.lang.String TYPE_OPERATION
           
static java.lang.String TYPE_PROCESSOR
           
static java.lang.String TYPE_SERVICE
           
static java.lang.String TYPE_SETTINGS
           
static java.lang.String TYPE_TYPE
           
static java.lang.String TYPE_UNKNOWN
           
static java.lang.String TYPE_VIEW
           
 
Constructor Summary
Externalizer()
          This constructor creates a Externalizer object.
Externalizer(java.lang.String option, java.io.BufferedInputStream aIniFile, java.lang.String kind)
          This constructor initializes an Externalizer object.
Externalizer(java.lang.String option, java.lang.String pathAndFile, java.lang.String kind)
          This constructor creates an Externalizer object.
Externalizer(java.net.URL aURL, java.lang.String kind)
          This constructor creates an Externalizer object that works with SGML code.
 
Method Summary
 void addEntryInTagClassTable(java.lang.String tagName, java.lang.String className)
          Add an entry in the tag/class table
 void clearCacheTable()
          This method empties the cache
 java.lang.Object convertTagToObject(Tag aTag)
          Converts a tag to an Object.
abstract  void end()
          Abstract method that must be implemented by subclasses to release resources from the Externalizer.
protected  int getCachePolicyToApply(Cacheable object)
          Checks which of the existing cache policies must be applied in order to insert the passed 'object' into the cache.
 Hashtable getCacheTable()
          This method returns the objects cache.
 java.util.Enumeration getClasses()
          Returns the classes that this externalizer can instantiate.
 Cacheable getFromCacheTable(java.lang.String key)
          Removes an element with id=key from the cache and return it.
 long getNumberOfObjects()
          Returns the numberOfObjects.
 long getObjectsMaxNum()
          Returns the objectsMaxNum.
 long getObjectsPerTypeMaxNum()
          Returns the objectsPerTypeMaxNum.
 long getObjectTypesMaxNum()
          Returns the objectTypesMaxNum.
 Hashtable getTagClassTable()
          Returns a Hashtable with the classes that this Externalizer can instantiate.
 TagInputStream getTagInputStream()
          Returns a special stream that is able to read tags.
 TagOutputStream getTagOutputStream()
          Returns a special stream that is able to output tags.
 boolean isCachingEnabled()
          Returns true if element caching is possible.
static boolean isRunTime()
          Returns the value of the isRunTime property.
 void makeTagClassTable()
          This method should be overridden by subclasses to make their own tables of tags and classes.
 void putIntoCacheTable(Cacheable object)
          Places the element 'object' into the cache verifying first if any of the cache bounds is overheaded.
 java.lang.Object readObject(int index)
          Reads the Object defined by its index in the SGML file owned by the externalizer's stream.
 java.lang.Object readObject(java.lang.String aString)
          When an application wants to internalize an instance of an Externalizable class, it calls this method.
 Tag readTag(int index)
          Asks to the tagInputStream for the Tag with a given index.
protected  void rebuildCacheTable(int policy, Cacheable object)
          Removes elements from the cache table corresponding to the remove policy to apply.
 void setCachingEnabled(boolean newValue)
          This method enables or disables the element caching.
 void setNumberOfObjects(long numberOfObjects)
          Sets the numberOfObjects.
 void setObjectsMaxNum(long objectsMaxNum)
          Sets the objectsMaxNum.
 void setObjectsPerTypeMaxNum(long objectsPerTypeMaxNum)
          Sets the objectsPerTypeMaxNum.
 void setObjectTypesMaxNum(long objectTypesMaxNum)
          Sets the objectTypesMaxNum.
static void setRunTime(boolean aBoolean)
          Sets the value of the isRunTime property.
 void setTagClassTable(Hashtable aHashtable)
          Sets the value of tagClassTable.
 void setTagInputStream(TagInputStream aTagInputStream)
          Sets the tagInputStream.
 Vector tagList()
          Returns the tags in the generic operation stream of this externalizer.
 Tag tagWithId(java.lang.String aString)
          Returns a Tag with an ID in the generic operation stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tagInputStream

public TagInputStream tagInputStream

tagClassTable

public Hashtable tagClassTable

TYPE_SETTINGS

public static final java.lang.String TYPE_SETTINGS
See Also:
Constant Field Values

TYPE_DATA

public static final java.lang.String TYPE_DATA
See Also:
Constant Field Values

TYPE_FORMAT

public static final java.lang.String TYPE_FORMAT
See Also:
Constant Field Values

TYPE_SERVICE

public static final java.lang.String TYPE_SERVICE
See Also:
Constant Field Values

TYPE_CONTEXT

public static final java.lang.String TYPE_CONTEXT
See Also:
Constant Field Values

TYPE_OPERATION

public static final java.lang.String TYPE_OPERATION
See Also:
Constant Field Values

TYPE_PROCESSOR

public static final java.lang.String TYPE_PROCESSOR
See Also:
Constant Field Values

TYPE_VIEW

public static final java.lang.String TYPE_VIEW
See Also:
Constant Field Values

TYPE_TYPE

public static final java.lang.String TYPE_TYPE
See Also:
Constant Field Values

TYPE_UNKNOWN

public static final java.lang.String TYPE_UNKNOWN
See Also:
Constant Field Values

numberOfObjects

protected long numberOfObjects
Constructor Detail

Externalizer

public Externalizer()
This constructor creates a Externalizer object.


Externalizer

public Externalizer(java.lang.String option,
                    java.io.BufferedInputStream aIniFile,
                    java.lang.String kind)
             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
aIniFile - java.io.BufferedInputStream

Externalizer

public Externalizer(java.lang.String option,
                    java.lang.String pathAndFile,
                    java.lang.String kind)
             throws java.io.IOException
This constructor creates 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

Externalizer

public Externalizer(java.net.URL aURL,
                    java.lang.String kind)
             throws java.io.IOException
This constructor creates an Externalizer object that works with SGML code.

Parameters:
aURL - java.net.URL
Method Detail

addEntryInTagClassTable

public void addEntryInTagClassTable(java.lang.String tagName,
                                    java.lang.String className)
Add an entry in the tag/class table

Parameters:
tagName - java.lang.String
className - java.lang.String

clearCacheTable

public void clearCacheTable()
This method empties the cache

Specified by:
clearCacheTable in interface Cache

convertTagToObject

public java.lang.Object convertTagToObject(Tag aTag)
                                    throws java.io.IOException
Converts a tag to an Object. This method is needed to create an instance of the class with the same name as the supplied tag. Note: to work properly the class providing the instance must have a constructor with no arguements.

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

end

public abstract void end()
Abstract method that must be implemented by subclasses to release resources from the Externalizer.


getCacheTable

public Hashtable getCacheTable()
This method returns the objects cache.

Specified by:
getCacheTable in interface Cache
Returns:
com.ibm.dse.base.Hashtable

getClasses

public java.util.Enumeration getClasses()
Returns the classes that this externalizer can instantiate.

Returns:
Enumeration

getFromCacheTable

public Cacheable getFromCacheTable(java.lang.String key)
                            throws java.io.IOException
Removes an 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.

Specified by:
getFromCacheTable in interface Cache
Parameters:
key - java.lang.String object name
Returns:
java.lang.Object object from cache
Throws:
java.io.IOException

getTagClassTable

public Hashtable getTagClassTable()
Returns a Hashtable with the classes that this Externalizer can instantiate.

Returns:
java.util.Hashtable

getTagInputStream

public TagInputStream getTagInputStream()
Returns a special stream that is able to read tags.

Returns:
TagInputStream

getTagOutputStream

public TagOutputStream getTagOutputStream()
Returns a special stream that is able to output tags. This is used only in edit-time.

Returns:
TagOutputStream

isCachingEnabled

public boolean isCachingEnabled()
Returns true if element caching is possible. Returns false if it is not possible.

Specified by:
isCachingEnabled in interface Cache
Returns:
boolean

isRunTime

public static boolean isRunTime()
Returns the value of the isRunTime property. This property determines the behavior of the Externalizer. This method is used by the SGML editor.

Returns:
boolean

makeTagClassTable

public void makeTagClassTable()
This method should be overridden by subclasses to make their own tables of tags and classes.


rebuildCacheTable

protected void rebuildCacheTable(int policy,
                                 Cacheable object)
Removes elements from the cache table corresponding to the remove policy to apply.

Parameters:
policy - int policy to apply
object - com.ibm.dse.Cacheable - Object to put into cache table

getCachePolicyToApply

protected int getCachePolicyToApply(Cacheable object)
Checks which of the existing cache policies must be applied in order to insert the passed 'object' into the cache.

Parameters:
object - com.ibm.dse.Cacheable - Object to put into cache table
Returns:
int - policy to apply

putIntoCacheTable

public void putIntoCacheTable(Cacheable object)
                       throws java.io.IOException
Places the element 'object' into the cache verifying first if any of the cache bounds is overheaded. The element will be keyed with the name in the cache.

Specified by:
putIntoCacheTable in interface Cache
Throws:
java.io.IOException

readObject

public java.lang.Object readObject(int index)
                            throws java.io.IOException
Reads the Object defined by its index in the SGML file owned by the externalizer's stream. The returned Object is an instance of any of the classes in the TagClassTable and always implements Externalizable.

Returns:
java.lang.Object
Throws:
java.io.IOException

readObject

public java.lang.Object readObject(java.lang.String aString)
                            throws java.io.IOException
When an application wants to internalize an instance of an Externalizable class, it calls this method. The parameter is the identification of a tag whose type matches the class of the element. The instance is initialized with the attributes found in the tag. This method returns a null if the parameter is not found in any tag. If you know the class to be internalized and it implements Externalizable, an alternative way to get the instance is to use: new MyClass(aString)

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

readTag

public Tag readTag(int index)
            throws java.io.IOException
Asks to the tagInputStream for the Tag with a given index.

Parameters:
index - int
Returns:
Tag
Throws:
java.io.IOException

setCachingEnabled

public void setCachingEnabled(boolean newValue)
This method enables or disables the element caching. if newValue = true, then object caching is enabled. if newValue = false, then object caching is disabled.

Specified by:
setCachingEnabled in interface Cache
Parameters:
newValue - boolean

setRunTime

public static void setRunTime(boolean aBoolean)
Sets the value of the isRunTime property. This property determines the behavior of the Externalizer. This method is used by the SGML editor.

Parameters:
aBoolean - boolean

setTagClassTable

public void setTagClassTable(Hashtable aHashtable)
Sets the value of tagClassTable. This table contains all of the classes that this Externalizer is able to instantiate.

Parameters:
aHashtable - java.util.Hashtable

setTagInputStream

public void setTagInputStream(TagInputStream aTagInputStream)
Sets the tagInputStream. This stream is used to read tags.

Parameters:
aTagInputStream - TagInputStream

tagList

public Vector tagList()
Returns the tags in the generic operation stream of this externalizer.

Returns:
Vector

tagWithId

public Tag tagWithId(java.lang.String aString)
              throws java.io.IOException
Returns a Tag with an ID in the generic operation stream.

Parameters:
aString - java.lang.String
Returns:
Tag
Throws:
java.io.IOException.
java.io.IOException

getObjectsMaxNum

public long getObjectsMaxNum()
Returns the objectsMaxNum.

Returns:
long

getObjectsPerTypeMaxNum

public long getObjectsPerTypeMaxNum()
Returns the objectsPerTypeMaxNum.

Returns:
long

getObjectTypesMaxNum

public long getObjectTypesMaxNum()
Returns the objectTypesMaxNum.

Returns:
long

setObjectsMaxNum

public void setObjectsMaxNum(long objectsMaxNum)
Sets the objectsMaxNum.

Parameters:
objectsMaxNum - - The objectsMaxNum to set

setObjectsPerTypeMaxNum

public void setObjectsPerTypeMaxNum(long objectsPerTypeMaxNum)
Sets the objectsPerTypeMaxNum.

Parameters:
objectsPerTypeMaxNum - - The objectsPerTypeMaxNum to set

setObjectTypesMaxNum

public void setObjectTypesMaxNum(long objectTypesMaxNum)
Sets the objectTypesMaxNum.

Parameters:
objectTypesMaxNum - - The objectTypesMaxNum to set

getNumberOfObjects

public long getNumberOfObjects()
Returns the numberOfObjects.

Returns:
long

setNumberOfObjects

public void setNumberOfObjects(long numberOfObjects)
Sets the numberOfObjects.

Parameters:
numberOfObjects - - The numberOfObjects to set

IBM Branch Transformation Toolkit Javadoc

(c) Copyright IBM Corporation 1998, 2005