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
public class StAXEventContentHandler extends StAXContentHandler
SAX ContentHandler that writes events to a StAXXMLEventConsumer.- Version:
- $Revision: 1.5 $
- Author:
- Christian Niles
-
-
Field Summary
-
Fields inherited from class javanet.staxutils.StAXContentHandler
CDATABuffer, docLocator, isCDATA, namespaces, reporter
-
-
Constructor Summary
Constructors Constructor Description StAXEventContentHandler()Constructs 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcharacters(char[] ch, int start, int length)voidcomment(char[] ch, int start, int length)protected NamespacecreateNamespace(String prefix, String uri)protected voidcreateStartEvents(Attributes attributes, Collection[] events)voidendCDATA()voidendDocument()voidendElement(String uri, String localName, String qName)XMLEventConsumergetEventConsumer()Returns a reference to theXMLEventConsumerto which events will be written.XMLEventFactorygetEventFactory()Returns a reference to theXMLEventFactoryused to construct events.voidignorableWhitespace(char[] ch, int start, int length)voidprocessingInstruction(String target, String data)voidsetEventConsumer(XMLEventConsumer consumer)Sets theXMLEventConsumerto which events are written.voidsetEventFactory(XMLEventFactory factory)Sets theXMLEventFactoryused to create events.voidstartDocument()voidstartElement(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 Detail
-
StAXEventContentHandler
public StAXEventContentHandler()
Constructs a default instance with a default event factory. You must set theXMLEventConsumervia thesetEventConsumer(XMLEventConsumer)method.
-
StAXEventContentHandler
public StAXEventContentHandler(XMLEventConsumer consumer)
Constructs an instance that writes events to the provided XMLEventConsumer. Events will be constructed from a default XMLEventFactory instance.- Parameters:
consumer- TheXMLEventConsumerto which events will be written.
-
StAXEventContentHandler
public StAXEventContentHandler(XMLEventConsumer consumer, XMLEventFactory factory)
Constructs an instance that writes events constructed with the provided XMLEventFactory to the provided XMLEventConsumer- Parameters:
consumer- TheXMLEventConsumerto which events will be written.factory- TheXMLEventFactoryused to construct events. Ifnull, a default instance will be constructed.
-
-
Method Detail
-
getEventConsumer
public XMLEventConsumer getEventConsumer()
Returns a reference to theXMLEventConsumerto which events will be written.- Returns:
- The
XMLEventConsumerto which events will be written.
-
setEventConsumer
public void setEventConsumer(XMLEventConsumer consumer)
Sets theXMLEventConsumerto which events are written.- Parameters:
consumer- TheXMLEventConsumerto which events will be written.
-
getEventFactory
public XMLEventFactory getEventFactory()
Returns a reference to theXMLEventFactoryused to construct events.- Returns:
- The
XMLEventFactoryused to construct events.
-
setEventFactory
public void setEventFactory(XMLEventFactory factory)
Sets theXMLEventFactoryused to create events.- Parameters:
factory- TheXMLEventFactoryused to create events.
-
startDocument
public void startDocument() throws SAXException- Specified by:
startDocumentin interfaceContentHandler- Overrides:
startDocumentin classStAXContentHandler- Throws:
SAXException
-
endDocument
public void endDocument() throws SAXException- Specified by:
endDocumentin interfaceContentHandler- Overrides:
endDocumentin classStAXContentHandler- Throws:
SAXException
-
startElement
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
- Specified by:
startElementin interfaceContentHandler- Overrides:
startElementin classStAXContentHandler- Throws:
SAXException
-
endElement
public void endElement(String uri, String localName, String qName) throws SAXException
- Specified by:
endElementin interfaceContentHandler- Overrides:
endElementin classStAXContentHandler- Throws:
SAXException
-
comment
public void comment(char[] ch, int start, int length) throws SAXException- Specified by:
commentin interfaceLexicalHandler- Overrides:
commentin classStAXContentHandler- Throws:
SAXException
-
characters
public void characters(char[] ch, int start, int length) throws SAXException- Specified by:
charactersin interfaceContentHandler- Overrides:
charactersin classStAXContentHandler- Throws:
SAXException
-
ignorableWhitespace
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException- Specified by:
ignorableWhitespacein interfaceContentHandler- Overrides:
ignorableWhitespacein classDefaultHandler- Throws:
SAXException
-
processingInstruction
public void processingInstruction(String target, String data) throws SAXException
- Specified by:
processingInstructionin interfaceContentHandler- Overrides:
processingInstructionin classDefaultHandler- Throws:
SAXException
-
endCDATA
public void endCDATA() throws SAXException- Specified by:
endCDATAin interfaceLexicalHandler- Overrides:
endCDATAin classStAXContentHandler- Throws:
SAXException
-
createStartEvents
protected void createStartEvents(Attributes attributes, Collection[] events)
-
-