Release Planner v1.0

rp.util.xml
Class XMLTagsDefault

java.lang.Object
  |
  +--rp.util.xml.XMLTagsDefault
All Implemented Interfaces:
XMLTags
Direct Known Subclasses:
RPTags

public abstract class XMLTagsDefault
extends java.lang.Object
implements XMLTags

A default implementation of XMLTag that uses arrays and hash maps, and re-cycles loaders.

Version:
$Revision: 1.1 $, $Date: 2001/06/01 15:23:38 $

Constructor Summary
protected XMLTagsDefault(int nTags)
          Allocates storage in advance for the tag mapping data structures.
 
Method Summary
protected  void doneTags()
          Called after all the tags have been registered with putTag.
 XMLLoader getLoader(int id)
          Fetches an instance of a loader class (possibly recycled) for a given tag id.
 int idOf(java.lang.String tagName)
          Returns the integer id of a tag given by its string name.
 java.lang.String nameOf(int id)
          Returns the string name of a tag given by its integer id.
protected  void putTag(int tagId, java.lang.String tagName, java.lang.String loaderClassName)
          Registers an association.
 void returnLoader(int id, XMLLoader loader)
          Inidicates that the client is done with this loader and it may be recycled.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLTagsDefault

protected XMLTagsDefault(int nTags)
Allocates storage in advance for the tag mapping data structures.

Method Detail

putTag

protected void putTag(int tagId,
                      java.lang.String tagName,
                      java.lang.String loaderClassName)
Registers an association. Derived classes should call this routine once for each tag from their constructors. After all the calls for this routine, doneTags should then be called.

Parameters:
tagId - the integer id of an XML tag (used for efficiency in place of the name)
tagName - the unqualified string name of an XML tag as it appears in an XML file
loaderClassName - the name of a loader class for XML elements with this tag
See Also:
doneTags()

doneTags

protected void doneTags()
Called after all the tags have been registered with putTag. Creates an efficient, hashed inverse mapping from string name to id.

See Also:
putTag()

idOf

public int idOf(java.lang.String tagName)
         throws XMLTagNotFoundException
Description copied from interface: XMLTags
Returns the integer id of a tag given by its string name.

Specified by:
idOf in interface XMLTags
Parameters:
tagName - the string name of the tag whose id we are looking up
Returns:
the integer id of the tag
Throws:
XMLTagNotFoundException - when the name corresponds to no tag

nameOf

public java.lang.String nameOf(int id)
Description copied from interface: XMLTags
Returns the string name of a tag given by its integer id.

Specified by:
nameOf in interface XMLTags
Parameters:
id - the integer id of the tag we are looking up
Returns:
the unqualified name of the XML tag as it appears in an XML file

getLoader

public XMLLoader getLoader(int id)
                    throws XMLTagNoLoaderException
Description copied from interface: XMLTags
Fetches an instance of a loader class (possibly recycled) for a given tag id.

Specified by:
getLoader in interface XMLTags
Parameters:
id - the integer id of the tag whose loader we are instantiating
Returns:
a new instance of a loader
Throws:
XMLTagNoLoaderException - when the loader class cannot be instantiated.

returnLoader

public void returnLoader(int id,
                         XMLLoader loader)
Description copied from interface: XMLTags
Inidicates that the client is done with this loader and it may be recycled.

Specified by:
returnLoader in interface XMLTags
Parameters:
id - the id of the tag withi which this loader is associated.
loader - the loader object to be recycled

Release Planner v1.0