1 /*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3 *
4 * This code is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 only, as
6 * published by the Free Software Foundation. Sun designates this
7 * particular file as subject to the "Classpath" exception as provided
8 * by Sun in the LICENSE file that accompanied this code.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
22 * have any questions.
23 */
24
25 /*
26 * Copyright (c) 2003 by BEA Systems, Inc. All Rights Reserved.
27 */
28
29 package javax.xml.stream.util;
30
31 import java.io.Reader;
32 import javax.xml.namespace.QName;
33 import javax.xml.namespace.NamespaceContext;
34 import javax.xml.stream.XMLStreamReader;
35 import javax.xml.stream.Location;
36 import javax.xml.stream.XMLStreamException;
37
38 /**
39 * This is the base class for deriving an XMLStreamReader filter
40 *
41 * This class is designed to sit between an XMLStreamReader and an
42 * application's XMLStreamReader. By default each method
43 * does nothing but call the corresponding method on the
44 * parent interface.
45 *
46 * @author Copyright (c) 2003 by BEA Systems. All Rights Reserved.
47 * @see javax.xml.stream.XMLStreamReader
48 * @see EventReaderDelegate
49 * @since 1.6
50 */
51
52 public class StreamReaderDelegate implements XMLStreamReader {
53 private XMLStreamReader reader;
54
55 /**
56 * Construct an empty filter with no parent.
57 */
58 public StreamReaderDelegate(){}
59
60 /**
61 * Construct an filter with the specified parent.
62 * @param reader the parent
63 */
64 public StreamReaderDelegate(XMLStreamReader reader) {
65 this.reader = reader;
66 }
67
68 /**
69 * Set the parent of this instance.
70 * @param reader the new parent
71 */
72 public void setParent(XMLStreamReader reader) {
73 this.reader = reader;
74 }
75
76 /**
77 * Get the parent of this instance.
78 * @return the parent or null if none is set
79 */
80 public XMLStreamReader getParent() {
81 return reader;
82 }
83
84 public int next()
85 throws XMLStreamException
86 {
87 return reader.next();
88 }
89
90 public int nextTag()
91 throws XMLStreamException
92 {
93 return reader.nextTag();
94 }
95
96 public String getElementText()
97 throws XMLStreamException
98 {
99 return reader.getElementText();
100 }
101
102 public void require(int type, String namespaceURI, String localName)
103 throws XMLStreamException
104 {
105 reader.require(type,namespaceURI,localName);
106 }
107
108 public boolean hasNext()
109 throws XMLStreamException
110 {
111 return reader.hasNext();
112 }
113
114 public void close()
115 throws XMLStreamException
116 {
117 reader.close();
118 }
119
120 public String getNamespaceURI(String prefix)
121 {
122 return reader.getNamespaceURI(prefix);
123 }
124
125 public NamespaceContext getNamespaceContext() {
126 return reader.getNamespaceContext();
127 }
128
129 public boolean isStartElement() {
130 return reader.isStartElement();
131 }
132
133 public boolean isEndElement() {
134 return reader.isEndElement();
135 }
136
137 public boolean isCharacters() {
138 return reader.isCharacters();
139 }
140
141 public boolean isWhiteSpace() {
142 return reader.isWhiteSpace();
143 }
144
145 public String getAttributeValue(String namespaceUri,
146 String localName)
147 {
148 return reader.getAttributeValue(namespaceUri,localName);
149 }
150
151 public int getAttributeCount() {
152 return reader.getAttributeCount();
153 }
154
155 public QName getAttributeName(int index) {
156 return reader.getAttributeName(index);
157 }
158
159 public String getAttributePrefix(int index) {
160 return reader.getAttributePrefix(index);
161 }
162
163 public String getAttributeNamespace(int index) {
164 return reader.getAttributeNamespace(index);
165 }
166
167 public String getAttributeLocalName(int index) {
168 return reader.getAttributeLocalName(index);
169 }
170
171 public String getAttributeType(int index) {
172 return reader.getAttributeType(index);
173 }
174
175 public String getAttributeValue(int index) {
176 return reader.getAttributeValue(index);
177 }
178
179 public boolean isAttributeSpecified(int index) {
180 return reader.isAttributeSpecified(index);
181 }
182
183 public int getNamespaceCount() {
184 return reader.getNamespaceCount();
185 }
186
187 public String getNamespacePrefix(int index) {
188 return reader.getNamespacePrefix(index);
189 }
190
191 public String getNamespaceURI(int index) {
192 return reader.getNamespaceURI(index);
193 }
194
195 public int getEventType() {
196 return reader.getEventType();
197 }
198
199 public String getText() {
200 return reader.getText();
201 }
202
203 public int getTextCharacters(int sourceStart,
204 char[] target,
205 int targetStart,
206 int length)
207 throws XMLStreamException {
208 return reader.getTextCharacters(sourceStart,
209 target,
210 targetStart,
211 length);
212 }
213
214
215 public char[] getTextCharacters() {
216 return reader.getTextCharacters();
217 }
218
219 public int getTextStart() {
220 return reader.getTextStart();
221 }
222
223 public int getTextLength() {
224 return reader.getTextLength();
225 }
226
227 public String getEncoding() {
228 return reader.getEncoding();
229 }
230
231 public boolean hasText() {
232 return reader.hasText();
233 }
234
235 public Location getLocation() {
236 return reader.getLocation();
237 }
238
239 public QName getName() {
240 return reader.getName();
241 }
242
243 public String getLocalName() {
244 return reader.getLocalName();
245 }
246
247 public boolean hasName() {
248 return reader.hasName();
249 }
250
251 public String getNamespaceURI() {
252 return reader.getNamespaceURI();
253 }
254
255 public String getPrefix() {
256 return reader.getPrefix();
257 }
258
259 public String getVersion() {
260 return reader.getVersion();
261 }
262
263 public boolean isStandalone() {
264 return reader.isStandalone();
265 }
266
267 public boolean standaloneSet() {
268 return reader.standaloneSet();
269 }
270
271 public String getCharacterEncodingScheme() {
272 return reader.getCharacterEncodingScheme();
273 }
274
275 public String getPITarget() {
276 return reader.getPITarget();
277 }
278
279 public String getPIData() {
280 return reader.getPIData();
281 }
282
283 public Object getProperty(String name) {
284 return reader.getProperty(name);
285 }
286 }