Package org.apache.axiom.util.stax.xop
Class XOPEncodingStreamReader
java.lang.Object
org.apache.axiom.util.stax.xop.XOPEncodingStreamWrapper
org.apache.axiom.util.stax.xop.XOPEncodingStreamReader
- All Implemented Interfaces:
XMLStreamConstants,XMLStreamReader,MimePartProvider
XMLStreamReader wrapper that encodes XOP. It assumes that the underlying reader
implements the extension defined by DataHandlerReader so that it can identify the
information items to optimize (by looking for
XMLStreamConstants.CHARACTERS events for which
DataHandlerReader.isBinary() returns true). The DataHandler
objects for the parts referenced by xop:Include element information items produced by
an instance of this class can be retrieved using the XOPEncodingStreamWrapper.getDataHandler(String) method.
Note that the primary purpose of this class is not to serialize an XML infoset to an XOP package
(this is better done using XOPEncodingStreamWriter), but rather to optimize interaction
(by exchanging DataHandler objects instead of base64 encoded representations) with
databinding frameworks that understand XOP, but that are not aware of the
DataHandlerReader extension.
This class defers loading of DataHandler objects until XOPEncodingStreamWrapper.getDataHandler(String) is
called, except if this is not supported by the underlying stream.
-
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
ConstructorsConstructorDescriptionXOPEncodingStreamReader(XMLStreamReader parent, ContentIDGenerator contentIDGenerator, OptimizationPolicy optimizationPolicy) 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()voidbooleanMethods inherited from class org.apache.axiom.util.stax.xop.XOPEncodingStreamWrapper
getContentIDs, getDataHandler, isLoaded, processDataHandler, processDataHandler
-
Constructor Details
-
XOPEncodingStreamReader
public XOPEncodingStreamReader(XMLStreamReader parent, ContentIDGenerator contentIDGenerator, OptimizationPolicy optimizationPolicy) Constructor.- Parameters:
parent- The XML stream to encode. The reader must implement the extension defined byDataHandlerReader.contentIDGenerator- used to generate content IDs for the binary content exposed as xop:Include element information itemsoptimizationPolicy- the policy to apply to decide which binary content to optimize- Throws:
IllegalArgumentException- if the providedXMLStreamReaderdoesn't implement the extension defined byDataHandlerReader
-
-
Method Details
-
next
- Specified by:
nextin interfaceXMLStreamReader- Throws:
XMLStreamException
-
hasNext
- Specified by:
hasNextin interfaceXMLStreamReader- Throws:
XMLStreamException
-
nextTag
- Specified by:
nextTagin interfaceXMLStreamReader- Throws:
XMLStreamException
-
require
- Specified by:
requirein interfaceXMLStreamReader- Throws:
XMLStreamException
-
getLocation
- Specified by:
getLocationin interfaceXMLStreamReader
-
close
- Specified by:
closein interfaceXMLStreamReader- Throws:
XMLStreamException
-
getProperty
- Specified by:
getPropertyin interfaceXMLStreamReader- Throws:
IllegalArgumentException
-
getEncoding
- Specified by:
getEncodingin interfaceXMLStreamReader
-
getCharacterEncodingScheme
- Specified by:
getCharacterEncodingSchemein interfaceXMLStreamReader
-
getVersion
- Specified by:
getVersionin interfaceXMLStreamReader
-
isStandalone
public boolean isStandalone()- Specified by:
isStandalonein interfaceXMLStreamReader
-
standaloneSet
public boolean standaloneSet()- Specified by:
standaloneSetin interfaceXMLStreamReader
-
getPIData
- Specified by:
getPIDatain interfaceXMLStreamReader
-
getPITarget
- Specified by:
getPITargetin 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
-
getEventType
public int getEventType()- Specified by:
getEventTypein interfaceXMLStreamReader
-
getNamespaceURI
- Specified by:
getNamespaceURIin interfaceXMLStreamReader
-
getLocalName
- Specified by:
getLocalNamein interfaceXMLStreamReader
-
getPrefix
- Specified by:
getPrefixin interfaceXMLStreamReader
-
getName
- Specified by:
getNamein interfaceXMLStreamReader
-
getNamespaceContext
- Specified by:
getNamespaceContextin interfaceXMLStreamReader
-
getNamespaceURI
- Specified by:
getNamespaceURIin interfaceXMLStreamReader
-
getNamespaceCount
public int getNamespaceCount()- Specified by:
getNamespaceCountin interfaceXMLStreamReader
-
getNamespacePrefix
- Specified by:
getNamespacePrefixin interfaceXMLStreamReader
-
getNamespaceURI
- Specified by:
getNamespaceURIin interfaceXMLStreamReader
-
getText
- Specified by:
getTextin interfaceXMLStreamReader
-
getTextStart
public int getTextStart()- Specified by:
getTextStartin interfaceXMLStreamReader
-
getTextLength
public int getTextLength()- Specified by:
getTextLengthin 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
-
hasName
public boolean hasName()- Specified by:
hasNamein interfaceXMLStreamReader
-
hasText
public boolean hasText()- Specified by:
hasTextin interfaceXMLStreamReader
-
isCharacters
public boolean isCharacters()- Specified by:
isCharactersin interfaceXMLStreamReader
-
isWhiteSpace
public boolean isWhiteSpace()- Specified by:
isWhiteSpacein interfaceXMLStreamReader
-
isStartElement
public boolean isStartElement()- Specified by:
isStartElementin interfaceXMLStreamReader
-
isEndElement
public boolean isEndElement()- Specified by:
isEndElementin interfaceXMLStreamReader
-