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.XMLStreamReaderFactory;
040:
041: import javax.xml.namespace.NamespaceContext;
042: import javax.xml.namespace.QName;
043: import javax.xml.stream.Location;
044: import javax.xml.stream.XMLStreamException;
045: import javax.xml.stream.XMLStreamReader;
046:
047: /**
048: * {@link XMLStreamReader} that delegates to another {@link XMLStreamReader}.
049: *
050: * <p>
051: * This class isn't very useful by itself, but works as a base class
052: * for {@link XMLStreamReader} filtering.
053: *
054: * @author Kohsuke Kawaguchi
055: */
056: public class XMLStreamReaderFilter implements
057: XMLStreamReaderFactory.RecycleAware, XMLStreamReader {
058: /**
059: * The underlying {@link XMLStreamReader} that does the parsing of the root part.
060: */
061: protected XMLStreamReader reader;
062:
063: public XMLStreamReaderFilter(XMLStreamReader core) {
064: this .reader = core;
065: }
066:
067: public void onRecycled() {
068: XMLStreamReaderFactory.recycle(reader);
069: reader = null;
070: }
071:
072: public int getAttributeCount() {
073: return reader.getAttributeCount();
074: }
075:
076: public int getEventType() {
077: return reader.getEventType();
078: }
079:
080: public int getNamespaceCount() {
081: return reader.getNamespaceCount();
082: }
083:
084: public int getTextLength() {
085: return reader.getTextLength();
086: }
087:
088: public int getTextStart() {
089: return reader.getTextStart();
090: }
091:
092: public int next() throws XMLStreamException {
093: return reader.next();
094: }
095:
096: public int nextTag() throws XMLStreamException {
097: return reader.nextTag();
098: }
099:
100: public void close() throws XMLStreamException {
101: reader.close();
102: }
103:
104: public boolean hasName() {
105: return reader.hasName();
106: }
107:
108: public boolean hasNext() throws XMLStreamException {
109: return reader.hasNext();
110: }
111:
112: public boolean hasText() {
113: return reader.hasText();
114: }
115:
116: public boolean isCharacters() {
117: return reader.isCharacters();
118: }
119:
120: public boolean isEndElement() {
121: return reader.isEndElement();
122: }
123:
124: public boolean isStandalone() {
125: return reader.isStandalone();
126: }
127:
128: public boolean isStartElement() {
129: return reader.isStartElement();
130: }
131:
132: public boolean isWhiteSpace() {
133: return reader.isWhiteSpace();
134: }
135:
136: public boolean standaloneSet() {
137: return reader.standaloneSet();
138: }
139:
140: public char[] getTextCharacters() {
141: return reader.getTextCharacters();
142: }
143:
144: public boolean isAttributeSpecified(int index) {
145: return reader.isAttributeSpecified(index);
146: }
147:
148: public int getTextCharacters(int sourceStart, char[] target,
149: int targetStart, int length) throws XMLStreamException {
150: return reader.getTextCharacters(sourceStart, target,
151: targetStart, length);
152: }
153:
154: public String getCharacterEncodingScheme() {
155: return reader.getCharacterEncodingScheme();
156: }
157:
158: public String getElementText() throws XMLStreamException {
159: return reader.getElementText();
160: }
161:
162: public String getEncoding() {
163: return reader.getEncoding();
164: }
165:
166: public String getLocalName() {
167: return reader.getLocalName();
168: }
169:
170: public String getNamespaceURI() {
171: return reader.getNamespaceURI();
172: }
173:
174: public String getPIData() {
175: return reader.getPIData();
176: }
177:
178: public String getPITarget() {
179: return reader.getPITarget();
180: }
181:
182: public String getPrefix() {
183: return reader.getPrefix();
184: }
185:
186: public String getText() {
187: return reader.getText();
188: }
189:
190: public String getVersion() {
191: return reader.getVersion();
192: }
193:
194: public String getAttributeLocalName(int index) {
195: return reader.getAttributeLocalName(index);
196: }
197:
198: public String getAttributeNamespace(int index) {
199: return reader.getAttributeNamespace(index);
200: }
201:
202: public String getAttributePrefix(int index) {
203: return reader.getAttributePrefix(index);
204: }
205:
206: public String getAttributeType(int index) {
207: return reader.getAttributeType(index);
208: }
209:
210: public String getAttributeValue(int index) {
211: return reader.getAttributeValue(index);
212: }
213:
214: public String getNamespacePrefix(int index) {
215: return reader.getNamespacePrefix(index);
216: }
217:
218: public String getNamespaceURI(int index) {
219: return reader.getNamespaceURI(index);
220: }
221:
222: public NamespaceContext getNamespaceContext() {
223: return reader.getNamespaceContext();
224: }
225:
226: public QName getName() {
227: return reader.getName();
228: }
229:
230: public QName getAttributeName(int index) {
231: return reader.getAttributeName(index);
232: }
233:
234: public Location getLocation() {
235: return reader.getLocation();
236: }
237:
238: public Object getProperty(String name)
239: throws IllegalArgumentException {
240: return reader.getProperty(name);
241: }
242:
243: public void require(int type, String namespaceURI, String localName)
244: throws XMLStreamException {
245: reader.require(type, namespaceURI, localName);
246: }
247:
248: public String getNamespaceURI(String prefix) {
249: return reader.getNamespaceURI(prefix);
250: }
251:
252: public String getAttributeValue(String namespaceURI,
253: String localName) {
254: return reader.getAttributeValue(namespaceURI, localName);
255: }
256: }
|