Class MTOMXMLStreamWriter
- All Implemented Interfaces:
XMLStreamWriter
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract String
Returns the character set encoding scheme.abstract OMOutputFormat
Get the output format used by this writer.abstract OutputStream
Get the underlyingOutputStream
for this writer, if available.abstract boolean
Check if MTOM is enabled.abstract String
prepareBlob
(Blob blob) Prepare aBlob
for serialization without using theBlobWriter
API.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface javax.xml.stream.XMLStreamWriter
close, flush, getNamespaceContext, getPrefix, getProperty, setDefaultNamespace, setNamespaceContext, setPrefix, writeAttribute, writeAttribute, writeAttribute, writeCData, writeCharacters, writeCharacters, writeComment, writeDefaultNamespace, writeDTD, writeEmptyElement, writeEmptyElement, writeEmptyElement, writeEndDocument, writeEndElement, writeEntityRef, writeNamespace, writeProcessingInstruction, writeProcessingInstruction, writeStartDocument, writeStartDocument, writeStartDocument, writeStartElement, writeStartElement, writeStartElement
-
Constructor Details
-
MTOMXMLStreamWriter
public MTOMXMLStreamWriter()
-
-
Method Details
-
isOptimized
public abstract boolean isOptimized()Check if MTOM is enabled.Note that serialization code should use
XMLStreamWriterUtils.writeBlob(XMLStreamWriter, Blob, String, boolean)
orXMLStreamWriterUtils.writeBlob(XMLStreamWriter, BlobProvider, String, boolean)
to submit any binary content and let this writer decide whether the content should be written as base64 encoded character data or usingxop:Include
. This makes optimization entirely transparent for the caller and there should be no need to check if the writer is producing MTOM. However, in some cases this is not possible, such as when integrating with 3rd party libraries. The serialization code should then useprepareBlob(Blob)
so that it can writexop:Include
elements directly to the stream. In that case, the code may use theisOptimized()
method check if MTOM is enabled at all.- Returns:
true
if MTOM is enabled,false
otherwise
-
prepareBlob
Prepare aBlob
for serialization without using theBlobWriter
API. The method first determines whether the binary data represented by theBlob
should be optimized or inlined. If the data should not be optimized, then the method returnsnull
and the caller is expected to useXMLStreamWriter.writeCharacters(String)
orXMLStreamWriter.writeCharacters(char[], int, int)
to write the base64 encoded data to the stream. If the data should be optimized, then the method returns a content ID and the caller is expected to generate anxop:Include
element referring to that content ID.This method should only be used to integrate Axiom with third party libraries that support XOP. In all other cases,
XMLStreamWriterUtils.writeBlob(XMLStreamWriter, Blob, String, boolean)
orXMLStreamWriterUtils.writeBlob(XMLStreamWriter, BlobProvider, String, boolean)
should be used to write base64Binary values and the application code should never generatexop:Include
elements itself.- Parameters:
blob
- theBlob
that the caller intends to write to the stream- Returns:
- the content ID that the caller must use in the
xop:Include
element ornull
if the base64 encoded data should not be optimized
-
getCharSetEncoding
Returns the character set encoding scheme. If the value of the charSetEncoding is not set then the default will be returned.- Returns:
- Returns encoding.
-
getOutputFormat
Get the output format used by this writer.The caller should use the returned instance in a read-only way, i.e. he should not modify the settings of the output format. Any attempt to do so will lead to unpredictable results.
- Returns:
- the output format used by this writer
-
getOutputStream
Get the underlyingOutputStream
for this writer, if available. This method allows a node (perhaps anOMSourcedElement
) to write its content directly to the byte stream.WARNING: This method should be used with extreme care. The caller must be prepared to handle the following issues:
- The caller must use the right charset encoding when writing to the stream.
- The caller should avoid writing byte order marks to the stream.
- The caller must be aware of the fact that a default namespace might have been set in the context where the byte stream is requested. If the XML data written to the stream contains unqualified elements, then the caller must make sure that the default namespace is redeclared as appropriate.
- Returns:
- the underlying byte stream, or
null
if the stream is not accessible - Throws:
XMLStreamException
-