1/* 2 * Copyright (c) 1997, 2013, 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 */ 25 26package com.sun.xml.internal.ws.util.xml; 27 28import com.sun.xml.internal.ws.api.streaming.XMLStreamReaderFactory; 29 30import javax.xml.namespace.NamespaceContext; 31import javax.xml.namespace.QName; 32import javax.xml.stream.Location; 33import javax.xml.stream.XMLStreamException; 34import javax.xml.stream.XMLStreamReader; 35 36/** 37 * {@link XMLStreamReader} that delegates to another {@link XMLStreamReader}. 38 * 39 * <p> 40 * This class isn't very useful by itself, but works as a base class 41 * for {@link XMLStreamReader} filtering. 42 * 43 * @author Kohsuke Kawaguchi 44 */ 45public class XMLStreamReaderFilter implements XMLStreamReaderFactory.RecycleAware, XMLStreamReader { 46 /** 47 * The underlying {@link XMLStreamReader} that does the parsing of the root part. 48 */ 49 protected XMLStreamReader reader; 50 51 public XMLStreamReaderFilter(XMLStreamReader core) { 52 this.reader = core; 53 } 54 55 public void onRecycled() { 56 XMLStreamReaderFactory.recycle(reader); 57 reader = null; 58 } 59 60 public int getAttributeCount() { 61 return reader.getAttributeCount(); 62 } 63 64 public int getEventType() { 65 return reader.getEventType(); 66 } 67 68 public int getNamespaceCount() { 69 return reader.getNamespaceCount(); 70 } 71 72 public int getTextLength() { 73 return reader.getTextLength(); 74 } 75 76 public int getTextStart() { 77 return reader.getTextStart(); 78 } 79 80 public int next() throws XMLStreamException { 81 return reader.next(); 82 } 83 84 public int nextTag() throws XMLStreamException { 85 return reader.nextTag(); 86 } 87 88 public void close() throws XMLStreamException { 89 reader.close(); 90 } 91 92 public boolean hasName() { 93 return reader.hasName(); 94 } 95 96 public boolean hasNext() throws XMLStreamException { 97 return reader.hasNext(); 98 } 99 100 public boolean hasText() { 101 return reader.hasText(); 102 } 103 104 public boolean isCharacters() { 105 return reader.isCharacters(); 106 } 107 108 public boolean isEndElement() { 109 return reader.isEndElement(); 110 } 111 112 public boolean isStandalone() { 113 return reader.isStandalone(); 114 } 115 116 public boolean isStartElement() { 117 return reader.isStartElement(); 118 } 119 120 public boolean isWhiteSpace() { 121 return reader.isWhiteSpace(); 122 } 123 124 public boolean standaloneSet() { 125 return reader.standaloneSet(); 126 } 127 128 public char[] getTextCharacters() { 129 return reader.getTextCharacters(); 130 } 131 132 public boolean isAttributeSpecified(int index) { 133 return reader.isAttributeSpecified(index); 134 } 135 136 public int getTextCharacters(int sourceStart, char[] target, int targetStart, int length) throws XMLStreamException { 137 return reader.getTextCharacters(sourceStart, target, targetStart, length); 138 } 139 140 public String getCharacterEncodingScheme() { 141 return reader.getCharacterEncodingScheme(); 142 } 143 144 public String getElementText() throws XMLStreamException { 145 return reader.getElementText(); 146 } 147 148 public String getEncoding() { 149 return reader.getEncoding(); 150 } 151 152 public String getLocalName() { 153 return reader.getLocalName(); 154 } 155 156 public String getNamespaceURI() { 157 return reader.getNamespaceURI(); 158 } 159 160 public String getPIData() { 161 return reader.getPIData(); 162 } 163 164 public String getPITarget() { 165 return reader.getPITarget(); 166 } 167 168 public String getPrefix() { 169 return reader.getPrefix(); 170 } 171 172 public String getText() { 173 return reader.getText(); 174 } 175 176 public String getVersion() { 177 return reader.getVersion(); 178 } 179 180 public String getAttributeLocalName(int index) { 181 return reader.getAttributeLocalName(index); 182 } 183 184 public String getAttributeNamespace(int index) { 185 return reader.getAttributeNamespace(index); 186 } 187 188 public String getAttributePrefix(int index) { 189 return reader.getAttributePrefix(index); 190 } 191 192 public String getAttributeType(int index) { 193 return reader.getAttributeType(index); 194 } 195 196 public String getAttributeValue(int index) { 197 return reader.getAttributeValue(index); 198 } 199 200 public String getNamespacePrefix(int index) { 201 return reader.getNamespacePrefix(index); 202 } 203 204 public String getNamespaceURI(int index) { 205 return reader.getNamespaceURI(index); 206 } 207 208 public NamespaceContext getNamespaceContext() { 209 return reader.getNamespaceContext(); 210 } 211 212 public QName getName() { 213 return reader.getName(); 214 } 215 216 public QName getAttributeName(int index) { 217 return reader.getAttributeName(index); 218 } 219 220 public Location getLocation() { 221 return reader.getLocation(); 222 } 223 224 public Object getProperty(String name) throws IllegalArgumentException { 225 return reader.getProperty(name); 226 } 227 228 public void require(int type, String namespaceURI, String localName) throws XMLStreamException { 229 reader.require(type, namespaceURI, localName); 230 } 231 232 public String getNamespaceURI(String prefix) { 233 return reader.getNamespaceURI(prefix); 234 } 235 236 public String getAttributeValue(String namespaceURI, String localName) { 237 return reader.getAttributeValue(namespaceURI, localName); 238 } 239} 240