Thu, 31 Aug 2017 15:18:52 +0800
merge
1 /*
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
26 package com.sun.xml.internal.ws.util.xml;
28 import com.sun.xml.internal.ws.api.streaming.XMLStreamWriterFactory;
29 import com.sun.xml.internal.ws.api.streaming.XMLStreamWriterFactory.RecycleAware;
31 import javax.xml.namespace.NamespaceContext;
32 import javax.xml.stream.XMLStreamException;
33 import javax.xml.stream.XMLStreamWriter;
35 /**
36 * {@link XMLStreamWriter} that delegates to another {@link XMLStreamWriter}.
37 *
38 * <p>
39 * This class isn't very useful by itself, but works as a base class
40 * for {@link XMLStreamWriter} filtering.
41 *
42 * @author Kohsuke Kawaguchi
43 */
44 public class XMLStreamWriterFilter implements XMLStreamWriter, RecycleAware {
45 protected XMLStreamWriter writer;
47 public XMLStreamWriterFilter(XMLStreamWriter writer) {
48 this.writer = writer;
49 }
51 public void close() throws XMLStreamException {
52 writer.close();
53 }
55 public void flush() throws XMLStreamException {
56 writer.flush();
57 }
59 public void writeEndDocument() throws XMLStreamException {
60 writer.writeEndDocument();
61 }
63 public void writeEndElement() throws XMLStreamException {
64 writer.writeEndElement();
65 }
67 public void writeStartDocument() throws XMLStreamException {
68 writer.writeStartDocument();
69 }
71 public void writeCharacters(char[] text, int start, int len) throws XMLStreamException {
72 writer.writeCharacters(text, start, len);
73 }
75 public void setDefaultNamespace(String uri) throws XMLStreamException {
76 writer.setDefaultNamespace(uri);
77 }
79 public void writeCData(String data) throws XMLStreamException {
80 writer.writeCData(data);
81 }
83 public void writeCharacters(String text) throws XMLStreamException {
84 writer.writeCharacters(text);
85 }
87 public void writeComment(String data) throws XMLStreamException {
88 writer.writeComment(data);
89 }
91 public void writeDTD(String dtd) throws XMLStreamException {
92 writer.writeDTD(dtd);
93 }
95 public void writeDefaultNamespace(String namespaceURI) throws XMLStreamException {
96 writer.writeDefaultNamespace(namespaceURI);
97 }
99 public void writeEmptyElement(String localName) throws XMLStreamException {
100 writer.writeEmptyElement(localName);
101 }
103 public void writeEntityRef(String name) throws XMLStreamException {
104 writer.writeEntityRef(name);
105 }
107 public void writeProcessingInstruction(String target) throws XMLStreamException {
108 writer.writeProcessingInstruction(target);
109 }
111 public void writeStartDocument(String version) throws XMLStreamException {
112 writer.writeStartDocument(version);
113 }
115 public void writeStartElement(String localName) throws XMLStreamException {
116 writer.writeStartElement(localName);
117 }
119 public NamespaceContext getNamespaceContext() {
120 return writer.getNamespaceContext();
121 }
123 public void setNamespaceContext(NamespaceContext context) throws XMLStreamException {
124 writer.setNamespaceContext(context);
125 }
127 public Object getProperty(String name) throws IllegalArgumentException {
128 return writer.getProperty(name);
129 }
131 public String getPrefix(String uri) throws XMLStreamException {
132 return writer.getPrefix(uri);
133 }
135 public void setPrefix(String prefix, String uri) throws XMLStreamException {
136 writer.setPrefix(prefix, uri);
137 }
139 public void writeAttribute(String localName, String value) throws XMLStreamException {
140 writer.writeAttribute(localName, value);
141 }
143 public void writeEmptyElement(String namespaceURI, String localName) throws XMLStreamException {
144 writer.writeEmptyElement(namespaceURI, localName);
145 }
147 public void writeNamespace(String prefix, String namespaceURI) throws XMLStreamException {
148 writer.writeNamespace(prefix, namespaceURI);
149 }
151 public void writeProcessingInstruction(String target, String data) throws XMLStreamException {
152 writer.writeProcessingInstruction(target, data);
153 }
155 public void writeStartDocument(String encoding, String version) throws XMLStreamException {
156 writer.writeStartDocument(encoding, version);
157 }
159 public void writeStartElement(String namespaceURI, String localName) throws XMLStreamException {
160 writer.writeStartElement(namespaceURI, localName);
161 }
163 public void writeAttribute(String namespaceURI, String localName, String value) throws XMLStreamException {
164 writer.writeAttribute(namespaceURI, localName, value);
165 }
167 public void writeEmptyElement(String prefix, String localName, String namespaceURI) throws XMLStreamException {
168 writer.writeEmptyElement(prefix, localName, namespaceURI);
169 }
171 public void writeStartElement(String prefix, String localName, String namespaceURI) throws XMLStreamException {
172 writer.writeStartElement(prefix, localName, namespaceURI);
173 }
175 public void writeAttribute(String prefix, String namespaceURI, String localName, String value) throws XMLStreamException {
176 writer.writeAttribute(prefix, namespaceURI, localName, value);
177 }
179 public void onRecycled() {
180 XMLStreamWriterFactory.recycle(writer);
181 writer = null;
182 }
183 }