com.ibm.dse.base.types
Class DSETypeExternalizer

java.lang.Object
  |
  +--com.ibm.dse.base.types.DSETypeExternalizer

public class DSETypeExternalizer
extends java.lang.Object
implements TypeExternalizer, TypeConstants

This class provides an implementation of the TypeExternalizer interface and is responsible for maintaining a registry of all known Types, indexed by name.


Fields inherited from interface com.ibm.dse.base.types.TypeConstants
CONV_TYPE_DEFAULT, CONV_TYPE_HOST, CONV_TYPE_OUTPUT, CONV_TYPE_SER, CONV_TYPE_XML, disabled, hidden, isDisabled, isHidden, isMandatory, isOmitted, isReadOnly, mandatory, omitted, readOnly, TYPE_DEFAULT, TYPE_REGISTRY_INIT_SIZE
 
Constructor Summary
DSETypeExternalizer()
          This constructor creates a DSETypeExternalizer
DSETypeExternalizer(java.lang.String option, java.io.BufferedInputStream aIniFile)
          This constructor creates a DSETypeExternalizer given a BufferedInputStream
DSETypeExternalizer(java.lang.String option, java.lang.String pathAndFile)
          This constructor creates a DSETypeExternalizer given the path and file name of the externalized file
DSETypeExternalizer(java.net.URL aURL)
          This constructor creates a DSETypeExternalizer from the URL given
 
Method Summary
 Type addType(Type newType)
          Adds the Type passed as argument to the registry of Types known to the TypeExternalizer and if successful, the Type added is returned.
 void augment(java.net.URL aURL)
          Augments the TypeExternalizer with the Type definitions contained in the URL passed as argument, throwing an appropriate exception if unsuccessful.
 AbstractConverter createConverter(Tag convTag)
          This method creates a converter object which is initialized with the information stored in the 'convTag'
 java.lang.Object createDataFromType(Tag dataTag)
          Creates a typed data element from a data tag.
protected  Externalizer createNewExternalizer()
          Returns a new externalizer for the generic type file.
 AbstractPropertyDescriptor createPropDescriptor(Tag theTag, java.lang.String enclosingType, boolean creatingType)
          This method creates a Property Descriptor object which is initialized with the information stored in the 'theTag'.
 void createType(Tag typeTag)
          This method creates a DSEType object which is initialized with the information stored in the 'typeTag'
protected  Type createTypeInstance(Tag typeTag)
          This method returns a new DSEType instance which is initialized with the information stored in the 'typeTag'.
 AbstractValidator createValidator(Tag valTag)
          This method creates a validator object which is initialized with the information stored in the 'valTag'
 void end()
          Releases resources from this Externalizer.
 java.lang.Class findPDescriptorClass(java.lang.String tagName)
          This method will take the prefix of tagName and concatenate it with "PropertyDescriptor".
static DataExternalizer getHelperExternalizer()
          Returns the instance of the helperExternalizer.
 Type getType(java.lang.String name)
          Returns the Type with the name passed as argument.
 java.util.Enumeration getTypes()
          Returns an Enumeration of all Types known to the TypeExternalizer.
 void initializeExternalizer()
          This method is called after the helper externalizer has read the Typed Data file into a Tag structure in memory.
protected  void modifyTypeDefinition(Type oldType, Tag newTypeTag)
          Modifies an old Type instance with the definitions included in a new Type Tag
 java.lang.String[] parseConvTypes(java.lang.String tempConvTypes)
          This method will take the convTypes string and parse it into substrings and place them into a String array
 java.lang.Object readObject(java.lang.String name)
          Returns a business object for the Type with the name passed as argument.
protected  void removeType(java.lang.String typeId)
          Removes a type
 void reset()
          Resets all the tags definitions and their associated type instances by reloading the types file.
 void reset(java.util.Enumeration listTagId)
          Resets the declaration of tags which tag id appears in listTagId.
 void reset(java.lang.String tagId)
          Resets the declaration of the tag with id tagId.
