Path: blob/master/src/java.xml/share/classes/javax/xml/stream/util/StreamReaderDelegate.java
40955 views
/*1* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.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 it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* 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 WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 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 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.xml.stream.util;2627import javax.xml.namespace.QName;28import javax.xml.namespace.NamespaceContext;29import javax.xml.stream.XMLStreamReader;30import javax.xml.stream.Location;31import javax.xml.stream.XMLStreamException;3233/**34* This is the base class for deriving an XMLStreamReader filter35*36* This class is designed to sit between an XMLStreamReader and an37* application's XMLStreamReader. By default each method38* does nothing but call the corresponding method on the39* parent interface.40*41* @version 1.042* @author Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.43* @see javax.xml.stream.XMLStreamReader44* @see EventReaderDelegate45* @since 1.646*/4748public class StreamReaderDelegate implements XMLStreamReader {49private XMLStreamReader reader;5051/**52* Construct an empty filter with no parent.53*/54public StreamReaderDelegate(){}5556/**57* Construct an filter with the specified parent.58* @param reader the parent59*/60public StreamReaderDelegate(XMLStreamReader reader) {61this.reader = reader;62}6364/**65* Set the parent of this instance.66* @param reader the new parent67*/68public void setParent(XMLStreamReader reader) {69this.reader = reader;70}7172/**73* Get the parent of this instance.74* @return the parent or null if none is set75*/76public XMLStreamReader getParent() {77return reader;78}7980public int next()81throws XMLStreamException82{83return reader.next();84}8586public int nextTag()87throws XMLStreamException88{89return reader.nextTag();90}9192public String getElementText()93throws XMLStreamException94{95return reader.getElementText();96}9798public void require(int type, String namespaceURI, String localName)99throws XMLStreamException100{101reader.require(type,namespaceURI,localName);102}103104public boolean hasNext()105throws XMLStreamException106{107return reader.hasNext();108}109110public void close()111throws XMLStreamException112{113reader.close();114}115116public String getNamespaceURI(String prefix)117{118return reader.getNamespaceURI(prefix);119}120121public NamespaceContext getNamespaceContext() {122return reader.getNamespaceContext();123}124125public boolean isStartElement() {126return reader.isStartElement();127}128129public boolean isEndElement() {130return reader.isEndElement();131}132133public boolean isCharacters() {134return reader.isCharacters();135}136137public boolean isWhiteSpace() {138return reader.isWhiteSpace();139}140141public String getAttributeValue(String namespaceUri,142String localName)143{144return reader.getAttributeValue(namespaceUri,localName);145}146147public int getAttributeCount() {148return reader.getAttributeCount();149}150151public QName getAttributeName(int index) {152return reader.getAttributeName(index);153}154155public String getAttributePrefix(int index) {156return reader.getAttributePrefix(index);157}158159public String getAttributeNamespace(int index) {160return reader.getAttributeNamespace(index);161}162163public String getAttributeLocalName(int index) {164return reader.getAttributeLocalName(index);165}166167public String getAttributeType(int index) {168return reader.getAttributeType(index);169}170171public String getAttributeValue(int index) {172return reader.getAttributeValue(index);173}174175public boolean isAttributeSpecified(int index) {176return reader.isAttributeSpecified(index);177}178179public int getNamespaceCount() {180return reader.getNamespaceCount();181}182183public String getNamespacePrefix(int index) {184return reader.getNamespacePrefix(index);185}186187public String getNamespaceURI(int index) {188return reader.getNamespaceURI(index);189}190191public int getEventType() {192return reader.getEventType();193}194195public String getText() {196return reader.getText();197}198199public int getTextCharacters(int sourceStart,200char[] target,201int targetStart,202int length)203throws XMLStreamException {204return reader.getTextCharacters(sourceStart,205target,206targetStart,207length);208}209210211public char[] getTextCharacters() {212return reader.getTextCharacters();213}214215public int getTextStart() {216return reader.getTextStart();217}218219public int getTextLength() {220return reader.getTextLength();221}222223public String getEncoding() {224return reader.getEncoding();225}226227public boolean hasText() {228return reader.hasText();229}230231public Location getLocation() {232return reader.getLocation();233}234235public QName getName() {236return reader.getName();237}238239public String getLocalName() {240return reader.getLocalName();241}242243public boolean hasName() {244return reader.hasName();245}246247public String getNamespaceURI() {248return reader.getNamespaceURI();249}250251public String getPrefix() {252return reader.getPrefix();253}254255public String getVersion() {256return reader.getVersion();257}258259public boolean isStandalone() {260return reader.isStandalone();261}262263public boolean standaloneSet() {264return reader.standaloneSet();265}266267public String getCharacterEncodingScheme() {268return reader.getCharacterEncodingScheme();269}270271public String getPITarget() {272return reader.getPITarget();273}274275public String getPIData() {276return reader.getPIData();277}278279public Object getProperty(String name) {280return reader.getProperty(name);281}282}283284285