001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common Development
008: * and Distribution License("CDDL") (collectively, the "License"). You
009: * may not use this file except in compliance with the License. You can obtain
010: * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
011: * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
012: * language governing permissions and limitations under the License.
013: *
014: * When distributing the software, include this License Header Notice in each
015: * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
016: * Sun designates this particular file as subject to the "Classpath" exception
017: * as provided by Sun in the GPL Version 2 section of the License file that
018: * accompanied this code. If applicable, add the following below the License
019: * Header, with the fields enclosed by brackets [] replaced by your own
020: * identifying information: "Portions Copyrighted [year]
021: * [name of copyright owner]"
022: *
023: * Contributor(s):
024: *
025: * If you wish your version of this file to be governed by only the CDDL or
026: * only the GPL Version 2, indicate your decision by adding "[Contributor]
027: * elects to include this software in this distribution under the [CDDL or GPL
028: * Version 2] license." If you don't indicate a single choice of license, a
029: * recipient has the option to distribute your version of this file under
030: * either the CDDL, the GPL Version 2 or to extend the choice of license to
031: * its licensees as provided above. However, if you add GPL Version 2 code
032: * and therefore, elected the GPL Version 2 license, then the option applies
033: * only if the new code is made subject to such option by the copyright
034: * holder.
035: */
036:
037: package com.sun.xml.ws.util.xml;
038:
039: import com.sun.xml.ws.api.streaming.XMLStreamWriterFactory;
040: import com.sun.xml.ws.api.streaming.XMLStreamWriterFactory.RecycleAware;
041:
042: import javax.xml.namespace.NamespaceContext;
043: import javax.xml.stream.XMLStreamException;
044: import javax.xml.stream.XMLStreamWriter;
045:
046: /**
047: * {@link XMLStreamWriter} that delegates to another {@link XMLStreamWriter}.
048: *
049: * <p>
050: * This class isn't very useful by itself, but works as a base class
051: * for {@link XMLStreamWriter} filtering.
052: *
053: * @author Kohsuke Kawaguchi
054: */
055: public class XMLStreamWriterFilter implements XMLStreamWriter,
056: RecycleAware {
057: protected XMLStreamWriter writer;
058:
059: public XMLStreamWriterFilter(XMLStreamWriter writer) {
060: this .writer = writer;
061: }
062:
063: public void close() throws XMLStreamException {
064: writer.close();
065: }
066:
067: public void flush() throws XMLStreamException {
068: writer.flush();
069: }
070:
071: public void writeEndDocument() throws XMLStreamException {
072: writer.writeEndDocument();
073: }
074:
075: public void writeEndElement() throws XMLStreamException {
076: writer.writeEndElement();
077: }
078:
079: public void writeStartDocument() throws XMLStreamException {
080: writer.writeStartDocument();
081: }
082:
083: public void writeCharacters(char[] text, int start, int len)
084: throws XMLStreamException {
085: writer.writeCharacters(text, start, len);
086: }
087:
088: public void setDefaultNamespace(String uri)
089: throws XMLStreamException {
090: writer.setDefaultNamespace(uri);
091: }
092:
093: public void writeCData(String data) throws XMLStreamException {
094: writer.writeCData(data);
095: }
096:
097: public void writeCharacters(String text) throws XMLStreamException {
098: writer.writeCharacters(text);
099: }
100:
101: public void writeComment(String data) throws XMLStreamException {
102: writer.writeComment(data);
103: }
104:
105: public void writeDTD(String dtd) throws XMLStreamException {
106: writer.writeDTD(dtd);
107: }
108:
109: public void writeDefaultNamespace(String namespaceURI)
110: throws XMLStreamException {
111: writer.writeDefaultNamespace(namespaceURI);
112: }
113:
114: public void writeEmptyElement(String localName)
115: throws XMLStreamException {
116: writer.writeEmptyElement(localName);
117: }
118:
119: public void writeEntityRef(String name) throws XMLStreamException {
120: writer.writeEntityRef(name);
121: }
122:
123: public void writeProcessingInstruction(String target)
124: throws XMLStreamException {
125: writer.writeProcessingInstruction(target);
126: }
127:
128: public void writeStartDocument(String version)
129: throws XMLStreamException {
130: writer.writeStartDocument(version);
131: }
132:
133: public void writeStartElement(String localName)
134: throws XMLStreamException {
135: writer.writeStartElement(localName);
136: }
137:
138: public NamespaceContext getNamespaceContext() {
139: return writer.getNamespaceContext();
140: }
141:
142: public void setNamespaceContext(NamespaceContext context)
143: throws XMLStreamException {
144: writer.setNamespaceContext(context);
145: }
146:
147: public Object getProperty(String name)
148: throws IllegalArgumentException {
149: return writer.getProperty(name);
150: }
151:
152: public String getPrefix(String uri) throws XMLStreamException {
153: return writer.getPrefix(uri);
154: }
155:
156: public void setPrefix(String prefix, String uri)
157: throws XMLStreamException {
158: writer.setPrefix(prefix, uri);
159: }
160:
161: public void writeAttribute(String localName, String value)
162: throws XMLStreamException {
163: writer.writeAttribute(localName, value);
164: }
165:
166: public void writeEmptyElement(String namespaceURI, String localName)
167: throws XMLStreamException {
168: writer.writeEmptyElement(namespaceURI, localName);
169: }
170:
171: public void writeNamespace(String prefix, String namespaceURI)
172: throws XMLStreamException {
173: writer.writeNamespace(prefix, namespaceURI);
174: }
175:
176: public void writeProcessingInstruction(String target, String data)
177: throws XMLStreamException {
178: writer.writeProcessingInstruction(target, data);
179: }
180:
181: public void writeStartDocument(String encoding, String version)
182: throws XMLStreamException {
183: writer.writeStartDocument(encoding, version);
184: }
185:
186: public void writeStartElement(String namespaceURI, String localName)
187: throws XMLStreamException {
188: writer.writeStartElement(namespaceURI, localName);
189: }
190:
191: public void writeAttribute(String namespaceURI, String localName,
192: String value) throws XMLStreamException {
193: writer.writeAttribute(namespaceURI, localName, value);
194: }
195:
196: public void writeEmptyElement(String prefix, String localName,
197: String namespaceURI) throws XMLStreamException {
198: writer.writeEmptyElement(prefix, localName, namespaceURI);
199: }
200:
201: public void writeStartElement(String prefix, String localName,
202: String namespaceURI) throws XMLStreamException {
203: writer.writeStartElement(prefix, localName, namespaceURI);
204: }
205:
206: public void writeAttribute(String prefix, String namespaceURI,
207: String localName, String value) throws XMLStreamException {
208: writer.writeAttribute(prefix, namespaceURI, localName, value);
209: }
210:
211: public void onRecycled() {
212: XMLStreamWriterFactory.recycle(writer);
213: writer = null;
214: }
215: }
|