Package org.apache.axiom.om.impl
Class MTOMXMLStreamWriter
- java.lang.Object
-
- org.apache.axiom.om.impl.MTOMXMLStreamWriter
-
- All Implemented Interfaces:
XMLStreamWriter
public class MTOMXMLStreamWriter extends Object implements 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 & also looking at the OM tree whether it has any optimizable content.
-
-
Constructor Summary
Constructors Constructor Description MTOMXMLStreamWriter(OutputStream outStream, OMOutputFormat format)Creates a new MTOMXMLStreamWriter with specified encoding.MTOMXMLStreamWriter(XMLStreamWriter xmlWriter)
-
Method Summary
-
-
-
Constructor Detail
-
MTOMXMLStreamWriter
public MTOMXMLStreamWriter(XMLStreamWriter xmlWriter)
-
MTOMXMLStreamWriter
public MTOMXMLStreamWriter(OutputStream outStream, OMOutputFormat format) throws XMLStreamException, FactoryConfigurationError
Creates a new MTOMXMLStreamWriter with specified encoding.- Parameters:
outStream-format-- Throws:
XMLStreamExceptionFactoryConfigurationError- See Also:
OMOutputFormat.DEFAULT_CHAR_SET_ENCODING
-
-
Method Detail
-
writeStartElement
public void writeStartElement(String string) throws XMLStreamException
- Specified by:
writeStartElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeStartElement
public void writeStartElement(String string, String string1) throws XMLStreamException
- 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
public void writeEmptyElement(String string, String string1) throws XMLStreamException
- 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
public void writeEmptyElement(String string) throws XMLStreamException
- Specified by:
writeEmptyElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeEndElement
public void writeEndElement() throws XMLStreamException- Specified by:
writeEndElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeEndDocument
public void writeEndDocument() throws XMLStreamException- Specified by:
writeEndDocumentin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
close
public void close() throws XMLStreamException- Specified by:
closein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
flush
public void flush() throws XMLStreamExceptionFlush is overridden to trigger the attachment serialization- Specified by:
flushin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeAttribute
public void writeAttribute(String string, String string1) throws XMLStreamException
- 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
public void writeAttribute(String string, String string1, String string2) throws XMLStreamException
- Specified by:
writeAttributein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeNamespace
public void writeNamespace(String string, String string1) throws XMLStreamException
- Specified by:
writeNamespacein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeDefaultNamespace
public void writeDefaultNamespace(String string) throws XMLStreamException
- Specified by:
writeDefaultNamespacein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeComment
public void writeComment(String string) throws XMLStreamException
- Specified by:
writeCommentin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeProcessingInstruction
public void writeProcessingInstruction(String string) throws XMLStreamException
- Specified by:
writeProcessingInstructionin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeProcessingInstruction
public void writeProcessingInstruction(String string, String string1) throws XMLStreamException
- Specified by:
writeProcessingInstructionin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeCData
public void writeCData(String string) throws XMLStreamException
- Specified by:
writeCDatain interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeDTD
public void writeDTD(String string) throws XMLStreamException
- Specified by:
writeDTDin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeEntityRef
public void writeEntityRef(String string) throws XMLStreamException
- Specified by:
writeEntityRefin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeStartDocument
public void writeStartDocument() throws XMLStreamException- Specified by:
writeStartDocumentin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeStartDocument
public void writeStartDocument(String string) throws XMLStreamException
- Specified by:
writeStartDocumentin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeStartDocument
public void writeStartDocument(String string, String string1) throws XMLStreamException
- Specified by:
writeStartDocumentin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeCharacters
public void writeCharacters(String string) throws XMLStreamException
- Specified by:
writeCharactersin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeCharacters
public void writeCharacters(char[] chars, int i, int i1) throws XMLStreamException- Specified by:
writeCharactersin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
getPrefix
public String getPrefix(String string) throws XMLStreamException
- Specified by:
getPrefixin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
setPrefix
public void setPrefix(String string, String string1) throws XMLStreamException
- Specified by:
setPrefixin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
setDefaultNamespace
public void setDefaultNamespace(String string) throws XMLStreamException
- Specified by:
setDefaultNamespacein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
setNamespaceContext
public void setNamespaceContext(NamespaceContext namespaceContext) throws XMLStreamException
- Specified by:
setNamespaceContextin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
getNamespaceContext
public NamespaceContext getNamespaceContext()
- Specified by:
getNamespaceContextin interfaceXMLStreamWriter
-
getProperty
public Object getProperty(String string) throws IllegalArgumentException
- 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
public String getContentType()
-
writeOptimized
public void writeOptimized(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.
-
isOptimizedThreshold
public boolean isOptimizedThreshold(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. Since the writer applies the settings defined inOMOutputFormat(including MTOM thresholds), there is not need for this method anymore.
-
setXmlStreamWriter
public void setXmlStreamWriter(XMLStreamWriter xmlWriter)
-
getXmlStreamWriter
public XMLStreamWriter getXmlStreamWriter()
-
getMimeBoundary
public String getMimeBoundary()
-
getRootContentId
public String getRootContentId()
-
getNextContentId
public String getNextContentId()
-
getCharSetEncoding
public String 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
public void setCharSetEncoding(String charSetEncoding)
-
getXmlVersion
public String getXmlVersion()
-
setXmlVersion
public void setXmlVersion(String xmlVersion)
-
setSoap11
public void setSoap11(boolean b)
-
isIgnoreXMLDeclaration
public boolean isIgnoreXMLDeclaration()
-
setIgnoreXMLDeclaration
public void setIgnoreXMLDeclaration(boolean ignoreXMLDeclaration)
-
setDoOptimize
public void setDoOptimize(boolean b)
-
getOutputFormat
public OMOutputFormat 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
public void setOutputFormat(OMOutputFormat format)
-
getOutputStream
public OutputStream getOutputStream() throws XMLStreamException
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
public void setFilter(XMLStreamWriterFilter filter)
-
removeFilter
public XMLStreamWriterFilter removeFilter()
-
-