junit.extensions.xml
Class XMLTagResourceBundle

java.lang.Object
  extended byjunit.extensions.xml.XMLTagResourceBundle

public final class XMLTagResourceBundle
extends java.lang.Object

This class is used to read in the properties and provide access to the tag handlers for various elements based on their attribute values.

Author:
Vijay Aravamudhan : ThoughtWorks Inc., Kevin Wilson

Field Summary
private  java.util.ResourceBundle m_bundle
          The ResourceBundle used to read in the properties.
private  java.util.Map m_map
          Map of the API specified Tag Handlers.
private static XMLTagResourceBundle s_singleton
          Handle to the singleton instance.
 
Constructor Summary
private XMLTagResourceBundle()
          A default private constructor.
 
Method Summary
static void addTagHandler(java.lang.String tagname, java.lang.String classname)
          Add a tag handler.
private  void addTagHandlerImpl(java.lang.String tagname, java.lang.String classname)
          Add a tag handler.
private  java.lang.Class getClassFromTag(java.lang.String tagname, boolean debug)
          Get the Class for the type of tag handler given.
private static XMLTagResourceBundle getSingleton()
          The "default" method that is used to create and initialize a singleton instance.
static AbstractTagHandler getTagHandler(org.w3c.dom.Element element, IXMLTest test, java.lang.String type)
          A convenience method to get a handle to the AbstractTagHandler implementation.
private  AbstractTagHandler getTagHandlerImpl(org.w3c.dom.Element element, IXMLTest test, java.lang.String type)
          Reads the short name (type) and creates an instance of the tag handler that corresponds to the value from the resource bundle.
static void removeTagHandler(java.lang.String tagname)
          Remove a tag handler.
private  void removeTagHandlerImpl(java.lang.String tagname)
          Remove a tag handler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

s_singleton

private static XMLTagResourceBundle s_singleton
Handle to the singleton instance.


m_map

private final java.util.Map m_map
Map of the API specified Tag Handlers.


m_bundle

private java.util.ResourceBundle m_bundle
The ResourceBundle used to read in the properties.

Constructor Detail

XMLTagResourceBundle

private XMLTagResourceBundle()
A default private constructor.

See Also:
Object.Object()
Method Detail

getTagHandler

public static AbstractTagHandler getTagHandler(org.w3c.dom.Element element,
                                               IXMLTest test,
                                               java.lang.String type)
                                        throws XMLException
A convenience method to get a handle to the AbstractTagHandler implementation.

Parameters:
element - The element for which we need the tag handler.
test - The IXMLTestSuite being run.
type - The type of element to be handled.
Returns:
AbstractTagHandler An implementation of the AbstractTagHandler which will be used to process the element.
Throws:
XMLException - if the tag handle cannot be instanciated.

addTagHandler

public static void addTagHandler(java.lang.String tagname,
                                 java.lang.String classname)
Add a tag handler. If the tag exists in the resource bundle, then the added tag handler will take precedence over the tag from the resource bundle.

Parameters:
tagname - Tag name to be registered.
classname - Classname to be registered.

removeTagHandler

public static void removeTagHandler(java.lang.String tagname)
Remove a tag handler. If the tag name was over ridden by a added tag, then access will be restored to the tag provided by the resource bundle. Tags in the resource bundle may not be removed.

Parameters:
tagname - Tagname to be removed.

getSingleton

private static XMLTagResourceBundle getSingleton()
The "default" method that is used to create and initialize a singleton instance.

Returns:
XMLTagResourceBundle The one and only instance of this class.

getClassFromTag

private java.lang.Class getClassFromTag(java.lang.String tagname,
                                        boolean debug)
                                 throws XMLException
Get the Class for the type of tag handler given. The local tag map will be used first. If the tag is not found in the map, the bundle will be searched.

Parameters:
tagname - TagName to be
debug - True if debugging.
Returns:
Class instance for the tagtype
Throws:
XMLException - may be thrown.

getTagHandlerImpl

private AbstractTagHandler getTagHandlerImpl(org.w3c.dom.Element element,
                                             IXMLTest test,
                                             java.lang.String type)
                                      throws XMLException
Reads the short name (type) and creates an instance of the tag handler that corresponds to the value from the resource bundle.

Parameters:
element - The element for which we need the tag handler.
test - The testCase being run.
type - The type of element to be handled.
Returns:
AbstractTagHandler An implementation of the AbstractTagHandler which will be used to process the element.
Throws:
XMLException - if the tag handler cannot be instanciated.

addTagHandlerImpl

private void addTagHandlerImpl(java.lang.String tagname,
                               java.lang.String classname)
Add a tag handler. If the tag exists in the resource bundle, then the added tag handler will take precedence over the tag from the resource bundle.

Parameters:
tagname - Tag name to be registered.
classname - Classname to be registered.

removeTagHandlerImpl

private void removeTagHandlerImpl(java.lang.String tagname)
Remove a tag handler. If the tag name was over ridden by a added tag, then access will be restored to the tag provided by the resource bundle. Tags in the resource bundle may not be removed.

Parameters:
tagname - Tagname to be removed.


Licensed under: GNU Lesser General Public License, Ver 2.1, February 1999