Package org.apache.axiom.util.stax
Class XMLFragmentStreamReader
java.lang.Object
org.apache.axiom.util.stax.XMLFragmentStreamReader
- All Implemented Interfaces:
XMLStreamConstants,XMLStreamReader
Wrapping XML stream reader that reads a single element from the underlying stream.
It will generate START_DOCUMENT and END_DOCUMENT events as required to make
the sequence of events appear as a complete document.
Assume for example that the parent reader is parsing the following document:
<a><b>text</b></a>If the current event is
<b> when the wrapper is created, it will produce
the following sequence of events:
- A synthetic START_DOCUMENT event.
- START_ELEMENT, CHARACTERS and END_ELEMENT events for
<b>text</b>. For these events, the wrapper directly delegates to the parent reader. - A synthetic END_DOCUMENT event.
</a>. The
XMLFragmentStreamReader(XMLStreamReader, boolean) constructor allows to override this
behavior.
The wrapper will release the reference to the parent reader when close() is called.
For obvious reasons, the wrapper will never call XMLStreamReader.close() on the parent
reader.
-
Field Summary
Fields inherited from interface javax.xml.stream.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
ConstructorsConstructorDescriptionConstructor.XMLFragmentStreamReader(XMLStreamReader parent, boolean proceedToNext) Constructor. -
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
-
XMLFragmentStreamReader
Constructor.- Parameters:
parent- the parent reader to read the fragment from- Throws:
IllegalStateException- if the current event on the parent is not a START_ELEMENT
-
XMLFragmentStreamReader
Constructor.- Parameters:
parent- the parent reader to read the fragment fromproceedToNext- determines whether the parent reader should be positioned on theXMLStreamConstants.END_ELEMENTevent of the fragment (false) or on event following theXMLStreamConstants.END_ELEMENTevent (true) after all events have been consumed from the wrapper- Throws:
IllegalStateException- if the current event on the parent is not a START_ELEMENT
-
-
Method Details
-
getEventType
public int getEventType()- Specified by:
getEventTypein interfaceXMLStreamReader
-
next
- Specified by:
nextin interfaceXMLStreamReader- Throws:
XMLStreamException
-
nextTag
- Specified by:
nextTagin interfaceXMLStreamReader- Throws:
XMLStreamException
-
close
- Specified by:
closein interfaceXMLStreamReader- Throws:
XMLStreamException
-
getProperty
- Specified by:
getPropertyin interfaceXMLStreamReader- Throws:
IllegalArgumentException
-
getCharacterEncodingScheme
- Specified by:
getCharacterEncodingSchemein interfaceXMLStreamReader
-
getEncoding
- Specified by:
getEncodingin interfaceXMLStreamReader
-
getVersion
- Specified by:
getVersionin interfaceXMLStreamReader
-
isStandalone
public boolean isStandalone()- Specified by:
isStandalonein interfaceXMLStreamReader
-
standaloneSet
public boolean standaloneSet()- Specified by:
standaloneSetin interfaceXMLStreamReader
-
getLocation
- Specified by:
getLocationin interfaceXMLStreamReader
-
getAttributeCount
public int getAttributeCount()- Specified by:
getAttributeCountin interfaceXMLStreamReader
-
getAttributeLocalName
- Specified by:
getAttributeLocalNamein interfaceXMLStreamReader
-
getAttributeName
- Specified by:
getAttributeNamein interfaceXMLStreamReader
-
getAttributeNamespace
- Specified by:
getAttributeNamespacein interfaceXMLStreamReader
-
getAttributePrefix
- Specified by:
getAttributePrefixin interfaceXMLStreamReader
-
getAttributeType
- Specified by:
getAttributeTypein interfaceXMLStreamReader
-
getAttributeValue
- Specified by:
getAttributeValuein interfaceXMLStreamReader
-
isAttributeSpecified
public boolean isAttributeSpecified(int index) - Specified by:
isAttributeSpecifiedin interfaceXMLStreamReader
-
getAttributeValue
- Specified by:
getAttributeValuein interfaceXMLStreamReader
-
getElementText
- Specified by:
getElementTextin interfaceXMLStreamReader- Throws:
XMLStreamException
-
getLocalName
- Specified by:
getLocalNamein interfaceXMLStreamReader
-
getName
- Specified by:
getNamein interfaceXMLStreamReader
-
getPrefix
- Specified by:
getPrefixin interfaceXMLStreamReader
-
getNamespaceURI
- Specified by:
getNamespaceURIin 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
-
getPIData
- Specified by:
getPIDatain interfaceXMLStreamReader
-
getPITarget
- Specified by:
getPITargetin interfaceXMLStreamReader
-
getText
- Specified by:
getTextin interfaceXMLStreamReader
-
getTextCharacters
public char[] getTextCharacters()- Specified by:
getTextCharactersin interfaceXMLStreamReader
-
getTextCharacters
public int getTextCharacters(int sourceStart, char[] target, int targetStart, int length) throws XMLStreamException - Specified by:
getTextCharactersin interfaceXMLStreamReader- Throws:
XMLStreamException
-
getTextLength
public int getTextLength()- Specified by:
getTextLengthin interfaceXMLStreamReader
-
getTextStart
public int getTextStart()- Specified by:
getTextStartin interfaceXMLStreamReader
-
hasName
public boolean hasName()- Specified by:
hasNamein interfaceXMLStreamReader
-
hasNext
- Specified by:
hasNextin interfaceXMLStreamReader- Throws:
XMLStreamException
-
hasText
public boolean hasText()- Specified by:
hasTextin interfaceXMLStreamReader
-
isCharacters
public boolean isCharacters()- Specified by:
isCharactersin interfaceXMLStreamReader
-
isStartElement
public boolean isStartElement()- Specified by:
isStartElementin interfaceXMLStreamReader
-
isEndElement
public boolean isEndElement()- Specified by:
isEndElementin interfaceXMLStreamReader
-
isWhiteSpace
public boolean isWhiteSpace()- Specified by:
isWhiteSpacein interfaceXMLStreamReader
-
require
- Specified by:
requirein interfaceXMLStreamReader- Throws:
XMLStreamException
-