001: /*
002: * Portions Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: package com.sun.xml.internal.ws.streaming;
027:
028: import javax.xml.stream.XMLStreamReader;
029: import javax.xml.stream.XMLStreamException;
030: import javax.xml.stream.Location;
031: import javax.xml.namespace.NamespaceContext;
032: import javax.xml.namespace.QName;
033: import javax.xml.ws.WebServiceException;
034: import java.io.Closeable;
035: import java.io.IOException;
036:
037: /**
038: * Wrapper over XMLStreamReader. It will be used primarily to cleaup the resources such as closure on InputStream/Reader.
039: *
040: * @author Vivek Pandey
041: */
042: public class TidyXMLStreamReader implements XMLStreamReader {
043: private final XMLStreamReader reader;
044: private final Closeable closeableSource;
045:
046: public TidyXMLStreamReader(XMLStreamReader reader,
047: Closeable closeableSource) {
048: this .reader = reader;
049: this .closeableSource = closeableSource;
050: }
051:
052: public int getAttributeCount() {
053: return reader.getAttributeCount();
054: }
055:
056: public int getEventType() {
057: return reader.getEventType();
058: }
059:
060: public int getNamespaceCount() {
061: return reader.getNamespaceCount();
062: }
063:
064: public int getTextLength() {
065: return reader.getTextLength();
066: }
067:
068: public int getTextStart() {
069: return reader.getTextStart();
070: }
071:
072: public int next() throws XMLStreamException {
073: return reader.next();
074: }
075:
076: public int nextTag() throws XMLStreamException {
077: return reader.nextTag();
078: }
079:
080: public void close() throws XMLStreamException {
081: reader.close();
082: try {
083: closeableSource.close();
084: } catch (IOException e) {
085: throw new WebServiceException(e);
086: }
087: }
088:
089: public boolean hasName() {
090: return reader.hasName();
091: }
092:
093: public boolean hasNext() throws XMLStreamException {
094: return reader.hasNext();
095: }
096:
097: public boolean hasText() {
098: return reader.hasText();
099: }
100:
101: public boolean isCharacters() {
102: return reader.isCharacters();
103: }
104:
105: public boolean isEndElement() {
106: return reader.isEndElement();
107: }
108:
109: public boolean isStandalone() {
110: return reader.isStandalone();
111: }
112:
113: public boolean isStartElement() {
114: return reader.isStartElement();
115: }
116:
117: public boolean isWhiteSpace() {
118: return reader.isWhiteSpace();
119: }
120:
121: public boolean standaloneSet() {
122: return reader.standaloneSet();
123: }
124:
125: public char[] getTextCharacters() {
126: return reader.getTextCharacters();
127: }
128:
129: public boolean isAttributeSpecified(int i) {
130: return reader.isAttributeSpecified(i);
131: }
132:
133: public int getTextCharacters(int i, char[] chars, int i1, int i2)
134: throws XMLStreamException {
135: return reader.getTextCharacters(i, chars, i1, i2);
136: }
137:
138: public String getCharacterEncodingScheme() {
139: return reader.getCharacterEncodingScheme();
140: }
141:
142: public String getElementText() throws XMLStreamException {
143: return reader.getElementText();
144: }
145:
146: public String getEncoding() {
147: return reader.getEncoding();
148: }
149:
150: public String getLocalName() {
151: return reader.getLocalName();
152: }
153:
154: public String getNamespaceURI() {
155: return reader.getNamespaceURI();
156: }
157:
158: public String getPIData() {
159: return reader.getPIData();
160: }
161:
162: public String getPITarget() {
163: return reader.getPITarget();
164: }
165:
166: public String getPrefix() {
167: return reader.getPrefix();
168: }
169:
170: public String getText() {
171: return reader.getText();
172: }
173:
174: public String getVersion() {
175: return reader.getVersion();
176: }
177:
178: public String getAttributeLocalName(int i) {
179: return reader.getAttributeLocalName(i);
180: }
181:
182: public String getAttributeNamespace(int i) {
183: return reader.getAttributeNamespace(i);
184: }
185:
186: public String getAttributePrefix(int i) {
187: return reader.getAttributePrefix(i);
188: }
189:
190: public String getAttributeType(int i) {
191: return reader.getAttributeType(i);
192: }
193:
194: public String getAttributeValue(int i) {
195: return reader.getAttributeValue(i);
196: }
197:
198: public String getNamespacePrefix(int i) {
199: return reader.getNamespacePrefix(i);
200: }
201:
202: public String getNamespaceURI(int i) {
203: return reader.getNamespaceURI(i);
204: }
205:
206: public NamespaceContext getNamespaceContext() {
207: return reader.getNamespaceContext();
208: }
209:
210: public QName getName() {
211: return reader.getName();
212: }
213:
214: public QName getAttributeName(int i) {
215: return reader.getAttributeName(i);
216: }
217:
218: public Location getLocation() {
219: return reader.getLocation();
220: }
221:
222: public Object getProperty(String s) throws IllegalArgumentException {
223: return reader.getProperty(s);
224: }
225:
226: public void require(int i, String s, String s1)
227: throws XMLStreamException {
228: reader.require(i, s, s1);
229: }
230:
231: public String getNamespaceURI(String s) {
232: return reader.getNamespaceURI(s);
233: }
234:
235: public String getAttributeValue(String s, String s1) {
236: return reader.getAttributeValue(s, s1);
237: }
238:
239: }
|