|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.xml.sax.helpers.DefaultHandler org.sadun.util.xml.configuration.DispatcherHandler
A SAX handler which dispatches events to subclasses implementing the
Configurator
interface.
Dispatching can be set by tree depth level (using setDispatchLevel()
) or by namespaceURI/tag combination (using
setToDispatch(java.lang.String, java.lang.String)
.
Configurator
classes are located automatically in a package
whose name is set at construction
and their name must match a transformation the element tag obtained by the
following rules:
For example <my-tag> becomes MyTag.
For example, MyTagConfiguration becomes also MyTag
two-parameters
constructor
is used to create the DispatcherHandler, the given postfix
is concatenated to the name.
For example, if the postfix is Configurator, the final result for a tag <my-tag> will be the class name MyTagConfigurator.
The class works via a current configurator (initially null).
Whenever a dispatching occurs, the Configurator
class found in the package name given at constructor is instantiated and
control is sent to that instance, which becomes the current configurator.
When the level/element for which the dispatch was enabled is terminated, the method configuratorReady()
(which must be implemented by the class extending this one) is invoked, and the previous configurator
is reinstated as "current".
Otherwise, the current configurator (if any) keeps receiving the SAX events.
Constructor Summary | |
protected |
DispatcherHandler(Setup setup,
java.lang.String packageName,
java.lang.String postfix)
Constructor for DispatcherHandler. |
protected |
DispatcherHandler(java.lang.String packageName)
Constructor for DispatcherHandler. |
protected |
DispatcherHandler(java.lang.String packageName,
java.lang.String postfix)
|
Method Summary | |
void |
characters(char[] ch,
int start,
int length)
|
protected abstract void |
configuratorReady(java.lang.String namespaceURI,
java.lang.String localName,
java.lang.String qName,
Configurator configurator)
|
void |
endDocument()
|
void |
endElement(java.lang.String namespaceURI,
java.lang.String localName,
java.lang.String qName)
|
void |
endPrefixMapping(java.lang.String prefix)
|
void |
error(org.xml.sax.SAXParseException exception)
|
void |
fatalError(org.xml.sax.SAXParseException exception)
|
Setup |
getSetupObject()
Returns the setupObject. |
void |
ignorableWhitespace(char[] ch,
int start,
int length)
|
void |
notationDecl(java.lang.String name,
java.lang.String publicId,
java.lang.String systemId)
|
void |
processingInstruction(java.lang.String target,
java.lang.String data)
|
org.xml.sax.InputSource |
resolveEntity(java.lang.String publicId,
java.lang.String systemId)
|
protected void |
setDispatchLevel(int level)
Indicates that every element at a given depth level in the XML tree is associated to a Configurator. |
protected void |
setDispatchLevel(int level,
boolean toDispatch)
Sets wether or not every element at a given depth level in the XML tree is associated to a Configurator. |
void |
setDocumentLocator(org.xml.sax.Locator locator)
|
void |
setSetupObject(Setup setupObject)
Sets the setupObject. |
protected void |
setToDispatch(java.lang.String namespaceURI,
java.lang.String localName)
Indicate that the given namespace URI/local name combination is associated to a Configurator. |
void |
skippedEntity(java.lang.String name)
|
void |
startDocument()
|
void |
startElement(java.lang.String namespaceURI,
java.lang.String localName,
java.lang.String qName,
org.xml.sax.Attributes atts)
Check whether the namespace/tag are associated to a configurator or we're at a dispatch level. |
void |
startPrefixMapping(java.lang.String prefix,
java.lang.String uri)
|
void |
unparsedEntityDecl(java.lang.String name,
java.lang.String publicId,
java.lang.String systemId,
java.lang.String notationName)
|
void |
warning(org.xml.sax.SAXParseException exception)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
protected DispatcherHandler(Setup setup, java.lang.String packageName, java.lang.String postfix)
Configurator
classes will be searched for in the given package (see class description).
packageName
- the name of the package where to attempt to locate the
necessary Configurator
classes.postfix
- a fixed postfix which will be added to the Configurator
class name (see class description).protected DispatcherHandler(java.lang.String packageName, java.lang.String postfix)
protected DispatcherHandler(java.lang.String packageName)
Configurator
classes will be searched for in the given package (see class description).
packageName
- the name of the package where to attempt to locate the
necessary Configurator
classes.Method Detail |
protected void setToDispatch(java.lang.String namespaceURI, java.lang.String localName)
protected void setDispatchLevel(int level, boolean toDispatch)
level
- the depth level in the XML treeprotected void setDispatchLevel(int level)
level
- the depth level in the XML treepublic final void startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts) throws org.xml.sax.SAXException
If yes, instantiate a new associated Configurator
.
and invoke its startElement()
method.
If no, invoke the
startElement()
method
of the current Configurator
(if any).
org.xml.sax.SAXException
public final void characters(char[] ch, int start, int length) throws org.xml.sax.SAXException
org.xml.sax.SAXException
public final void endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName) throws org.xml.sax.SAXException
org.xml.sax.SAXException
protected abstract void configuratorReady(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, Configurator configurator) throws org.xml.sax.SAXException
org.xml.sax.SAXException
public void endDocument() throws org.xml.sax.SAXException
org.xml.sax.SAXException
ContentHandler.endDocument()
public void endPrefixMapping(java.lang.String prefix) throws org.xml.sax.SAXException
org.xml.sax.SAXException
ContentHandler.endPrefixMapping(String)
public void error(org.xml.sax.SAXParseException exception) throws org.xml.sax.SAXException
org.xml.sax.SAXException
ErrorHandler.error(SAXParseException)
public void fatalError(org.xml.sax.SAXParseException exception) throws org.xml.sax.SAXException
org.xml.sax.SAXException
ErrorHandler.fatalError(SAXParseException)
public void ignorableWhitespace(char[] ch, int start, int length) throws org.xml.sax.SAXException
org.xml.sax.SAXException
ContentHandler.ignorableWhitespace(char[], int, int)
public void notationDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId) throws org.xml.sax.SAXException
org.xml.sax.SAXException
DTDHandler.notationDecl(String, String, String)
public void processingInstruction(java.lang.String target, java.lang.String data) throws org.xml.sax.SAXException
org.xml.sax.SAXException
ContentHandler.processingInstruction(String, String)
public org.xml.sax.InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId) throws org.xml.sax.SAXException
org.xml.sax.SAXException
EntityResolver.resolveEntity(String, String)
public void setDocumentLocator(org.xml.sax.Locator locator)
ContentHandler.setDocumentLocator(Locator)
public void skippedEntity(java.lang.String name) throws org.xml.sax.SAXException
org.xml.sax.SAXException
ContentHandler.skippedEntity(String)
public void startDocument() throws org.xml.sax.SAXException
org.xml.sax.SAXException
ContentHandler.startDocument()
public void startPrefixMapping(java.lang.String prefix, java.lang.String uri) throws org.xml.sax.SAXException
org.xml.sax.SAXException
ContentHandler.startPrefixMapping(String, String)
public void unparsedEntityDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId, java.lang.String notationName) throws org.xml.sax.SAXException
org.xml.sax.SAXException
DTDHandler.unparsedEntityDecl(String, String, String, String)
public void warning(org.xml.sax.SAXParseException exception) throws org.xml.sax.SAXException
org.xml.sax.SAXException
ErrorHandler.warning(SAXParseException)
public Setup getSetupObject()
public void setSetupObject(Setup setupObject)
setupObject
- The setupObject to set
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |