| /* |
| * Portions Copyright 2006 Sun Microsystems, Inc. All Rights Reserved. |
| * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| * |
| * This code is free software; you can redistribute it and/or modify it |
| * under the terms of the GNU General Public License version 2 only, as |
| * published by the Free Software Foundation. Sun designates this |
| * particular file as subject to the "Classpath" exception as provided |
| * by Sun in the LICENSE file that accompanied this code. |
| * |
| * This code is distributed in the hope that it will be useful, but WITHOUT |
| * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| * version 2 for more details (a copy is included in the LICENSE file that |
| * accompanied this code). |
| * |
| * You should have received a copy of the GNU General Public License version |
| * 2 along with this work; if not, write to the Free Software Foundation, |
| * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| * |
| * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| * CA 95054 USA or visit www.sun.com if you need additional information or |
| * have any questions. |
| */ |
| |
| package com.sun.xml.internal.ws.streaming; |
| |
| import javax.xml.stream.XMLStreamReader; |
| import javax.xml.stream.XMLStreamException; |
| import javax.xml.stream.Location; |
| import javax.xml.namespace.NamespaceContext; |
| import javax.xml.namespace.QName; |
| import javax.xml.ws.WebServiceException; |
| import java.io.Closeable; |
| import java.io.IOException; |
| |
| /** |
| * Wrapper over XMLStreamReader. It will be used primarily to cleaup the resources such as closure on InputStream/Reader. |
| * |
| * @author Vivek Pandey |
| */ |
| public class TidyXMLStreamReader implements XMLStreamReader{ |
| private final XMLStreamReader reader; |
| private final Closeable closeableSource; |
| |
| public TidyXMLStreamReader(XMLStreamReader reader, Closeable closeableSource) { |
| this.reader = reader; |
| this.closeableSource = closeableSource; |
| } |
| |
| public int getAttributeCount() { |
| return reader.getAttributeCount(); |
| } |
| |
| public int getEventType() { |
| return reader.getEventType(); |
| } |
| |
| public int getNamespaceCount() { |
| return reader.getNamespaceCount(); |
| } |
| |
| public int getTextLength() { |
| return reader.getTextLength(); |
| } |
| |
| public int getTextStart() { |
| return reader.getTextStart(); |
| } |
| |
| public int next() throws XMLStreamException { |
| return reader.next(); |
| } |
| |
| public int nextTag() throws XMLStreamException { |
| return reader.nextTag(); |
| } |
| |
| public void close() throws XMLStreamException { |
| reader.close(); |
| try { |
| closeableSource.close(); |
| } catch (IOException e) { |
| throw new WebServiceException(e); |
| } |
| } |
| |
| public boolean hasName() { |
| return reader.hasName(); |
| } |
| |
| public boolean hasNext() throws XMLStreamException { |
| return reader.hasNext(); |
| } |
| |
| public boolean hasText() { |
| return reader.hasText(); |
| } |
| |
| public boolean isCharacters() { |
| return reader.isCharacters(); |
| } |
| |
| public boolean isEndElement() { |
| return reader.isEndElement(); |
| } |
| |
| public boolean isStandalone() { |
| return reader.isStandalone(); |
| } |
| |
| public boolean isStartElement() { |
| return reader.isStartElement(); |
| } |
| |
| public boolean isWhiteSpace() { |
| return reader.isWhiteSpace(); |
| } |
| |
| public boolean standaloneSet() { |
| return reader.standaloneSet(); |
| } |
| |
| public char[] getTextCharacters() { |
| return reader.getTextCharacters(); |
| } |
| |
| public boolean isAttributeSpecified(int i) { |
| return reader.isAttributeSpecified(i); |
| } |
| |
| public int getTextCharacters(int i, char[] chars, int i1, int i2) throws XMLStreamException { |
| return reader.getTextCharacters(i, chars, i1, i2); |
| } |
| |
| public String getCharacterEncodingScheme() { |
| return reader.getCharacterEncodingScheme(); |
| } |
| |
| public String getElementText() throws XMLStreamException { |
| return reader.getElementText(); |
| } |
| |
| public String getEncoding() { |
| return reader.getEncoding(); |
| } |
| |
| public String getLocalName() { |
| return reader.getLocalName(); |
| } |
| |
| public String getNamespaceURI() { |
| return reader.getNamespaceURI(); |
| } |
| |
| public String getPIData() { |
| return reader.getPIData(); |
| } |
| |
| public String getPITarget() { |
| return reader.getPITarget(); |
| } |
| |
| public String getPrefix() { |
| return reader.getPrefix(); |
| } |
| |
| public String getText() { |
| return reader.getText(); |
| } |
| |
| public String getVersion() { |
| return reader.getVersion(); |
| } |
| |
| public String getAttributeLocalName(int i) { |
| return reader.getAttributeLocalName(i); |
| } |
| |
| public String getAttributeNamespace(int i) { |
| return reader.getAttributeNamespace(i); |
| } |
| |
| public String getAttributePrefix(int i) { |
| return reader.getAttributePrefix(i); |
| } |
| |
| public String getAttributeType(int i) { |
| return reader.getAttributeType(i); |
| } |
| |
| public String getAttributeValue(int i) { |
| return reader.getAttributeValue(i); |
| } |
| |
| public String getNamespacePrefix(int i) { |
| return reader.getNamespacePrefix(i); |
| } |
| |
| public String getNamespaceURI(int i) { |
| return reader.getNamespaceURI(i); |
| } |
| |
| public NamespaceContext getNamespaceContext() { |
| return reader.getNamespaceContext(); |
| } |
| |
| public QName getName() { |
| return reader.getName(); |
| } |
| |
| public QName getAttributeName(int i) { |
| return reader.getAttributeName(i); |
| } |
| |
| public Location getLocation() { |
| return reader.getLocation(); |
| } |
| |
| public Object getProperty(String s) throws IllegalArgumentException { |
| return reader.getProperty(s); |
| } |
| |
| public void require(int i, String s, String s1) throws XMLStreamException { |
| reader.require(i, s, s1); |
| } |
| |
| public String getNamespaceURI(String s) { |
| return reader.getNamespaceURI(s); |
| } |
| |
| public String getAttributeValue(String s, String s1) { |
| return reader.getAttributeValue(s, s1); |
| } |
| |
| |
| } |