Class AbstractXMLStreamReader<T>
java.lang.Object
org.apache.synapse.commons.staxon.core.base.AbstractXMLStreamReader<T>
- All Implemented Interfaces:
XMLStreamConstants,XMLStreamReader
- Direct Known Subclasses:
JsonXMLStreamReader
Abstract XML stream 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
ConstructorsConstructorDescriptionAbstractXMLStreamReader(T rootInfo) Create new reader instance.AbstractXMLStreamReader(T rootInfo, Location locationProvider) Create new reader instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()protected abstract booleanconsume()Main method to be implemented by subclasses.intgetAttributeLocalName(int index) getAttributeName(int index) getAttributeNamespace(int index) getAttributePrefix(int index) getAttributeType(int index) getAttributeValue(int index) getAttributeValue(String namespaceURI, String localName) protected final Objectprotected StringintgetName()intgetNamespacePrefix(int index) getNamespaceURI(int index) getNamespaceURI(String prefix) getProperty(String name) protected XMLStreamReaderScope<T> getScope()getText()char[]intgetTextCharacters(int sourceStart, char[] target, int targetStart, int length) intintbooleanhasName()booleanhasNext()booleanhasText()protected voidConsume initial event.booleanisAttributeSpecified(int index) booleanbooleanbooleanprotected booleanbooleanbooleanintnext()intnextTag()protected voidRead attribute.protected voidRead characters/comment/dtd/entity data.protected voidRead end document.protected voidRead end element.protected voidreadNsDecl(String prefix, String namespaceURI) Read namespace declaration.protected voidRead processing instruction.protected voidreadStartDocument(String version, String encodingScheme, Boolean standalone) Read start documentprotected voidreadStartElementTag(String prefix, String localName, String namespaceURI, T scopeInfo) Read start element.voidbooleantoString()
-
Constructor Details
-
AbstractXMLStreamReader
Create new reader instance.- Parameters:
rootInfo- root scope information
-
AbstractXMLStreamReader
Create new reader instance.- Parameters:
rootInfo- root scope information
-
-
Method Details
-
getScope
- Returns:
- current scope
-
isStartDocumentRead
protected boolean isStartDocumentRead()- Returns:
trueifSTART_DOCUMENTevent has been read
-
initialize
Consume initial event. This method must be called by subclasses prior to any use of an instance (typically in constructor).- Throws:
XMLStreamException
-
consume
Main method to be implemented by subclasses. This method is called by the reader when the event queue runs dry. Consume some events and delegate to the variousreadXXX()methods. When encountering an element start event, all attributes and namespace delarations must be consumed too, otherwise these won't be available during start element.- Returns:
trueif there's more to read- Throws:
XMLStreamExceptionIOException
-
readStartDocument
protected void readStartDocument(String version, String encodingScheme, Boolean standalone) throws XMLStreamException Read start document- Parameters:
version- XML versionencodingScheme- encoding scheme (may benull)standalone- standalone flag (may benull)- Throws:
XMLStreamException
-
readStartElementTag
protected void readStartElementTag(String prefix, String localName, String namespaceURI, T scopeInfo) throws XMLStreamException Read start element. A new scope is created and made the current scope. The providedscopeInfois stored in the new scope and will be available viagetScope().getInfo().- Parameters:
prefix- element prefix (usenullif unknown)localName- local namenamespaceURI- (usenullif unknown)scopeInfo- new scope info- Throws:
XMLStreamException
-
readAttr
protected void readAttr(String prefix, String localName, String namespaceURI, String value) throws XMLStreamException Read attribute.- Parameters:
prefix- attribute prefix (usenullif unknown)localName- local namenamespaceURI- (usenullif unknown)value- attribute value- Throws:
XMLStreamException
-
readNsDecl
Read namespace declaration.- Parameters:
prefix- namespace prefix (must not benull)namespaceURI- namespace URI (must not benull)- Throws:
XMLStreamException
-
readData
Read characters/comment/dtd/entity data.- Parameters:
text- textdata- additional data exposed bygetEventData()(e.g. type conversion)type- one ofCHARACTERS, COMMENT, CDATA, DTD, ENTITY_REFERENCE, SPACE- Throws:
XMLStreamException
-
readPI
Read processing instruction.- Parameters:
target- PI targetdata- PI data (may benull)- Throws:
XMLStreamException
-
readEndElementTag
Read end element. This will pop the current scope and make its parent the new current scope.- Throws:
XMLStreamException
-
readEndDocument
Read end document.- Throws:
XMLStreamException
-
require
- Specified by:
requirein interfaceXMLStreamReader- Throws:
XMLStreamException
-
getElementText
- Specified by:
getElementTextin interfaceXMLStreamReader- Throws:
XMLStreamException
-
hasNext
- Specified by:
hasNextin interfaceXMLStreamReader- Throws:
XMLStreamException
-
next
- Specified by:
nextin interfaceXMLStreamReader- Throws:
XMLStreamException
-
nextTag
- Specified by:
nextTagin interfaceXMLStreamReader- Throws:
XMLStreamException
-
close
- Specified by:
closein interfaceXMLStreamReader- Throws:
XMLStreamException
-
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
-
getAttributeCount
public int getAttributeCount()- Specified by:
getAttributeCountin interfaceXMLStreamReader
-
getAttributeName
- Specified by:
getAttributeNamein interfaceXMLStreamReader
-
getAttributeLocalName
- Specified by:
getAttributeLocalNamein interfaceXMLStreamReader
-
getAttributeValue
- Specified by:
getAttributeValuein interfaceXMLStreamReader
-
getAttributePrefix
- Specified by:
getAttributePrefixin interfaceXMLStreamReader
-
getAttributeNamespace
- Specified by:
getAttributeNamespacein interfaceXMLStreamReader
-
getAttributeType
- Specified by:
getAttributeTypein interfaceXMLStreamReader
-
isAttributeSpecified
public boolean isAttributeSpecified(int index) - Specified by:
isAttributeSpecifiedin interfaceXMLStreamReader
-
getAttributeValue
- Specified by:
getAttributeValuein interfaceXMLStreamReader
-
getNamespaceURI
- Specified by:
getNamespaceURIin interfaceXMLStreamReader
-
getNamespaceCount
public int getNamespaceCount()- Specified by:
getNamespaceCountin interfaceXMLStreamReader
-
getNamespacePrefix
- Specified by:
getNamespacePrefixin interfaceXMLStreamReader
-
getNamespaceURI
- Specified by:
getNamespaceURIin interfaceXMLStreamReader
-
getNamespaceContext
- Specified by:
getNamespaceContextin interfaceXMLStreamReader
-
getEventType
public int getEventType()- Specified by:
getEventTypein interfaceXMLStreamReader
-
getEventName
-
getEventData
- Returns:
- raw event data
-
getLocation
- Specified by:
getLocationin interfaceXMLStreamReader
-
hasText
public boolean hasText()- Specified by:
hasTextin 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
-
getTextStart
public int getTextStart()- Specified by:
getTextStartin interfaceXMLStreamReader
-
getTextLength
public int getTextLength()- Specified by:
getTextLengthin interfaceXMLStreamReader
-
hasName
public boolean hasName()- Specified by:
hasNamein interfaceXMLStreamReader
-
getName
- Specified by:
getNamein interfaceXMLStreamReader
-
getLocalName
- Specified by:
getLocalNamein interfaceXMLStreamReader
-
getNamespaceURI
- Specified by:
getNamespaceURIin interfaceXMLStreamReader
-
getPrefix
- Specified by:
getPrefixin interfaceXMLStreamReader
-
getVersion
- Specified by:
getVersionin interfaceXMLStreamReader
-
getEncoding
- Specified by:
getEncodingin interfaceXMLStreamReader
-
isStandalone
public boolean isStandalone()- Specified by:
isStandalonein interfaceXMLStreamReader
-
standaloneSet
public boolean standaloneSet()- Specified by:
standaloneSetin interfaceXMLStreamReader
-
getCharacterEncodingScheme
- Specified by:
getCharacterEncodingSchemein interfaceXMLStreamReader
-
getPITarget
- Specified by:
getPITargetin interfaceXMLStreamReader
-
getPIData
- Specified by:
getPIDatain interfaceXMLStreamReader
-
getProperty
- Specified by:
getPropertyin interfaceXMLStreamReader- Throws:
IllegalArgumentException
-
toString
-