001: /*
002: * Copyright 2004,2005 The Apache Software Foundation.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.apache.axis2.databinding.utils.writer;
017:
018: import org.apache.axiom.om.impl.llom.OMTextImpl;
019: import org.apache.axiom.om.OMAbstractFactory;
020:
021: import javax.xml.stream.XMLStreamException;
022: import javax.xml.stream.XMLStreamWriter;
023: import javax.xml.namespace.NamespaceContext;
024: import javax.activation.DataHandler;
025:
026: /**
027: * this class wrapps the existing xmlStreamWriter and implements the new method
028: * writeDataHandler
029: */
030: public class MTOMAwareXMLSerializer implements MTOMAwareXMLStreamWriter {
031:
032: private XMLStreamWriter xmlStreamWriter;
033:
034: public MTOMAwareXMLSerializer(XMLStreamWriter xmlStreamWriter) {
035: this .xmlStreamWriter = xmlStreamWriter;
036: }
037:
038: public void writeStartElement(String string)
039: throws XMLStreamException {
040: this .xmlStreamWriter.writeStartElement(string);
041: }
042:
043: public void writeStartElement(String string, String string1)
044: throws XMLStreamException {
045: this .xmlStreamWriter.writeStartElement(string, string1);
046: }
047:
048: public void writeStartElement(String string, String string1,
049: String string2) throws XMLStreamException {
050: this .xmlStreamWriter
051: .writeStartElement(string, string1, string2);
052: }
053:
054: public void writeEmptyElement(String string, String string1)
055: throws XMLStreamException {
056: this .xmlStreamWriter.writeEmptyElement(string, string1);
057: }
058:
059: public void writeEmptyElement(String string, String string1,
060: String string2) throws XMLStreamException {
061: this .xmlStreamWriter
062: .writeEmptyElement(string, string1, string2);
063: }
064:
065: public void writeEmptyElement(String string)
066: throws XMLStreamException {
067: this .xmlStreamWriter.writeEmptyElement(string);
068: }
069:
070: public void writeEndElement() throws XMLStreamException {
071: this .xmlStreamWriter.writeEndElement();
072: }
073:
074: public void writeEndDocument() throws XMLStreamException {
075: this .xmlStreamWriter.writeEndDocument();
076: }
077:
078: public void close() throws XMLStreamException {
079: this .xmlStreamWriter.close();
080: }
081:
082: public void flush() throws XMLStreamException {
083: this .xmlStreamWriter.flush();
084: }
085:
086: public void writeAttribute(String string, String string1)
087: throws XMLStreamException {
088: this .xmlStreamWriter.writeAttribute(string, string1);
089: }
090:
091: public void writeAttribute(String string, String string1,
092: String string2, String string3) throws XMLStreamException {
093: this .xmlStreamWriter.writeAttribute(string, string1, string2,
094: string3);
095: }
096:
097: public void writeAttribute(String string, String string1,
098: String string2) throws XMLStreamException {
099: this .xmlStreamWriter.writeAttribute(string, string1, string2);
100: }
101:
102: public void writeNamespace(String string, String string1)
103: throws XMLStreamException {
104: this .xmlStreamWriter.writeNamespace(string, string1);
105: }
106:
107: public void writeDefaultNamespace(String string)
108: throws XMLStreamException {
109: this .xmlStreamWriter.writeDefaultNamespace(string);
110: }
111:
112: public void writeComment(String string) throws XMLStreamException {
113: this .xmlStreamWriter.writeComment(string);
114: }
115:
116: public void writeProcessingInstruction(String string)
117: throws XMLStreamException {
118: this .xmlStreamWriter.writeProcessingInstruction(string);
119: }
120:
121: public void writeProcessingInstruction(String string, String string1)
122: throws XMLStreamException {
123: this .xmlStreamWriter
124: .writeProcessingInstruction(string, string1);
125: }
126:
127: public void writeCData(String string) throws XMLStreamException {
128: this .xmlStreamWriter.writeCData(string);
129: }
130:
131: public void writeDTD(String string) throws XMLStreamException {
132: this .xmlStreamWriter.writeDTD(string);
133: }
134:
135: public void writeEntityRef(String string) throws XMLStreamException {
136: this .xmlStreamWriter.writeEntityRef(string);
137: }
138:
139: public void writeStartDocument() throws XMLStreamException {
140: this .xmlStreamWriter.writeStartDocument();
141: }
142:
143: public void writeStartDocument(String string)
144: throws XMLStreamException {
145: this .xmlStreamWriter.writeStartDocument(string);
146: }
147:
148: public void writeStartDocument(String string, String string1)
149: throws XMLStreamException {
150: this .xmlStreamWriter.writeStartDocument(string, string1);
151: }
152:
153: public void writeCharacters(String string)
154: throws XMLStreamException {
155: this .xmlStreamWriter.writeCharacters(string);
156: }
157:
158: public void writeCharacters(char[] chars, int i, int i1)
159: throws XMLStreamException {
160: this .xmlStreamWriter.writeCharacters(chars, i, i1);
161: }
162:
163: public String getPrefix(String string) throws XMLStreamException {
164: return this .xmlStreamWriter.getPrefix(string);
165: }
166:
167: public void setPrefix(String string, String string1)
168: throws XMLStreamException {
169: this .xmlStreamWriter.setPrefix(string, string1);
170: }
171:
172: public void setDefaultNamespace(String string)
173: throws XMLStreamException {
174: this .xmlStreamWriter.setDefaultNamespace(string);
175: }
176:
177: public void setNamespaceContext(NamespaceContext namespaceContext)
178: throws XMLStreamException {
179: this .xmlStreamWriter.setNamespaceContext(namespaceContext);
180: }
181:
182: public NamespaceContext getNamespaceContext() {
183: return this .xmlStreamWriter.getNamespaceContext();
184: }
185:
186: public Object getProperty(String string)
187: throws IllegalArgumentException {
188: return this .xmlStreamWriter.getProperty(string);
189: }
190:
191: public void writeDataHandler(DataHandler dataHandler)
192: throws XMLStreamException {
193: OMTextImpl omText = new OMTextImpl(dataHandler,
194: OMAbstractFactory.getOMFactory());
195: omText.internalSerializeAndConsume(this.xmlStreamWriter);
196: }
197: }
|