Class XOPDecodingStreamReader
- java.lang.Object
-
- org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper
-
- org.apache.axiom.util.stax.xop.XOPDecodingStreamReader
-
- All Implemented Interfaces:
XMLStreamConstants,XMLStreamReader,DataHandlerReader
public class XOPDecodingStreamReader extends XMLStreamReaderWrapper implements DataHandlerReader
XMLStreamReaderwrapper that decodes XOP. It uses the extension defined byDataHandlerReaderto expose theDataHandlerobjects referenced by xop:Include elements encountered in the underlying stream. If the consumer usesgetText(),getTextCharacters(),getTextCharacters(int, char[], int, int)orgetElementText()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
MimePartProviderimplementation 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 theMimePartProviderwill only be invoked whenDataHandlerProvider.getDataHandler()is called.
-
-
Field Summary
-
Fields inherited from interface org.apache.axiom.ext.stax.datahandler.DataHandlerReader
PROPERTY
-
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
Constructors Constructor Description XOPDecodingStreamReader(XMLStreamReader parent, MimePartProvider mimePartProvider)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetContentID()Get the content ID of the binary content for the current event, if available.DataHandlergetDataHandler()Get theDataHandlerwith the binary content for the current event.DataHandlerProvidergetDataHandlerProvider()Get aDataHandlerProviderinstance for deferred loading of the binary content for the current event.StringgetElementText()intgetEventType()StringgetLocalName()LocationgetLocation()QNamegetName()intgetNamespaceCount()StringgetNamespacePrefix(int index)StringgetNamespaceURI()StringgetNamespaceURI(int index)StringgetNamespaceURI(String prefix)StringgetPrefix()ObjectgetProperty(String name)StringgetText()char[]getTextCharacters()intgetTextCharacters(int sourceStart, char[] target, int targetStart, int length)intgetTextLength()intgetTextStart()booleanhasName()booleanhasText()booleanisBinary()Check whether the current event is aXMLStreamConstants.CHARACTERSevent representing base64 encoded binary content and for which aDataHandleris available.booleanisCharacters()booleanisDeferred()Check whether theXMLStreamReadersupports deferred loading of the binary content for the current event.booleanisEndElement()booleanisOptimized()Check if the binary content is eligible for optimization (e.g.booleanisStartElement()booleanisWhiteSpace()intnext()intnextTag()voidrequire(int type, String namespaceURI, String localName)-
Methods 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 Detail
-
XOPDecodingStreamReader
public XOPDecodingStreamReader(XMLStreamReader parent, MimePartProvider mimePartProvider)
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 Detail
-
next
public int next() throws XMLStreamException- Specified by:
nextin interfaceXMLStreamReader- Overrides:
nextin classXMLStreamReaderWrapper- Throws:
XMLStreamException
-
getEventType
public int getEventType()
- Specified by:
getEventTypein interfaceXMLStreamReader- Overrides:
getEventTypein classXMLStreamReaderWrapper
-
nextTag
public int nextTag() throws XMLStreamException- Specified by:
nextTagin interfaceXMLStreamReader- Overrides:
nextTagin classXMLStreamReaderWrapper- Throws:
XMLStreamException
-
getProperty
public Object getProperty(String name) throws IllegalArgumentException
- Specified by:
getPropertyin interfaceXMLStreamReader- Overrides:
getPropertyin classXMLStreamReaderWrapper- Throws:
IllegalArgumentException
-
getElementText
public String getElementText() throws XMLStreamException
- Specified by:
getElementTextin interfaceXMLStreamReader- Overrides:
getElementTextin classXMLStreamReaderWrapper- Throws:
XMLStreamException
-
getPrefix
public String getPrefix()
- Specified by:
getPrefixin interfaceXMLStreamReader- Overrides:
getPrefixin classXMLStreamReaderWrapper
-
getNamespaceURI
public String getNamespaceURI()
- Specified by:
getNamespaceURIin interfaceXMLStreamReader- Overrides:
getNamespaceURIin classXMLStreamReaderWrapper
-
getLocalName
public String getLocalName()
- Specified by:
getLocalNamein interfaceXMLStreamReader- Overrides:
getLocalNamein classXMLStreamReaderWrapper
-
getName
public QName getName()
- Specified by:
getNamein interfaceXMLStreamReader- Overrides:
getNamein classXMLStreamReaderWrapper
-
getLocation
public Location getLocation()
- Specified by:
getLocationin interfaceXMLStreamReader- Overrides:
getLocationin classXMLStreamReaderWrapper
-
getNamespaceURI
public String getNamespaceURI(String prefix)
- Specified by:
getNamespaceURIin interfaceXMLStreamReader- Overrides:
getNamespaceURIin classXMLStreamReaderWrapper
-
getNamespaceCount
public int getNamespaceCount()
- Specified by:
getNamespaceCountin interfaceXMLStreamReader- Overrides:
getNamespaceCountin classXMLStreamReaderWrapper
-
getNamespacePrefix
public String getNamespacePrefix(int index)
- Specified by:
getNamespacePrefixin interfaceXMLStreamReader- Overrides:
getNamespacePrefixin classXMLStreamReaderWrapper
-
getNamespaceURI
public String getNamespaceURI(int index)
- Specified by:
getNamespaceURIin interfaceXMLStreamReader- Overrides:
getNamespaceURIin classXMLStreamReaderWrapper
-
getText
public String 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
public void require(int type, String namespaceURI, String localName) throws XMLStreamException- 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
public String 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
public DataHandler getDataHandler() throws XMLStreamException
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
public DataHandlerProvider 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
-
-