org.biojava.utils.xml
Class XMLDispatcher

java.lang.Object
  extended byorg.biojava.utils.xml.XMLDispatcher
All Implemented Interfaces:
XMLPeerFactory

public class XMLDispatcher
extends java.lang.Object
implements XMLPeerFactory

Simple implementation of XMLPeerFactory which delegates object- construction on the basis of tag name.

Author:
Thomas Down

Constructor Summary
XMLDispatcher()
          Construct a new XMLDispatcher which does not know about any tag names.
 
Method Summary
 java.lang.Object getXMLPeer(java.lang.String tag, java.util.List children, org.xml.sax.AttributeList al)
          Return a Java object to reflect an XML element.
 void mapTag(java.lang.String tag, XMLPeerFactory fact)
          Add an XMLPeerFactory which constructs objects corresponding to a specific XML tag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLDispatcher

public XMLDispatcher()
Construct a new XMLDispatcher which does not know about any tag names.

Method Detail

mapTag

public void mapTag(java.lang.String tag,
                   XMLPeerFactory fact)
Add an XMLPeerFactory which constructs objects corresponding to a specific XML tag.

Parameters:
tag - the tag name to bind.
fact - an XMLPeerFactory implementation to invoke when the specified tag is encountered.

getXMLPeer

public java.lang.Object getXMLPeer(java.lang.String tag,
                                   java.util.List children,
                                   org.xml.sax.AttributeList al)
Description copied from interface: XMLPeerFactory
Return a Java object to reflect an XML element.

Specified by:
getXMLPeer in interface XMLPeerFactory
Parameters:
tag - the XML tag.
children - a List (may be empty) of objects reflecting child nodes.
al - attribute list for the tag.
Returns:
a Java object to reflect the XML tag, or null if this element should be silently ignored.