Package javanet.staxutils
Class StAXEventContentHandler
java.lang.Object
org.xml.sax.helpers.DefaultHandler
javanet.staxutils.StAXContentHandler
javanet.staxutils.StAXEventContentHandler
- All Implemented Interfaces:
ContentHandler
,DTDHandler
,EntityResolver
,ErrorHandler
,LexicalHandler
SAX ContentHandler that writes events to a StAX
XMLEventConsumer
.- Version:
- $Revision: 1.5 $
- Author:
- Christian Niles
-
Field Summary
Fields inherited from class javanet.staxutils.StAXContentHandler
CDATABuffer, docLocator, isCDATA, namespaces, reporter
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a default instance with a default event factory.StAXEventContentHandler
(XMLEventConsumer consumer) Constructs an instance that writes events to the provided XMLEventConsumer.StAXEventContentHandler
(XMLEventConsumer consumer, XMLEventFactory factory) Constructs an instance that writes events constructed with the provided XMLEventFactory to the provided XMLEventConsumer -
Method Summary
Modifier and TypeMethodDescriptionvoid
characters
(char[] ch, int start, int length) void
comment
(char[] ch, int start, int length) protected Namespace
createNamespace
(String prefix, String uri) protected void
createStartEvents
(Attributes attributes, Collection[] events) void
endCDATA()
void
void
endElement
(String uri, String localName, String qName) Returns a reference to theXMLEventConsumer
to which events will be written.Returns a reference to theXMLEventFactory
used to construct events.void
ignorableWhitespace
(char[] ch, int start, int length) void
processingInstruction
(String target, String data) void
setEventConsumer
(XMLEventConsumer consumer) Sets theXMLEventConsumer
to which events are written.void
setEventFactory
(XMLEventFactory factory) Sets theXMLEventFactory
used to create events.void
void
startElement
(String uri, String localName, String qName, Attributes attributes) Methods inherited from class javanet.staxutils.StAXContentHandler
endDTD, endEntity, endPrefixMapping, error, fatalError, getCurrentLocation, parseQName, reportException, setDocumentLocator, setXMLReporter, startCDATA, startDTD, startEntity, startPrefixMapping, warning
Methods inherited from class org.xml.sax.helpers.DefaultHandler
notationDecl, resolveEntity, skippedEntity, unparsedEntityDecl
-
Constructor Details
-
StAXEventContentHandler
public StAXEventContentHandler()Constructs a default instance with a default event factory. You must set theXMLEventConsumer
via thesetEventConsumer(XMLEventConsumer)
method. -
StAXEventContentHandler
Constructs an instance that writes events to the provided XMLEventConsumer. Events will be constructed from a default XMLEventFactory instance.- Parameters:
consumer
- TheXMLEventConsumer
to which events will be written.
-
StAXEventContentHandler
Constructs an instance that writes events constructed with the provided XMLEventFactory to the provided XMLEventConsumer- Parameters:
consumer
- TheXMLEventConsumer
to which events will be written.factory
- TheXMLEventFactory
used to construct events. Ifnull
, a default instance will be constructed.
-
-
Method Details
-
getEventConsumer
Returns a reference to theXMLEventConsumer
to which events will be written.- Returns:
- The
XMLEventConsumer
to which events will be written.
-
setEventConsumer
Sets theXMLEventConsumer
to which events are written.- Parameters:
consumer
- TheXMLEventConsumer
to which events will be written.
-
getEventFactory
Returns a reference to theXMLEventFactory
used to construct events.- Returns:
- The
XMLEventFactory
used to construct events.
-
setEventFactory
Sets theXMLEventFactory
used to create events.- Parameters:
factory
- TheXMLEventFactory
used to create events.
-
startDocument
- Specified by:
startDocument
in interfaceContentHandler
- Overrides:
startDocument
in classStAXContentHandler
- Throws:
SAXException
-
endDocument
- Specified by:
endDocument
in interfaceContentHandler
- Overrides:
endDocument
in classStAXContentHandler
- Throws:
SAXException
-
startElement
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException - Specified by:
startElement
in interfaceContentHandler
- Overrides:
startElement
in classStAXContentHandler
- Throws:
SAXException
-
endElement
- Specified by:
endElement
in interfaceContentHandler
- Overrides:
endElement
in classStAXContentHandler
- Throws:
SAXException
-
comment
- Specified by:
comment
in interfaceLexicalHandler
- Overrides:
comment
in classStAXContentHandler
- Throws:
SAXException
-
characters
- Specified by:
characters
in interfaceContentHandler
- Overrides:
characters
in classStAXContentHandler
- Throws:
SAXException
-
ignorableWhitespace
- Specified by:
ignorableWhitespace
in interfaceContentHandler
- Overrides:
ignorableWhitespace
in classDefaultHandler
- Throws:
SAXException
-
processingInstruction
- Specified by:
processingInstruction
in interfaceContentHandler
- Overrides:
processingInstruction
in classDefaultHandler
- Throws:
SAXException
-
endCDATA
- Specified by:
endCDATA
in interfaceLexicalHandler
- Overrides:
endCDATA
in classStAXContentHandler
- Throws:
SAXException
-
createStartEvents
-
createNamespace
-