@MinDoc(copyright="Copyright 2005, 2009 A. Weinert", author="Albrecht Weinert", version="V.33", lastModified="27.03.2021", usage="use as is or extend for own (SAX) XML parsers", purpose="provide a comfortable (base for) XML parsers") public class SAXHandler extends ParseErrorHandler implements ErrorHandler, ContentHandler
ParseErrorHandler
, objects of this class are error
handlers for XML parsers. Additionally they implement a content handler
for SAX parser, hence being able to act as the one (and only) common
handler for SAX applications.startElement(String, String, String, Attributes)
. For many
application cases this as only change in an inheritor is sufficient.ContentHandler
methods in this class do nothing.GrafHelper.MBarFactory
is one
example of a class extending SAXHandler
. By comparably simple
overriding of just startDocument()
,
startElement()
and endElement()
it is a
powerful factory for MenuBar
s or
JMenuBar
s.de.frame4j
errorCount, fatalCount, log, name, reThrow, warningCount
Constructor and Description |
---|
SAXHandler(CharSequence name,
PrintWriter log,
boolean reThrow)
SAXHandler by name of the XML input and with report output.
|
Modifier and Type | Method and Description |
---|---|
void |
characters(char[] ch,
int start,
int length)
This implementation does nothing.
|
void |
endDocument()
This implementation does nothing.
|
void |
endElement(String namespaceURI,
String localName,
String qName)
This implementation does nothing.
|
void |
endPrefixMapping(String prefix)
This implementation does nothing.
|
Object |
getProduct()
Deliver the product of the (ready, successful) parsing.
|
void |
ignorableWhitespace(char[] ch,
int start,
int length)
This implementation does nothing.
|
void |
processingInstruction(String target,
String data)
This implementation does nothing.
|
void |
setDocumentLocator(Locator locator)
This implementation does nothing.
|
void |
skippedEntity(String name)
This implementation does nothing.
|
void |
startDocument()
This implementation does nothing.
|
void |
startElement(String namespaceURI,
String localName,
String qName,
Attributes atts)
Start of a XML elements.
|
void |
startPrefixMapping(String prefix,
String uri)
This implementation does nothing.
|
appRep, error, fatalError, getName, init, report, reportErrors, toString, toStringBuilder, warning
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
error, fatalError, warning
public SAXHandler(CharSequence name, PrintWriter log, boolean reThrow)
SAXHandler
object will be made named according to
the parameter ParseErrorHandler.name
or "...".ParseErrorHandler.log
the parameter log
is taken if not
null and the (decorated) normal output (System.out) otherwise.name
- the handler's or the input's name (stripped from surrounding
white space; null or empty is taken as "..."log
- destination for reportsreThrow
- if true error exceptions are thrown (again) and not just
reportedParseErrorHandler.init(CharSequence, boolean)
,
ParseErrorHandler(CharSequence, PrintWriter, boolean)
public Object getProduct()
public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException
ParseErrorHandler.log
. This method and hence this class is a first useful
test step for the intended SAX application.startElement
in interface ContentHandler
SAXException
ContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
public void endDocument() throws SAXException
endDocument
in interface ContentHandler
SAXException
ContentHandler.endDocument()
public void startDocument() throws SAXException
startDocument
in interface ContentHandler
SAXException
ContentHandler.startDocument()
public void characters(char[] ch, int start, int length) throws SAXException
characters
in interface ContentHandler
SAXException
ContentHandler.characters(char[], int, int)
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException
ignorableWhitespace
in interface ContentHandler
SAXException
ContentHandler.ignorableWhitespace(char[], int, int)
public void endPrefixMapping(String prefix) throws SAXException
endPrefixMapping
in interface ContentHandler
SAXException
ContentHandler.endPrefixMapping(java.lang.String)
public void skippedEntity(String name) throws SAXException
skippedEntity
in interface ContentHandler
SAXException
ContentHandler.skippedEntity(java.lang.String)
public void setDocumentLocator(Locator locator)
setDocumentLocator
in interface ContentHandler
ContentHandler.setDocumentLocator(org.xml.sax.Locator)
public void processingInstruction(String target, String data) throws SAXException
processingInstruction
in interface ContentHandler
SAXException
ContentHandler.processingInstruction(String, java.lang.String)
public void startPrefixMapping(String prefix, String uri) throws SAXException
startPrefixMapping
in interface ContentHandler
SAXException
ContentHandler.startPrefixMapping(String, String)
public void endElement(String namespaceURI, String localName, String qName) throws SAXException
endElement
in interface ContentHandler
SAXException
ContentHandler.endElement(String, String, String)