Class XOPDecodingStreamReader
- All Implemented Interfaces:
XMLStreamConstants,XMLStreamReader,DataHandlerReader
XMLStreamReader wrapper that decodes XOP. It uses the extension defined by
DataHandlerReader to expose the DataHandler objects referenced by
xop:Include elements encountered in the underlying stream. If the consumer uses
getText(), getTextCharacters(),
getTextCharacters(int, char[], int, int) or getElementText() when an
xop:Include element is present in the underlying stream, then the decoder will produce
a base64 representation of the data.
Note that this class only implements infoset transformation, but doesn't handle MIME processing.
A MimePartProvider implementation must be provided to the constructor of this class. This
object will be used to load MIME parts referenced by xop:Include elements encountered
in the underlying stream.
This class supports deferred loading of MIME parts: If the consumer uses
DataHandlerReader.getDataHandlerProvider(), then the MimePartProvider will only
be invoked when DataHandlerProvider.getDataHandler() is called.
-
Field Summary
Fields inherited from interface org.apache.axiom.ext.stax.datahandler.DataHandlerReader
PROPERTYFields 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
ConstructorsConstructorDescriptionXOPDecodingStreamReader(XMLStreamReader parent, MimePartProvider mimePartProvider) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionGet the content ID of the binary content for the current event, if available.Get theDataHandlerwith the binary content for the current event.Get aDataHandlerProviderinstance for deferred loading of the binary content for the current event.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()booleanhasText()booleanisBinary()Check whether the current event is aXMLStreamConstants.CHARACTERSevent representing base64 encoded binary content and for which aDataHandleris available.booleanbooleanCheck whether theXMLStreamReadersupports deferred loading of the binary content for the current event.booleanbooleanCheck if the binary content is eligible for optimization (e.g.booleanbooleanintnext()intnextTag()voidMethods inherited from class org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper
close, getAttributeCount, getAttributeLocalName, getAttributeName, getAttributeNamespace, getAttributePrefix, getAttributeType, getAttributeValue, getAttributeValue, getCharacterEncodingScheme, getEncoding, getNamespaceContext, getParent, getPIData, getPITarget, getVersion, hasNext, isAttributeSpecified, isStandalone, standaloneSet
-
Constructor Details
-
XOPDecodingStreamReader
Constructor.- Parameters:
parent- the XML stream to decodemimePartProvider- An implementation of theMimePartProviderinterface that will be used to load theDataHandlerobjects for MIME parts referenced by xop:Include element information items encountered in the underlying stream.
-
-
Method Details
-
next
- Specified by:
nextin interfaceXMLStreamReader- Overrides:
nextin classXMLStreamReaderWrapper- Throws:
XMLStreamException
-
getEventType
public int getEventType()- Specified by:
getEventTypein interfaceXMLStreamReader- Overrides:
getEventTypein classXMLStreamReaderWrapper
-
nextTag
- Specified by:
nextTagin interfaceXMLStreamReader- Overrides:
nextTagin classXMLStreamReaderWrapper- Throws:
XMLStreamException
-
getProperty
- Specified by:
getPropertyin interfaceXMLStreamReader- Overrides:
getPropertyin classXMLStreamReaderWrapper- Throws:
IllegalArgumentException
-
getElementText
- Specified by:
getElementTextin interfaceXMLStreamReader- Overrides:
getElementTextin classXMLStreamReaderWrapper- Throws:
XMLStreamException
-
getPrefix
- Specified by:
getPrefixin interfaceXMLStreamReader- Overrides:
getPrefixin classXMLStreamReaderWrapper
-
getNamespaceURI
- Specified by:
getNamespaceURIin interfaceXMLStreamReader- Overrides:
getNamespaceURIin classXMLStreamReaderWrapper
-
getLocalName
- Specified by:
getLocalNamein interfaceXMLStreamReader- Overrides:
getLocalNamein classXMLStreamReaderWrapper
-
getName
- Specified by:
getNamein interfaceXMLStreamReader- Overrides:
getNamein classXMLStreamReaderWrapper
-
getLocation
- Specified by:
getLocationin interfaceXMLStreamReader- Overrides:
getLocationin classXMLStreamReaderWrapper
-
getNamespaceURI
- Specified by:
getNamespaceURIin interfaceXMLStreamReader- Overrides:
getNamespaceURIin classXMLStreamReaderWrapper
-
getNamespaceCount
public int getNamespaceCount()- Specified by:
getNamespaceCountin interfaceXMLStreamReader- Overrides:
getNamespaceCountin classXMLStreamReaderWrapper
-
getNamespacePrefix
- Specified by:
getNamespacePrefixin interfaceXMLStreamReader- Overrides:
getNamespacePrefixin classXMLStreamReaderWrapper
-
getNamespaceURI
- Specified by:
getNamespaceURIin interfaceXMLStreamReader- Overrides:
getNamespaceURIin classXMLStreamReaderWrapper
-
getText
- Specified by:
getTextin interfaceXMLStreamReader- Overrides:
getTextin classXMLStreamReaderWrapper
-
getTextCharacters
public char[] getTextCharacters()- Specified by:
getTextCharactersin interfaceXMLStreamReader- Overrides:
getTextCharactersin classXMLStreamReaderWrapper
-
getTextCharacters
public int getTextCharacters(int sourceStart, char[] target, int targetStart, int length) throws XMLStreamException - Specified by:
getTextCharactersin interfaceXMLStreamReader- Overrides:
getTextCharactersin classXMLStreamReaderWrapper- Throws:
XMLStreamException
-
getTextLength
public int getTextLength()- Specified by:
getTextLengthin interfaceXMLStreamReader- Overrides:
getTextLengthin classXMLStreamReaderWrapper
-
getTextStart
public int getTextStart()- Specified by:
getTextStartin interfaceXMLStreamReader- Overrides:
getTextStartin classXMLStreamReaderWrapper
-
hasText
public boolean hasText()- Specified by:
hasTextin interfaceXMLStreamReader- Overrides:
hasTextin classXMLStreamReaderWrapper
-
isCharacters
public boolean isCharacters()- Specified by:
isCharactersin interfaceXMLStreamReader- Overrides:
isCharactersin classXMLStreamReaderWrapper
-
isStartElement
public boolean isStartElement()- Specified by:
isStartElementin interfaceXMLStreamReader- Overrides:
isStartElementin classXMLStreamReaderWrapper
-
isEndElement
public boolean isEndElement()- Specified by:
isEndElementin interfaceXMLStreamReader- Overrides:
isEndElementin classXMLStreamReaderWrapper
-
hasName
public boolean hasName()- Specified by:
hasNamein interfaceXMLStreamReader- Overrides:
hasNamein classXMLStreamReaderWrapper
-
isWhiteSpace
public boolean isWhiteSpace()- Specified by:
isWhiteSpacein interfaceXMLStreamReader- Overrides:
isWhiteSpacein classXMLStreamReaderWrapper
-
require
- Specified by:
requirein interfaceXMLStreamReader- Overrides:
requirein classXMLStreamReaderWrapper- Throws:
XMLStreamException
-
isBinary
public boolean isBinary()Description copied from interface:DataHandlerReaderCheck whether the current event is aXMLStreamConstants.CHARACTERSevent representing base64 encoded binary content and for which aDataHandleris available.- Specified by:
isBinaryin interfaceDataHandlerReader- Returns:
trueif the current event is aXMLStreamConstants.CHARACTERSevent representing base64 encoded binary content and for which aDataHandleris available;falsefor all other types of events.
-
isOptimized
public boolean isOptimized()Description copied from interface:DataHandlerReaderCheck if the binary content is eligible for optimization (e.g. using XOP) or if it should be serialized as base64. Calling this method is only meaningful ifDataHandlerReader.isBinary()returnstruefor the current event. The behavior of this method is undefined if this is not the case.- Specified by:
isOptimizedin interfaceDataHandlerReader- Returns:
trueif the binary content is eligible for optimization;falseotherwise
-
isDeferred
public boolean isDeferred()Description copied from interface:DataHandlerReaderCheck whether theXMLStreamReadersupports deferred loading of the binary content for the current event. If this method returnstruethen a consumer MAY callDataHandlerReader.getDataHandlerProvider()and retrieve theDataHandlerlater usingDataHandlerProvider.getDataHandler(). Calling this method is only meaningful ifDataHandlerReader.isBinary()returnstruefor the current event. The behavior of this method is undefined if this is not the case.- Specified by:
isDeferredin interfaceDataHandlerReader- Returns:
trueif deferred loading is supported;falseotherwise
-
getContentID
Description copied from interface:DataHandlerReaderGet the content ID of the binary content for the current event, if available. The result of this method is defined if and only ifDataHandlerReader.isBinary()returnstruefor the current event.The implementation SHOULD only return a non null value if the content ID has been used previously in an interaction with another component or system. The implementation SHOULD NOT generate a new content ID solely for the purpose of this method.
If available, the returned value MUST be a raw content ID. In particular:
- If the content ID has been extracted from an href attribute, it MUST NOT contain the cid: prefix.
- If it has been extracted from a Content-ID MIME header, it MUST NOT be enclosed in angles (<>).
A consumer MAY use the return value of this method in contexts where it is desirable to preserve the original content ID used by another system or component to identify the binary content. However, the consumer MUST NOT make any assumption about the uniqueness or validity of the content ID (with respect to relevant standards such as RFC822) and SHOULD make provision to sanitize the value if necessary.
- Specified by:
getContentIDin interfaceDataHandlerReader- Returns:
- any content ID used previously to identify the binary content, or
nullif no content ID is known
-
getDataHandler
Description copied from interface:DataHandlerReaderGet theDataHandlerwith the binary content for the current event. The behavior of this method is only defined for events for whichDataHandlerReader.isBinary()returnstrue. For events of this type the method MUST return a validDataHandler, regardless of the return value ofDataHandlerReader.isDeferred(). IfDataHandlerReader.isDeferred()returnstrue, then the consumer may use this method to force the implementation to load the binary content immediately.- Specified by:
getDataHandlerin interfaceDataHandlerReader- Returns:
- the binary content for the current event
- Throws:
XMLStreamException- if an error occurs while loading theDataHandler
-
getDataHandlerProvider
Description copied from interface:DataHandlerReaderGet aDataHandlerProviderinstance for deferred loading of the binary content for the current event. The behavior of this method is defined if and only ifDataHandlerReader.isDeferred()returnstruefor the current event. The returned reference MUST remain valid after the current event has been consumed. It is up to the implementation to specify the exact lifecycle of the returned instance, in particular until when the binary content can be retrieved.- Specified by:
getDataHandlerProviderin interfaceDataHandlerReader- Returns:
- the
DataHandlerProviderinstance the consumer can use to load the binary content at a later time
-