public class XOPDecodingStreamReader extends XMLStreamReaderWrapper implements 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.
PROPERTY
ATTRIBUTE, CDATA, CHARACTERS, COMMENT, DTD, END_DOCUMENT, END_ELEMENT, ENTITY_DECLARATION, ENTITY_REFERENCE, NAMESPACE, NOTATION_DECLARATION, PROCESSING_INSTRUCTION, SPACE, START_DOCUMENT, START_ELEMENT
Constructor and Description |
---|
XOPDecodingStreamReader(javax.xml.stream.XMLStreamReader parent,
MimePartProvider mimePartProvider)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
String |
getContentID()
Get the content ID of the binary content for the current event, if available.
|
javax.activation.DataHandler |
getDataHandler()
Get the
DataHandler with the binary content for the current event. |
DataHandlerProvider |
getDataHandlerProvider()
Get a
DataHandlerProvider instance for deferred loading of the binary content for the
current event. |
String |
getElementText() |
int |
getEventType() |
String |
getLocalName() |
javax.xml.stream.Location |
getLocation() |
QName |
getName() |
int |
getNamespaceCount() |
String |
getNamespacePrefix(int index) |
String |
getNamespaceURI() |
String |
getNamespaceURI(int index) |
String |
getNamespaceURI(String prefix) |
String |
getPrefix() |
Object |
getProperty(String name) |
String |
getText() |
char[] |
getTextCharacters() |
int |
getTextCharacters(int sourceStart,
char[] target,
int targetStart,
int length) |
int |
getTextLength() |
int |
getTextStart() |
boolean |
hasName() |
boolean |
hasText() |
boolean |
isBinary()
Check whether the current event is a
XMLStreamConstants.CHARACTERS
event representing base64 encoded binary content and for which a
DataHandler is available. |
boolean |
isCharacters() |
boolean |
isDeferred()
Check whether the
XMLStreamReader supports deferred loading of the
binary content for the current event. |
boolean |
isEndElement() |
boolean |
isOptimized()
Check if the binary content is eligible for optimization (e.g. using XOP) or if it should
be serialized as base64.
|
boolean |
isStartElement() |
boolean |
isWhiteSpace() |
int |
next() |
int |
nextTag() |
void |
require(int type,
String namespaceURI,
String localName) |
close, getAttributeCount, getAttributeLocalName, getAttributeName, getAttributeNamespace, getAttributePrefix, getAttributeType, getAttributeValue, getAttributeValue, getCharacterEncodingScheme, getEncoding, getNamespaceContext, getParent, getPIData, getPITarget, getVersion, hasNext, isAttributeSpecified, isStandalone, standaloneSet
public XOPDecodingStreamReader(javax.xml.stream.XMLStreamReader parent, MimePartProvider mimePartProvider)
parent
- the XML stream to decodemimePartProvider
- An implementation of the MimePartProvider
interface that will be used to
load the DataHandler
objects for MIME parts referenced by
xop:Include element information items encountered in the underlying
stream.public int next() throws javax.xml.stream.XMLStreamException
next
in interface javax.xml.stream.XMLStreamReader
next
in class XMLStreamReaderWrapper
javax.xml.stream.XMLStreamException
public int getEventType()
getEventType
in interface javax.xml.stream.XMLStreamReader
getEventType
in class XMLStreamReaderWrapper
public int nextTag() throws javax.xml.stream.XMLStreamException
nextTag
in interface javax.xml.stream.XMLStreamReader
nextTag
in class XMLStreamReaderWrapper
javax.xml.stream.XMLStreamException
public Object getProperty(String name) throws IllegalArgumentException
getProperty
in interface javax.xml.stream.XMLStreamReader
getProperty
in class XMLStreamReaderWrapper
IllegalArgumentException
public String getElementText() throws javax.xml.stream.XMLStreamException
getElementText
in interface javax.xml.stream.XMLStreamReader
getElementText
in class XMLStreamReaderWrapper
javax.xml.stream.XMLStreamException
public String getPrefix()
getPrefix
in interface javax.xml.stream.XMLStreamReader
getPrefix
in class XMLStreamReaderWrapper
public String getNamespaceURI()
getNamespaceURI
in interface javax.xml.stream.XMLStreamReader
getNamespaceURI
in class XMLStreamReaderWrapper
public String getLocalName()
getLocalName
in interface javax.xml.stream.XMLStreamReader
getLocalName
in class XMLStreamReaderWrapper
public QName getName()
getName
in interface javax.xml.stream.XMLStreamReader
getName
in class XMLStreamReaderWrapper
public javax.xml.stream.Location getLocation()
getLocation
in interface javax.xml.stream.XMLStreamReader
getLocation
in class XMLStreamReaderWrapper
public String getNamespaceURI(String prefix)
getNamespaceURI
in interface javax.xml.stream.XMLStreamReader
getNamespaceURI
in class XMLStreamReaderWrapper
public int getNamespaceCount()
getNamespaceCount
in interface javax.xml.stream.XMLStreamReader
getNamespaceCount
in class XMLStreamReaderWrapper
public String getNamespacePrefix(int index)
getNamespacePrefix
in interface javax.xml.stream.XMLStreamReader
getNamespacePrefix
in class XMLStreamReaderWrapper
public String getNamespaceURI(int index)
getNamespaceURI
in interface javax.xml.stream.XMLStreamReader
getNamespaceURI
in class XMLStreamReaderWrapper
public String getText()
getText
in interface javax.xml.stream.XMLStreamReader
getText
in class XMLStreamReaderWrapper
public char[] getTextCharacters()
getTextCharacters
in interface javax.xml.stream.XMLStreamReader
getTextCharacters
in class XMLStreamReaderWrapper
public int getTextCharacters(int sourceStart, char[] target, int targetStart, int length) throws javax.xml.stream.XMLStreamException
getTextCharacters
in interface javax.xml.stream.XMLStreamReader
getTextCharacters
in class XMLStreamReaderWrapper
javax.xml.stream.XMLStreamException
public int getTextLength()
getTextLength
in interface javax.xml.stream.XMLStreamReader
getTextLength
in class XMLStreamReaderWrapper
public int getTextStart()
getTextStart
in interface javax.xml.stream.XMLStreamReader
getTextStart
in class XMLStreamReaderWrapper
public boolean hasText()
hasText
in interface javax.xml.stream.XMLStreamReader
hasText
in class XMLStreamReaderWrapper
public boolean isCharacters()
isCharacters
in interface javax.xml.stream.XMLStreamReader
isCharacters
in class XMLStreamReaderWrapper
public boolean isStartElement()
isStartElement
in interface javax.xml.stream.XMLStreamReader
isStartElement
in class XMLStreamReaderWrapper
public boolean isEndElement()
isEndElement
in interface javax.xml.stream.XMLStreamReader
isEndElement
in class XMLStreamReaderWrapper
public boolean hasName()
hasName
in interface javax.xml.stream.XMLStreamReader
hasName
in class XMLStreamReaderWrapper
public boolean isWhiteSpace()
isWhiteSpace
in interface javax.xml.stream.XMLStreamReader
isWhiteSpace
in class XMLStreamReaderWrapper
public void require(int type, String namespaceURI, String localName) throws javax.xml.stream.XMLStreamException
require
in interface javax.xml.stream.XMLStreamReader
require
in class XMLStreamReaderWrapper
javax.xml.stream.XMLStreamException
public boolean isBinary()
DataHandlerReader
XMLStreamConstants.CHARACTERS
event representing base64 encoded binary content and for which a
DataHandler
is available.isBinary
in interface DataHandlerReader
true
if the current event is a
XMLStreamConstants.CHARACTERS
event representing base64
encoded binary content and for which a DataHandler
is
available; false
for all other types of events.public boolean isOptimized()
DataHandlerReader
DataHandlerReader.isBinary()
returns true
for
the current event. The behavior of this method is undefined if this is not the case.isOptimized
in interface DataHandlerReader
true
if the binary content is eligible for optimization;
false
otherwisepublic boolean isDeferred()
DataHandlerReader
XMLStreamReader
supports deferred loading of the
binary content for the current event. If this method returns true
then a
consumer MAY call DataHandlerReader.getDataHandlerProvider()
and retrieve the
DataHandler
later using DataHandlerProvider.getDataHandler()
.
Calling this method is only meaningful if DataHandlerReader.isBinary()
returns true
for
the current event. The behavior of this method is undefined if this is not the case.isDeferred
in interface DataHandlerReader
true
if deferred loading is supported; false
otherwisepublic String getContentID()
DataHandlerReader
DataHandlerReader.isBinary()
returns true
for 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:
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.
getContentID
in interface DataHandlerReader
null
if no content ID is knownpublic javax.activation.DataHandler getDataHandler() throws javax.xml.stream.XMLStreamException
DataHandlerReader
DataHandler
with the binary content for the current event. The behavior of
this method is only defined for events for which DataHandlerReader.isBinary()
returns
true
. For events of this type the method MUST return a valid
DataHandler
, regardless of the return value of DataHandlerReader.isDeferred()
. If
DataHandlerReader.isDeferred()
returns true
, then the consumer may use this method to
force the implementation to load the binary content immediately.getDataHandler
in interface DataHandlerReader
javax.xml.stream.XMLStreamException
- if an error occurs while loading the DataHandler
public DataHandlerProvider getDataHandlerProvider()
DataHandlerReader
DataHandlerProvider
instance for deferred loading of the binary content for the
current event. The behavior of this method is defined if and only if DataHandlerReader.isDeferred()
returns true
for 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.getDataHandlerProvider
in interface DataHandlerReader
DataHandlerProvider
instance the consumer can use to load the binary
content at a later timeCopyright © 2004-2013 The Apache Software Foundation. All Rights Reserved.