001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: *
023: * Free Software Foundation, Inc.
024: * 59 Temple Place, Suite 330
025: * Boston, MA 02111-1307 USA
026: *
027: * @author Emil Ong
028: */
029:
030: package com.caucho.xml.stream;
031:
032: import com.caucho.vfs.WriteStream;
033:
034: import javax.xml.XMLConstants;
035: import javax.xml.namespace.NamespaceContext;
036: import javax.xml.namespace.QName;
037: import javax.xml.stream.XMLOutputFactory;
038: import javax.xml.stream.XMLStreamException;
039: import javax.xml.stream.XMLStreamWriter;
040: import java.io.IOException;
041: import java.util.ArrayList;
042: import java.util.logging.Logger;
043:
044: public class XMLStreamWriterRepairingWrapper implements XMLStreamWriter {
045: private XMLStreamWriter _out;
046:
047: public XMLStreamWriterRepairingWrapper(XMLStreamWriter out) {
048: _out = out;
049: }
050:
051: public void close() throws XMLStreamException {
052: _out.close();
053: }
054:
055: public void flush() throws XMLStreamException {
056: _out.flush();
057: }
058:
059: public NamespaceContext getNamespaceContext() {
060: return _out.getNamespaceContext();
061: }
062:
063: public String getPrefix(String uri) throws XMLStreamException {
064: return _out.getPrefix(uri);
065: }
066:
067: public Object getProperty(String name) {
068: if (XMLOutputFactory.IS_REPAIRING_NAMESPACES.equals(name))
069: return true;
070:
071: return _out.getProperty(name);
072: }
073:
074: public void setDefaultNamespace(String uri)
075: throws XMLStreamException {
076: _out.setDefaultNamespace(uri);
077: }
078:
079: public void setNamespaceContext(NamespaceContext context)
080: throws XMLStreamException {
081: _out.setNamespaceContext(context);
082: }
083:
084: public void setPrefix(String prefix, String uri)
085: throws XMLStreamException {
086: _out.setPrefix(prefix, uri);
087: }
088:
089: public void writeAttribute(String localName, String value)
090: throws XMLStreamException {
091: _out.writeAttribute(localName, value);
092: }
093:
094: public void writeAttribute(String namespaceURI, String localName,
095: String value) throws XMLStreamException {
096: StaxUtil.repairNamespace(_out, namespaceURI);
097:
098: _out.writeAttribute(namespaceURI, localName, value);
099: }
100:
101: public void writeAttribute(String prefix, String namespaceURI,
102: String localName, String value) throws XMLStreamException {
103: StaxUtil.repairNamespace(_out, prefix, namespaceURI);
104:
105: _out.writeAttribute(prefix, namespaceURI, localName, value);
106: }
107:
108: public void writeCData(String data) throws XMLStreamException {
109: _out.writeCData(data);
110: }
111:
112: public void writeCharacters(char[] text, int start, int len)
113: throws XMLStreamException {
114: _out.writeCharacters(text, start, len);
115: }
116:
117: public void writeCharacters(String text) throws XMLStreamException {
118: _out.writeCharacters(text);
119: }
120:
121: public void writeComment(String data) throws XMLStreamException {
122: _out.writeComment(data);
123: }
124:
125: public void writeDefaultNamespace(String namespaceURI)
126: throws XMLStreamException {
127: _out.writeDefaultNamespace(namespaceURI);
128: }
129:
130: public void writeDTD(String dtd) throws XMLStreamException {
131: _out.writeDTD(dtd);
132: }
133:
134: public void writeEmptyElement(String localName)
135: throws XMLStreamException {
136: _out.writeEmptyElement(localName);
137: }
138:
139: public void writeEmptyElement(String namespaceURI, String localName)
140: throws XMLStreamException {
141: StaxUtil.repairNamespace(_out, namespaceURI);
142:
143: _out.writeEmptyElement(namespaceURI, localName);
144: }
145:
146: public void writeEmptyElement(String prefix, String localName,
147: String namespaceURI) throws XMLStreamException {
148: StaxUtil.repairNamespace(_out, prefix, namespaceURI);
149:
150: _out.writeEmptyElement(prefix, localName, namespaceURI);
151: }
152:
153: public void writeEndDocument() throws XMLStreamException {
154: _out.writeEndDocument();
155: }
156:
157: public void writeEndElement() throws XMLStreamException {
158: _out.writeEndElement();
159: }
160:
161: public void writeEntityRef(String name) throws XMLStreamException {
162: _out.writeEntityRef(name);
163: }
164:
165: public void writeNamespace(String prefix, String namespaceURI)
166: throws XMLStreamException {
167: _out.writeNamespace(prefix, namespaceURI);
168: }
169:
170: public void writeProcessingInstruction(String target)
171: throws XMLStreamException {
172: _out.writeProcessingInstruction(target);
173: }
174:
175: public void writeProcessingInstruction(String target, String data)
176: throws XMLStreamException {
177: _out.writeProcessingInstruction(target, data);
178: }
179:
180: public void writeStartDocument() throws XMLStreamException {
181: _out.writeStartDocument();
182: }
183:
184: public void writeStartDocument(String version)
185: throws XMLStreamException {
186: _out.writeStartDocument(version);
187: }
188:
189: public void writeStartDocument(String encoding, String version)
190: throws XMLStreamException {
191: _out.writeStartDocument(encoding, version);
192: }
193:
194: public void writeStartElement(String localName)
195: throws XMLStreamException {
196: _out.writeStartElement(localName);
197: }
198:
199: public void writeStartElement(String namespaceURI, String localName)
200: throws XMLStreamException {
201: StaxUtil.repairNamespace(_out, namespaceURI);
202:
203: _out.writeStartElement(namespaceURI, localName);
204: }
205:
206: public void writeStartElement(String prefix, String localName,
207: String namespaceURI) throws XMLStreamException {
208: StaxUtil.repairNamespace(_out, prefix, namespaceURI);
209:
210: _out.writeStartElement(prefix, localName, namespaceURI);
211: }
212: }
|