protected  void reset(java.lang.String tagId, Externalizer newExternalizer)
          Resets the declaration of the tag with id tagId.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DSETypeExternalizer

public DSETypeExternalizer()
This constructor creates a DSETypeExternalizer

DSETypeExternalizer

public DSETypeExternalizer(java.lang.String option,
                           java.io.BufferedInputStream aIniFile)
                    throws java.io.IOException
This constructor creates a DSETypeExternalizer given a BufferedInputStream

DSETypeExternalizer

public DSETypeExternalizer(java.lang.String option,
                           java.lang.String pathAndFile)
                    throws java.io.IOException
This constructor creates a DSETypeExternalizer given the path and file name of the externalized file

DSETypeExternalizer

public DSETypeExternalizer(java.net.URL aURL)
                    throws java.io.IOException
This constructor creates a DSETypeExternalizer from the URL given
Method Detail

addType

public Type addType(Type newType)
             throws DSETypeException
Adds the Type passed as argument to the registry of Types known to the TypeExternalizer and if successful, the Type added is returned.
Specified by:
addType in interface TypeExternalizer
Parameters:
newType - Type
Throws:
DSETypeException - Name of the Type to add is either null or a duplicate.

augment

public void augment(java.net.URL aURL)
             throws DSETypeException
Augments the TypeExternalizer with the Type definitions contained in the URL passed as argument, throwing an appropriate exception if unsuccessful.
Specified by:
augment in interface TypeExternalizer
Parameters:
typeDefinitionsAsXML - URL
Throws:
DSETypeException - Augmentation is unsuccessful.

createConverter

public AbstractConverter createConverter(Tag convTag)
                                  throws DSETypeException
This method creates a converter object which is initialized with the information stored in the 'convTag'
Returns:
com.ibm.dse.base.types.AbstractConverter

createDataFromType

public java.lang.Object createDataFromType(Tag dataTag)
                                    throws DSETypeException,
                                           DSEObjectNotFoundException,
                                           java.io.IOException
Creates a typed data element from a data tag.
Parameters:
aTag - com.ibm.dse.base.Tag
Returns:
java.lang.Object

createNewExternalizer

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

createPropDescriptor

public AbstractPropertyDescriptor createPropDescriptor(Tag theTag,
                                                       java.lang.String enclosingType,
                                                       boolean creatingType)
                                                throws DSETypeException
This method creates a Property Descriptor object which is initialized with the information stored in the 'theTag'. The 'enclosingType' is used in the case where the 'refType' of the property descriptor is null and thus assumed to be pointing to the enclosing type.
Returns:
com.ibm.dse.base.types.AbstractPropertyDescriptor

createType

public void createType(Tag typeTag)
                throws DSETypeException
This method creates a DSEType object which is initialized with the information stored in the 'typeTag'

createTypeInstance

protected Type createTypeInstance(Tag typeTag)
                           throws DSETypeException
This method returns a new DSEType instance which is initialized with the information stored in the 'typeTag'.
Returns:
com.ibm.dse.base.types.DSEType

createValidator

public AbstractValidator createValidator(Tag valTag)
                                  throws DSETypeException
This method creates a validator object which is initialized with the information stored in the 'valTag'
Returns:
com.ibm.dse.base.types.AbstractValidator

end

public void end()
Releases resources from this Externalizer.

findPDescriptorClass

public java.lang.Class findPDescriptorClass(java.lang.String tagName)
                                     throws DSETypeException
This method will take the prefix of tagName and concatenate it with "PropertyDescriptor". For example: if the tagName is "DateDescriptor" then the prefix "Date" will be extracted and concatenated with "PropertyDescriptor" to yield "DatePropertyDescriptor". Then the package is found for this class, and the class object is created and returned.
Returns:
java.lang.Class

getHelperExternalizer

public static DataExternalizer getHelperExternalizer()
Returns the instance of the helperExternalizer.
Returns:
DataExternalizer

getType

