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.
| Method from org.apache.axiom.om.impl.MTOMXMLStreamWriter Detail: |
public void close() throws XMLStreamException {
if (isDebugEnabled) {
log.debug("close");
}
xmlWriter.close();
}
|
public void flush() throws XMLStreamException {
if (isDebugEnabled) {
log.debug("Calling MTOMXMLStreamWriter.flush");
}
xmlWriter.flush();
String SOAPContentType;
// flush() triggers the optimized attachment writing.
// If the optimized attachments are specified, and the xml
// document is completed, then write out the attachments.
if (format.isOptimized() && !isComplete & (isEndDocument || depth == 0)) {
if (isDebugEnabled) {
log.debug("The XML writing is completed. Now the attachments are written");
}
isComplete = true;
if (format.isSOAP11()) {
SOAPContentType = SOAP11Constants.SOAP_11_CONTENT_TYPE;
} else {
SOAPContentType = SOAP12Constants.SOAP_12_CONTENT_TYPE;
}
try {
MIMEOutputUtils.complete(outStream,
bufferedXML.toByteArray(),
binaryNodeList,
format.getMimeBoundary(),
format.getRootContentId(),
format.getCharSetEncoding(),
SOAPContentType,
format);
bufferedXML.close();
bufferedXML = null;
} catch (UnsupportedEncodingException e) {
throw new OMException(e);
} catch (IOException e) {
throw new OMException(e);
}
}
}
Flush is overridden to trigger the attachment serialization |
public String getCharSetEncoding() {
return format.getCharSetEncoding();
}
Returns the character set encoding scheme. If the value of the charSetEncoding is not set
then the default will be returned. |
public String getContentType() {
return format.getContentType();
}
|
public String getMimeBoundary() {
return format.getMimeBoundary();
}
|
public NamespaceContext getNamespaceContext() {
return xmlWriter.getNamespaceContext();
}
|
public String getNextContentId() {
return format.getNextContentId();
}
|
public OMOutputFormat getOutputFormat() {
return format;
}
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. |
public OutputStream getOutputStream() throws XMLStreamException {
OutputStream os = null;
if (bufferedXML != null) {
os = bufferedXML;
} else {
os = outStream;
}
if (isDebugEnabled) {
if (os == null) {
log.debug("Direct access to the output stream is not available.");
} else if (bufferedXML != null) {
log.debug("Returning access to the buffered xml stream: " + bufferedXML);
} else {
log.debug("Returning access to the original output stream: " + os);
}
}
if (os != null) {
// Flush the state of the writer..Many times the
// write defers the writing of tag characters ( >)
// until the next write. Flush out this character
this.writeCharacters("");
this.flush();
}
return os;
}
If this XMLStreamWriter is connected to an OutputStream
then the OutputStream is returned. This allows a node
(perhaps an OMSourcedElement) to write its content
directly to the OutputStream. |
public String getPrefix(String string) throws XMLStreamException {
return xmlWriter.getPrefix(string);
}
|
public Object getProperty(String string) throws IllegalArgumentException {
return xmlWriter.getProperty(string);
}
|
public String getRootContentId() {
return format.getRootContentId();
}
|
public XMLStreamWriter getXmlStreamWriter() {
return xmlWriter;
}
|
public String getXmlVersion() {
return format.getXmlVersion();
}
|
public boolean isIgnoreXMLDeclaration() {
return format.isIgnoreXMLDeclaration();
}
|
public boolean isOptimized() {
return format.isOptimized();
}
|
public boolean isOptimizedThreshold(OMText node) {
if(isDebugEnabled){
log.debug("Start MTOMXMLStreamWriter.isOptimizedThreshold()");
}
DataHandler dh = (DataHandler)node.getDataHandler();
int optimized = UNSUPPORTED;
if(dh!=null){
if(isDebugEnabled){
log.debug("DataHandler fetched, starting optimized Threshold processing");
}
optimized= BufferUtils.doesDataHandlerExceedLimit(dh, format.getOptimizedThreshold());
}
if(optimized == UNSUPPORTED || optimized == EXCEED_LIMIT){
if(log.isDebugEnabled()){
log.debug("node should be added to binart NodeList for optimization");
}
return true;
}
return false;
}
|
public void setCharSetEncoding(String charSetEncoding) {
format.setCharSetEncoding(charSetEncoding);
}
|
public void setDefaultNamespace(String string) throws XMLStreamException {
xmlWriter.setDefaultNamespace(string);
}
|
public void setDoOptimize(boolean b) {
format.setDoOptimize(b);
}
|
public void setIgnoreXMLDeclaration(boolean ignoreXMLDeclaration) {
format.setIgnoreXMLDeclaration(ignoreXMLDeclaration);
}
|
public void setNamespaceContext(NamespaceContext namespaceContext) throws XMLStreamException {
xmlWriter.setNamespaceContext(namespaceContext);
}
|
public void setOutputFormat(OMOutputFormat format) {
this.format = format;
}
|
public void setPrefix(String string,
String string1) throws XMLStreamException {
xmlWriter.setPrefix(string, string1);
}
|
public void setSoap11(boolean b) {
format.setSOAP11(b);
}
|
public void setXmlStreamWriter(XMLStreamWriter xmlWriter) {
this.xmlWriter = xmlWriter;
}
|
public void setXmlVersion(String xmlVersion) {
format.setXmlVersion(xmlVersion);
}
|
public void writeAttribute(String string,
String string1) throws XMLStreamException {
xmlWriter.writeAttribute(string, string1);
}
|
public void writeAttribute(String string,
String string1,
String string2) throws XMLStreamException {
xmlWriter.writeAttribute(string, string1, string2);
}
|
public void writeAttribute(String string,
String string1,
String string2,
String string3) throws XMLStreamException {
xmlWriter.writeAttribute(string, string1, string2, string3);
}
|
public void writeCData(String string) throws XMLStreamException {
xmlWriter.writeCData(string);
}
|
public void writeCharacters(String string) throws XMLStreamException {
xmlWriter.writeCharacters(string);
}
|
public void writeCharacters(char[] chars,
int i,
int i1) throws XMLStreamException {
xmlWriter.writeCharacters(chars, i, i1);
}
|
public void writeComment(String string) throws XMLStreamException {
xmlWriter.writeComment(string);
}
|
public void writeDTD(String string) throws XMLStreamException {
xmlWriter.writeDTD(string);
}
|
public void writeDefaultNamespace(String string) throws XMLStreamException {
xmlWriter.writeDefaultNamespace(string);
}
|
public void writeEmptyElement(String string) throws XMLStreamException {
xmlWriter.writeEmptyElement(string);
}
|
public void writeEmptyElement(String string,
String string1) throws XMLStreamException {
xmlWriter.writeEmptyElement(string, string1);
}
|
public void writeEmptyElement(String string,
String string1,
String string2) throws XMLStreamException {
xmlWriter.writeEmptyElement(string, string1, string2);
}
|
public void writeEndDocument() throws XMLStreamException {
if (isDebugEnabled) {
log.debug("writeEndDocument");
}
xmlWriter.writeEndDocument();
isEndDocument = true;
}
|
public void writeEndElement() throws XMLStreamException {
xmlWriter.writeEndElement();
depth--;
}
|
public void writeEntityRef(String string) throws XMLStreamException {
xmlWriter.writeEntityRef(string);
}
|
public void writeNamespace(String string,
String string1) throws XMLStreamException {
xmlWriter.writeNamespace(string, string1);
}
|
public void writeOptimized(OMText node) {
if(isDebugEnabled){
log.debug("Start MTOMXMLStreamWriter.writeOptimized()");
}
binaryNodeList.add(node);
if(isDebugEnabled){
log.debug("Exit MTOMXMLStreamWriter.writeOptimized()");
}
}
|
public void writeProcessingInstruction(String string) throws XMLStreamException {
xmlWriter.writeProcessingInstruction(string);
}
|
public void writeProcessingInstruction(String string,
String string1) throws XMLStreamException {
xmlWriter.writeProcessingInstruction(string, string1);
}
|
public void writeStartDocument() throws XMLStreamException {
xmlWriter.writeStartDocument();
}
|
public void writeStartDocument(String string) throws XMLStreamException {
xmlWriter.writeStartDocument(string);
}
|
public void writeStartDocument(String string,
String string1) throws XMLStreamException {
xmlWriter.writeStartDocument(string, string1);
}
|
public void writeStartElement(String string) throws XMLStreamException {
xmlWriter.writeStartElement(string);
depth++;
}
|
public void writeStartElement(String string,
String string1) throws XMLStreamException {
xmlWriter.writeStartElement(string, string1);
depth++;
}
|
public void writeStartElement(String string,
String string1,
String string2) throws XMLStreamException {
xmlWriter.writeStartElement(string, string1, string2);
depth++;
}
|