Package org.apache.axiom.om.impl
Class MTOMXMLStreamWriter
java.lang.Object
org.apache.axiom.om.impl.MTOMXMLStreamWriter
- All Implemented Interfaces:
XMLStreamWriter
MTOMXMLStreamWriter is an XML + Attachments stream writer.
For the moment this assumes that transport takes the decision of whether to optimize or not by
looking at whether the MTOM optimize is enabled invalid input: '&' also looking at the OM tree whether it has any
optimizable content.
-
Constructor Summary
ConstructorsConstructorDescriptionMTOMXMLStreamWriter(OutputStream outStream, OMOutputFormat format) Creates a new MTOMXMLStreamWriter with specified encoding.MTOMXMLStreamWriter(XMLStreamWriter xmlWriter) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidflush()Flush is overridden to trigger the attachment serializationReturns the character set encoding scheme.Get the output format used by this writer.Get the underlyingOutputStreamfor this writer, if available.getProperty(String string) booleanbooleanDeprecated.booleanisOptimizedThreshold(OMText node) Deprecated.Serialization code should useXMLStreamWriterUtils.writeDataHandler(XMLStreamWriter, DataHandler, String, boolean)orXMLStreamWriterUtils.writeDataHandler(XMLStreamWriter, org.apache.axiom.ext.stax.datahandler.DataHandlerProvider, String, boolean)to submit any binary content and let this writer decide whether the content should be written as base64 encoded character data or using xop:Include.voidsetCharSetEncoding(String charSetEncoding) voidsetDefaultNamespace(String string) voidsetDoOptimize(boolean b) voidsetFilter(XMLStreamWriterFilter filter) voidsetIgnoreXMLDeclaration(boolean ignoreXMLDeclaration) voidsetNamespaceContext(NamespaceContext namespaceContext) voidsetOutputFormat(OMOutputFormat format) voidvoidsetSoap11(boolean b) voidsetXmlStreamWriter(XMLStreamWriter xmlWriter) voidsetXmlVersion(String xmlVersion) voidwriteAttribute(String string, String string1) voidwriteAttribute(String string, String string1, String string2) voidwriteAttribute(String string, String string1, String string2, String string3) voidwriteCData(String string) voidwriteCharacters(char[] chars, int i, int i1) voidwriteCharacters(String string) voidwriteComment(String string) voidwriteDefaultNamespace(String string) voidvoidwriteEmptyElement(String string) voidwriteEmptyElement(String string, String string1) voidwriteEmptyElement(String string, String string1, String string2) voidvoidvoidwriteEntityRef(String string) voidwriteNamespace(String string, String string1) voidwriteOptimized(OMText node) Deprecated.Serialization code should useXMLStreamWriterUtils.writeDataHandler(XMLStreamWriter, DataHandler, String, boolean)orXMLStreamWriterUtils.writeDataHandler(XMLStreamWriter, org.apache.axiom.ext.stax.datahandler.DataHandlerProvider, String, boolean)to submit any binary content and let this writer decide whether the content should be written as base64 encoded character data or using xop:Include.voidwriteProcessingInstruction(String string) voidwriteProcessingInstruction(String string, String string1) voidvoidwriteStartDocument(String string) voidwriteStartDocument(String string, String string1) voidwriteStartElement(String string) voidwriteStartElement(String string, String string1) voidwriteStartElement(String string, String string1, String string2)
-
Constructor Details
-
MTOMXMLStreamWriter
-
MTOMXMLStreamWriter
public MTOMXMLStreamWriter(OutputStream outStream, OMOutputFormat format) throws XMLStreamException, FactoryConfigurationError Creates a new MTOMXMLStreamWriter with specified encoding.- Parameters:
outStream-format-- Throws:
XMLStreamExceptionFactoryConfigurationError- See Also:
-
-
Method Details
-
writeStartElement
- Specified by:
writeStartElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeStartElement
- Specified by:
writeStartElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeStartElement
public void writeStartElement(String string, String string1, String string2) throws XMLStreamException - Specified by:
writeStartElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeEmptyElement
- Specified by:
writeEmptyElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeEmptyElement
public void writeEmptyElement(String string, String string1, String string2) throws XMLStreamException - Specified by:
writeEmptyElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeEmptyElement
- Specified by:
writeEmptyElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeEndElement
- Specified by:
writeEndElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeEndDocument
- Specified by:
writeEndDocumentin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
close
- Specified by:
closein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
flush
Flush is overridden to trigger the attachment serialization- Specified by:
flushin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeAttribute
- Specified by:
writeAttributein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeAttribute
public void writeAttribute(String string, String string1, String string2, String string3) throws XMLStreamException - Specified by:
writeAttributein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeAttribute
- Specified by:
writeAttributein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeNamespace
- Specified by:
writeNamespacein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeDefaultNamespace
- Specified by:
writeDefaultNamespacein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeComment
- Specified by:
writeCommentin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeProcessingInstruction
- Specified by:
writeProcessingInstructionin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeProcessingInstruction
- Specified by:
writeProcessingInstructionin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeCData
- Specified by:
writeCDatain interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeDTD
- Specified by:
writeDTDin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeEntityRef
- Specified by:
writeEntityRefin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeStartDocument
- Specified by:
writeStartDocumentin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeStartDocument
- Specified by:
writeStartDocumentin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeStartDocument
- Specified by:
writeStartDocumentin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeCharacters
- Specified by:
writeCharactersin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeCharacters
- Specified by:
writeCharactersin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
getPrefix
- Specified by:
getPrefixin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
setPrefix
- Specified by:
setPrefixin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
setDefaultNamespace
- Specified by:
setDefaultNamespacein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
setNamespaceContext
- Specified by:
setNamespaceContextin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
getNamespaceContext
- Specified by:
getNamespaceContextin interfaceXMLStreamWriter
-
getProperty
- Specified by:
getPropertyin interfaceXMLStreamWriter- Throws:
IllegalArgumentException
-
isOptimized
public boolean isOptimized()Deprecated.Serialization code should useXMLStreamWriterUtils.writeDataHandler(XMLStreamWriter, DataHandler, String, boolean)orXMLStreamWriterUtils.writeDataHandler(XMLStreamWriter, org.apache.axiom.ext.stax.datahandler.DataHandlerProvider, String, boolean)to submit any binary content and let this writer decide whether the content should be written as base64 encoded character data or using xop:Include. This makes optimization entirely transparent for the caller and there should be no need to check if the writer is producing MTOM. -
getContentType
-
writeOptimized
Deprecated.Serialization code should useXMLStreamWriterUtils.writeDataHandler(XMLStreamWriter, DataHandler, String, boolean)orXMLStreamWriterUtils.writeDataHandler(XMLStreamWriter, org.apache.axiom.ext.stax.datahandler.DataHandlerProvider, String, boolean)to submit any binary content and let this writer decide whether the content should be written as base64 encoded character data or using xop:Include. -
isOptimizedThreshold
Deprecated.Serialization code should useXMLStreamWriterUtils.writeDataHandler(XMLStreamWriter, DataHandler, String, boolean)orXMLStreamWriterUtils.writeDataHandler(XMLStreamWriter, org.apache.axiom.ext.stax.datahandler.DataHandlerProvider, String, boolean)to submit any binary content and let this writer decide whether the content should be written as base64 encoded character data or using xop:Include. Since the writer applies the settings defined inOMOutputFormat(including MTOM thresholds), there is not need for this method anymore. -
setXmlStreamWriter
-
getXmlStreamWriter
-
getMimeBoundary
-
getRootContentId
-
getNextContentId
-
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.
-
setCharSetEncoding
-
getXmlVersion
-
setXmlVersion
-
setSoap11
public void setSoap11(boolean b) -
isIgnoreXMLDeclaration
public boolean isIgnoreXMLDeclaration() -
setIgnoreXMLDeclaration
public void setIgnoreXMLDeclaration(boolean ignoreXMLDeclaration) -
setDoOptimize
public void setDoOptimize(boolean b) -
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
-
setOutputFormat
-
getOutputStream
Get the underlyingOutputStreamfor 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
nullif the stream is not accessible - Throws:
XMLStreamException
-
setFilter
-
removeFilter
-
XMLStreamWriterUtils.writeDataHandler(XMLStreamWriter, DataHandler, String, boolean)orXMLStreamWriterUtils.writeDataHandler(XMLStreamWriter, org.apache.axiom.ext.stax.datahandler.DataHandlerProvider, String, boolean)to submit any binary content and let this writer decide whether the content should be written as base64 encoded character data or using xop:Include.