Class DomTripStreamReader
java.lang.Object
eu.maveniverse.domtrip.stax.DomTripStreamReader
- All Implemented Interfaces:
XMLStreamConstants, XMLStreamReader
Pull-based
XMLStreamReader implementation backed by a domtrip Document.
This enables domtrip to participate in StAX-based XML processing pipelines. Rather than serializing to a string and re-parsing, the reader walks the domtrip tree directly and exposes it as a sequence of StAX events via the cursor API.
Note: Formatting preservation is intentionally lost at this boundary since StAX events do not carry formatting metadata. The value is interoperability, not round-tripping through StAX.
Usage Examples:
Document doc = Document.of(xml);
// Create a StAX reader
DomTripStreamReader reader = new DomTripStreamReader(doc);
while (reader.hasNext()) {
int event = reader.next();
// process events...
}
// Use with JAXP via StAXSource
StAXSource source = DomTripStAXSource.of(doc);
transformer.transform(source, result);
- Since:
- 1.3.0
- See Also:
-
Field Summary
Fields inherited from interface XMLStreamConstants
ATTRIBUTE, CDATA, CHARACTERS, COMMENT, DTD, END_DOCUMENT, END_ELEMENT, ENTITY_DECLARATION, ENTITY_REFERENCE, NAMESPACE, NOTATION_DECLARATION, PROCESSING_INSTRUCTION, SPACE, START_DOCUMENT, START_ELEMENT -
Constructor Summary
ConstructorsConstructorDescriptionDomTripStreamReader(Document document) Creates a new StAX reader for the given document. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()intgetAttributeLocalName(int index) getAttributeName(int index) getAttributeNamespace(int index) getAttributePrefix(int index) getAttributeType(int index) getAttributeValue(int index) getAttributeValue(String namespaceURI, String localName) intgetName()intgetNamespacePrefix(int index) getNamespaceURI(int index) getNamespaceURI(String prefix) getProperty(String name) getText()char[]intgetTextCharacters(int sourceStart, char[] target, int targetStart, int length) intintbooleanhasName()booleanhasNext()booleanhasText()booleanisAttributeSpecified(int index) booleanbooleanbooleanbooleanbooleanintnext()intnextTag()voidboolean
-
Constructor Details
-
DomTripStreamReader
Creates a new StAX reader for the given document.The reader starts at
XMLStreamConstants.START_DOCUMENT.- Parameters:
document- the document to read- Throws:
IllegalArgumentException- if document is null
-
-
Method Details
-
next
- Specified by:
nextin interfaceXMLStreamReader- Throws:
XMLStreamException
-
hasNext
- Specified by:
hasNextin interfaceXMLStreamReader- Throws:
XMLStreamException
-
getEventType
public int getEventType()- Specified by:
getEventTypein interfaceXMLStreamReader
-
getName
- Specified by:
getNamein interfaceXMLStreamReader
-
getLocalName
- Specified by:
getLocalNamein interfaceXMLStreamReader
-
getPrefix
- Specified by:
getPrefixin interfaceXMLStreamReader
-
getNamespaceURI
- Specified by:
getNamespaceURIin interfaceXMLStreamReader
-
getAttributeCount
public int getAttributeCount()- Specified by:
getAttributeCountin interfaceXMLStreamReader
-
getAttributeName
- Specified by:
getAttributeNamein interfaceXMLStreamReader
-
getAttributeLocalName
- Specified by:
getAttributeLocalNamein interfaceXMLStreamReader
-
getAttributePrefix
- Specified by:
getAttributePrefixin interfaceXMLStreamReader
-
getAttributeNamespace
- Specified by:
getAttributeNamespacein interfaceXMLStreamReader
-
getAttributeType
- Specified by:
getAttributeTypein interfaceXMLStreamReader
-
getAttributeValue
- Specified by:
getAttributeValuein interfaceXMLStreamReader
-
getAttributeValue
- Specified by:
getAttributeValuein interfaceXMLStreamReader
-
isAttributeSpecified
public boolean isAttributeSpecified(int index) - Specified by:
isAttributeSpecifiedin interfaceXMLStreamReader
-
getNamespaceCount
public int getNamespaceCount()- Specified by:
getNamespaceCountin interfaceXMLStreamReader
-
getNamespacePrefix
- Specified by:
getNamespacePrefixin interfaceXMLStreamReader
-
getNamespaceURI
- Specified by:
getNamespaceURIin interfaceXMLStreamReader
-
getNamespaceURI
- Specified by:
getNamespaceURIin interfaceXMLStreamReader
-
getNamespaceContext
- Specified by:
getNamespaceContextin interfaceXMLStreamReader
-
getText
- Specified by:
getTextin interfaceXMLStreamReader
-
getTextCharacters
public char[] getTextCharacters()- Specified by:
getTextCharactersin interfaceXMLStreamReader
-
getTextStart
public int getTextStart()- Specified by:
getTextStartin interfaceXMLStreamReader
-
getTextLength
public int getTextLength()- Specified by:
getTextLengthin interfaceXMLStreamReader
-
getTextCharacters
public int getTextCharacters(int sourceStart, char[] target, int targetStart, int length) throws XMLStreamException - Specified by:
getTextCharactersin interfaceXMLStreamReader- Throws:
XMLStreamException
-
getPITarget
- Specified by:
getPITargetin interfaceXMLStreamReader
-
getPIData
- Specified by:
getPIDatain interfaceXMLStreamReader
-
getEncoding
- Specified by:
getEncodingin interfaceXMLStreamReader
-
getVersion
- Specified by:
getVersionin interfaceXMLStreamReader
-
getCharacterEncodingScheme
- Specified by:
getCharacterEncodingSchemein interfaceXMLStreamReader
-
isStandalone
public boolean isStandalone()- Specified by:
isStandalonein interfaceXMLStreamReader
-
standaloneSet
public boolean standaloneSet()- Specified by:
standaloneSetin interfaceXMLStreamReader
-
isStartElement
public boolean isStartElement()- Specified by:
isStartElementin interfaceXMLStreamReader
-
isEndElement
public boolean isEndElement()- Specified by:
isEndElementin interfaceXMLStreamReader
-
isCharacters
public boolean isCharacters()- Specified by:
isCharactersin interfaceXMLStreamReader
-
isWhiteSpace
public boolean isWhiteSpace()- Specified by:
isWhiteSpacein interfaceXMLStreamReader
-
hasName
public boolean hasName()- Specified by:
hasNamein interfaceXMLStreamReader
-
hasText
public boolean hasText()- Specified by:
hasTextin interfaceXMLStreamReader
-
require
- Specified by:
requirein interfaceXMLStreamReader- Throws:
XMLStreamException
-
getElementText
- Specified by:
getElementTextin interfaceXMLStreamReader- Throws:
XMLStreamException
-
nextTag
- Specified by:
nextTagin interfaceXMLStreamReader- Throws:
XMLStreamException
-
getLocation
- Specified by:
getLocationin interfaceXMLStreamReader
-
getProperty
- Specified by:
getPropertyin interfaceXMLStreamReader
-
close
public void close()- Specified by:
closein interfaceXMLStreamReader
-