public Type getType(java.lang.String name)
             throws DSETypeException
Returns the Type with the name passed as argument.
Specified by:
getType in interface TypeExternalizer
Parameters:
name - String
Returns:
Type
Throws:
DSETypeException - Type requested is not found.

getTypes

public java.util.Enumeration getTypes()
Returns an Enumeration of all Types known to the TypeExternalizer.
Specified by:
getTypes in interface TypeExternalizer
Returns:
Enumeration

initializeExternalizer

public void initializeExternalizer()
                            throws DSETypeException
This method is called after the helper externalizer has read the Typed Data file into a Tag structure in memory. This method will create the Types, the PropertyDescriptors, the Validators, and the Converters.

modifyTypeDefinition

protected void modifyTypeDefinition(Type oldType,
                                    Tag newTypeTag)
                             throws DSETypeException
Modifies an old Type instance with the definitions included in a new Type Tag
Parameters:
oldType - com.ibm.dse.base.types.Type
newTypeTag - com.ibm.dse.base.Tag
Throws:
DSETypeException - if the type can not be modified

parseConvTypes

public java.lang.String[] parseConvTypes(java.lang.String tempConvTypes)
                                  throws DSETypeException
This method will take the convTypes string and parse it into substrings and place them into a String array
Returns:
java.lang.String[]

readObject

public java.lang.Object readObject(java.lang.String name)
                            throws DSETypeException
Returns a business object for the Type with the name passed as argument.

This business object is populated with the default data for the Type requested. Collabrotes with Type. Compond Types return a KeyedCollection, Simple Types return a DataField with a business object as value.

Specified by:
readObject in interface TypeExternalizer
Parameters:
name - String
Returns:
Object
Throws:
DSETypeException - Type requested is not found.

removeType

protected void removeType(java.lang.String typeId)
Removes a type
Parameters:
typeId - java.lang.String
newType - com.ibm.dse.base.types.Type

reset

public void reset()
           throws DSETypeException,
                  DSEObjectNotFoundException,
                  java.io.IOException
Resets all the tags definitions and their associated type instances by reloading the types file.
Throws:
DSETypeException -  
java.io.IOException -  
DSEObjectNotFoundException -  

reset

public void reset(java.lang.String tagId)
           throws java.io.IOException,
                  DSEObjectNotFoundException,
                  DSETypeException
Resets the declaration of the tag with id tagId. The new declaration is read from the file associated with this externalizer. If the tag already exists, it is updated. Otherwise the tag is added. The old type instance associated to this tag is modified acordding to the new tag. If the type doesn't exist the new type is created.
Parameters:
tagId - java.lang.String The id of the tag to reset.
Throws:
java.io.IOException -  
DSEObjectNotFoundException -  
DSETypeException - if the Type instance associated to the tagId can not be reset

reset

protected void reset(java.lang.String tagId,
                     Externalizer newExternalizer)
              throws java.io.IOException,
                     DSEObjectNotFoundException,
                     DSETypeException
Resets the declaration of the tag with id tagId. The new declaration is read from the file associated with the externalizer passed as argument. If the tag already exists, it is updated. Otherwise the tag is added. The old type instance associated to this tag is modified acordding to the new tag. If the type doesn't exist the new type is created.
Parameters:
tagId - java.lang.String The id of the tag to reset.
Throws:
java.io.IOException -  
DSEObjectNotFoundException -  
DSETypeException - if the Type instance associated to the tagId can not be reset

reset

public void reset(java.util.Enumeration listTagId)
           throws java.io.IOException,
                  DSEObjectNotFoundException,
                  DSETypeException
Resets the declaration of tags which tag id appears in listTagId. If a new tag id is specified then the corresponding tag is added. The old type instances associated to those tags if exist are modified with the new types attributes created from the new tags. If the old type instances don't exist they are created from the new tags.
Parameters:
listTagId - java.util.Enumeration
Throws:
java.io.IOException -  
DSEObjectNotFoundException -  
DSETypeException -