Class STAXEventReader
java.lang.Object
org.dom4j.io.STAXEventReader
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate DocumentFactoryReference to the DocumentFactory used to build DOM4J nodes.private XMLInputFactoryA StAX input factory, used to construct streams from IO streams. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a defaultSTAXEventReaderinstance with a defaultDocumentFactory.STAXEventReader(DocumentFactory factory) Constructs aSTAXEventReaderinstance that uses the specifiedDocumentFactoryto construct DOM4JNodes. -
Method Summary
Modifier and TypeMethodDescriptioncreateAttribute(Element elem, Attribute attr) Constructs a new DOM4J Attribute from the provided StAX Attribute event.createCharacterData(Characters characters) Constructs a new DOM4J Text or CDATA object from the provided Characters event.createComment(Comment comment) Constructs a new DOM4J Comment from the provided StAX Comment event.createElement(StartElement startEvent) Constructs a new DOM4J Element from the provided StartElement event.createEntity(EntityReference entityRef) Constructs a new DOM4J Entity from the provided StAX EntityReference event.Constructs a new DOM4J Namespace from the provided StAX Namespace event.Constructs a new DOM4J ProcessingInstruction from the provided StAX ProcessingInstruction event.createQName(QName qname) Constructs a new DOM4J QName from the provided JAXP QName.readAttribute(XMLEventReader reader) Constructs a DOM4J Attribute from the provided event stream.readCharacters(XMLEventReader reader) Constructs a DOM4J Text or CDATA section from the provided event stream.readComment(XMLEventReader reader) Constructs a DOM4J Comment from the provided event stream.Constructs a StAX event stream from the provided I/O stream and reads a DOM4J document from it.readDocument(InputStream is, String systemId) Constructs a StAX event stream from the provided I/O stream and reads a DOM4J document from it.readDocument(Reader reader) Constructs a StAX event stream from the provided I/O character stream and reads a DOM4J document from it.readDocument(Reader reader, String systemId) Constructs a StAX event stream from the provided I/O character stream and reads a DOM4J document from it.readDocument(XMLEventReader reader) Reads a DOM4JDocumentfrom the provided stream.readElement(XMLEventReader eventReader) Reads a DOM4J Element from the provided event stream.readEntityReference(XMLEventReader reader) Constructs a DOM4J Entity from the provided event stream.readNamespace(XMLEventReader reader) Constructs a DOM4J Namespace from the provided event stream.readNode(XMLEventReader reader) Reads aNodefrom the event stream.Constructs a DOM4J ProcessingInstruction from the provided event stream.voidsetDocumentFactory(DocumentFactory documentFactory) Sets the DocumentFactory to be used when constructing DOM4J nodes.
-
Field Details
-
factory
Reference to the DocumentFactory used to build DOM4J nodes. -
inputFactory
A StAX input factory, used to construct streams from IO streams.
-
-
Constructor Details
-
STAXEventReader
public STAXEventReader()Constructs a defaultSTAXEventReaderinstance with a defaultDocumentFactory. -
STAXEventReader
Constructs aSTAXEventReaderinstance that uses the specifiedDocumentFactoryto construct DOM4JNodes.- Parameters:
factory- The DocumentFactory to use when constructing DOM4J nodes, ornullif a default should be used.
-
-
Method Details
-
setDocumentFactory
Sets the DocumentFactory to be used when constructing DOM4J nodes.- Parameters:
documentFactory- The DocumentFactory to use when constructing DOM4J nodes, ornullif a default should be used.
-
readDocument
Constructs a StAX event stream from the provided I/O stream and reads a DOM4J document from it.- Parameters:
is- The I/O stream from which the Document will be read.- Returns:
- The Document that was read from the stream.
- Throws:
XMLStreamException- If an error occurs reading content from the stream.
-
readDocument
Constructs a StAX event stream from the provided I/O character stream and reads a DOM4J document from it.- Parameters:
reader- The character stream from which the Document will be read.- Returns:
- The Document that was read from the stream.
- Throws:
XMLStreamException- If an error occurs reading content from the stream.
-
readDocument
Constructs a StAX event stream from the provided I/O stream and reads a DOM4J document from it.- Parameters:
is- The I/O stream from which the Document will be read.systemId- A system id used to resolve entities.- Returns:
- The Document that was read from the stream.
- Throws:
XMLStreamException- If an error occurs reading content from the stream.
-
readDocument
Constructs a StAX event stream from the provided I/O character stream and reads a DOM4J document from it.- Parameters:
reader- The character stream from which the Document will be read.systemId- A system id used to resolve entities.- Returns:
- The Document that was read from the stream.
- Throws:
XMLStreamException- If an error occurs reading content from the stream.
-
readNode
Reads aNodefrom the event stream. If the next event is aStartElement, all events until the closingEndElementwill be read, and the resulting nodes will be added to the returnedElement.Pre-Conditions : The stream must be positioned before an event other than an
EndElement,EndDocument, or any DTD-related events, which are not currently supported.- Parameters:
reader- The reader from which events will be read.- Returns:
- A DOM4J
Nodeconstructed from the read events. - Throws:
XMLStreamException- If an error occurs reading from the stream, or the stream was positioned before an unsupported event.
-
readDocument
Reads a DOM4JDocumentfrom the provided stream. The stream should be positioned at the start of a document, or before aStartElementevent.- Parameters:
reader- The event stream from which to read theDocument.- Returns:
- The
Documentthat was read from the stream. - Throws:
XMLStreamException- If an error occurs reading events from the stream.
-
readElement
Reads a DOM4J Element from the provided event stream. The stream must be positioned before anStartElementevent. In addition to the initial start event, all events up to and including the closingEndElementwill be read, and included with the returned element.- Parameters:
eventReader- The event stream from which to read the Element.- Returns:
- The Element that was read from the stream.
- Throws:
XMLStreamException- If an error occured reading events from the stream, or the stream was not positioned before aStartElementevent.
-
readAttribute
Constructs a DOM4J Attribute from the provided event stream. The stream must be positioned before anAttributeevent.- Parameters:
reader- The event stream from which to read the Attribute.- Returns:
- The Attribute that was read from the stream.
- Throws:
XMLStreamException- If an error occured reading events from the stream, or the stream was not positioned before anAttributeevent.
-
readNamespace
Constructs a DOM4J Namespace from the provided event stream. The stream must be positioned before aNamespaceevent.- Parameters:
reader- The event stream from which to read the Namespace.- Returns:
- The Namespace that was read from the stream.
- Throws:
XMLStreamException- If an error occured reading events from the stream, or the stream was not positioned before aNamespaceevent.
-
readCharacters
Constructs a DOM4J Text or CDATA section from the provided event stream. The stream must be positioned before aCharactersevent.- Parameters:
reader- The event stream from which to read the Text or CDATA.- Returns:
- The Text or CDATA that was read from the stream.
- Throws:
XMLStreamException- If an error occured reading events from the stream, or the stream was not positioned before aCharactersevent.
-
readComment
Constructs a DOM4J Comment from the provided event stream. The stream must be positioned before aCommentevent.- Parameters:
reader- The event stream from which to read the Comment.- Returns:
- The Comment that was read from the stream.
- Throws:
XMLStreamException- If an error occured reading events from the stream, or the stream was not positioned before aCommentevent.
-
readEntityReference
Constructs a DOM4J Entity from the provided event stream. The stream must be positioned before anEntityReferenceevent.- Parameters:
reader- The event stream from which to read theEntityReference.- Returns:
- The
Entitythat was read from the stream. - Throws:
XMLStreamException- If an error occured reading events from the stream, or the stream was not positioned before anEntityReferenceevent.
-
readProcessingInstruction
public ProcessingInstruction readProcessingInstruction(XMLEventReader reader) throws XMLStreamException Constructs a DOM4J ProcessingInstruction from the provided event stream. The stream must be positioned before aProcessingInstructionevent.- Parameters:
reader- The event stream from which to read the ProcessingInstruction.- Returns:
- The ProcessingInstruction that was read from the stream.
- Throws:
XMLStreamException- If an error occured reading events from the stream, or the stream was not positioned before aProcessingInstructionevent.
-
createElement
Constructs a new DOM4J Element from the provided StartElement event. All attributes and namespaces will be added to the returned element.- Parameters:
startEvent- The StartElement event from which to construct the new DOM4J Element.- Returns:
- The Element constructed from the provided StartElement event.
-
createAttribute
Constructs a new DOM4J Attribute from the provided StAX Attribute event.- Parameters:
elem- DOCUMENT ME!attr- The Attribute event from which to construct the new DOM4J Attribute.- Returns:
- The Attribute constructed from the provided Attribute event.
-
createNamespace
-
createCharacterData
Constructs a new DOM4J Text or CDATA object from the provided Characters event.- Parameters:
characters- The Characters event from which to construct the new DOM4J Text or CDATA object.- Returns:
- The Text or CDATA object constructed from the provided Characters event.
-
createComment
-
createEntity
Constructs a new DOM4J Entity from the provided StAX EntityReference event.- Parameters:
entityRef- The EntityReference event from which to construct the new DOM4J Entity.- Returns:
- The Entity constructed from the provided EntityReference event.
-
createProcessingInstruction
Constructs a new DOM4J ProcessingInstruction from the provided StAX ProcessingInstruction event.- Parameters:
pi- The ProcessingInstruction event from which to construct the new DOM4J ProcessingInstruction.- Returns:
- The ProcessingInstruction constructed from the provided ProcessingInstruction event.
-
createQName
-