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. Oracle designates this 7 * particular file as subject to the "Classpath" exception as provided 8 * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 * or visit www.oracle.com if you need additional information or have any 22 * questions. 23 */ 24 25 /* 26 * Copyright (c) 2009 by Oracle Corporation. 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 * @version 1.0 47 * @author Copyright (c) 2009 by Oracle Corporation. All Rights Reserved. 48 * @see javax.xml.stream.XMLStreamReader 49 * @see EventReaderDelegate 50 * @since 1.6 51 */ 52 53 public class StreamReaderDelegate implements XMLStreamReader { 54 private XMLStreamReader reader; 55 56 /** 57 * Construct an empty filter with no parent. 58 */ 59 public StreamReaderDelegate(){} 60 61 /** 62 * Construct an filter with the specified parent. 63 * @param reader the parent 64 */ 65 public StreamReaderDelegate(XMLStreamReader reader) { 66 this.reader = reader; 67 } 68 69 /** 70 * Set the parent of this instance. 71 * @param reader the new parent 72 */ 73 public void setParent(XMLStreamReader reader) { 74 this.reader = reader; 75 } 76 77 /** 78 * Get the parent of this instance. 79 * @return the parent or null if none is set 80 */ 81 public XMLStreamReader getParent() { 82 return reader; 83 } 84 85 public int next() 86 throws XMLStreamException 87 { 88 return reader.next(); 89 } 90 91 public int nextTag() 92 throws XMLStreamException 93 { 94 return reader.nextTag(); 95 } 96 97 public String getElementText() 98 throws XMLStreamException 99 { 100 return reader.getElementText(); 101 } 102 103 public void require(int type, String namespaceURI, String localName) 104 throws XMLStreamException 105 { 106 reader.require(type,namespaceURI,localName); 107 } 108 109 public boolean hasNext() 110 throws XMLStreamException 111 { 112 return reader.hasNext(); 113 } 114 115 public void close() 116 throws XMLStreamException 117 { 118 reader.close(); 119 } 120 121 public String getNamespaceURI(String prefix) 122 { 123 return reader.getNamespaceURI(prefix); 124 } 125 126 public NamespaceContext getNamespaceContext() { 127 return reader.getNamespaceContext(); 128 } 129 130 public boolean isStartElement() { 131 return reader.isStartElement(); 132 } 133 134 public boolean isEndElement() { 135 return reader.isEndElement(); 136 } 137 138 public boolean isCharacters() { 139 return reader.isCharacters(); 140 } 141 142 public boolean isWhiteSpace() { 143 return reader.isWhiteSpace(); 144 } 145 146 public String getAttributeValue(String namespaceUri, 147 String localName) 148 { 149 return reader.getAttributeValue(namespaceUri,localName); 150 } 151 152 public int getAttributeCount() { 153 return reader.getAttributeCount(); 154 } 155 156 public QName getAttributeName(int index) { 157 return reader.getAttributeName(index); 158 } 159 160 public String getAttributePrefix(int index) { 161 return reader.getAttributePrefix(index); 162 } 163 164 public String getAttributeNamespace(int index) { 165 return reader.getAttributeNamespace(index); 166 } 167 168 public String getAttributeLocalName(int index) { 169 return reader.getAttributeLocalName(index); 170 } 171 172 public String getAttributeType(int index) { 173 return reader.getAttributeType(index); 174 } 175 176 public String getAttributeValue(int index) { 177 return reader.getAttributeValue(index); 178 } 179 180 public boolean isAttributeSpecified(int index) { 181 return reader.isAttributeSpecified(index); 182 } 183 184 public int getNamespaceCount() { 185 return reader.getNamespaceCount(); 186 } 187 188 public String getNamespacePrefix(int index) { 189 return reader.getNamespacePrefix(index); 190 } 191 192 public String getNamespaceURI(int index) { 193 return reader.getNamespaceURI(index); 194 } 195 196 public int getEventType() { 197 return reader.getEventType(); 198 } 199 200 public String getText() { 201 return reader.getText(); 202 } 203 204 public int getTextCharacters(int sourceStart, 205 char[] target, 206 int targetStart, 207 int length) 208 throws XMLStreamException { 209 return reader.getTextCharacters(sourceStart, 210 target, 211 targetStart, 212 length); 213 } 214 215 216 public char[] getTextCharacters() { 217 return reader.getTextCharacters(); 218 } 219 220 public int getTextStart() { 221 return reader.getTextStart(); 222 } 223 224 public int getTextLength() { 225 return reader.getTextLength(); 226 } 227 228 public String getEncoding() { 229 return reader.getEncoding(); 230 } 231 232 public boolean hasText() { 233 return reader.hasText(); 234 } 235 236 public Location getLocation() { 237 return reader.getLocation(); 238 } 239 240 public QName getName() { 241 return reader.getName(); 242 } 243 244 public String getLocalName() { 245 return reader.getLocalName(); 246 } 247 248 public boolean hasName() { 249 return reader.hasName(); 250 } 251 252 public String getNamespaceURI() { 253 return reader.getNamespaceURI(); 254 } 255 256 public String getPrefix() { 257 return reader.getPrefix(); 258 } 259 260 public String getVersion() { 261 return reader.getVersion(); 262 } 263 264 public boolean isStandalone() { 265 return reader.isStandalone(); 266 } 267 268 public boolean standaloneSet() { 269 return reader.standaloneSet(); 270 } 271 272 public String getCharacterEncodingScheme() { 273 return reader.getCharacterEncodingScheme(); 274 } 275 276 public String getPITarget() { 277 return reader.getPITarget(); 278 } 279 280 public String getPIData() { 281 return reader.getPIData(); 282 } 283 284 public Object getProperty(String name) { 285 return reader.getProperty(name); 286 } 287 }