Path: blob/master/src/java.xml/share/classes/javax/xml/stream/util/EventReaderDelegate.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.stream.XMLEventReader;28import javax.xml.stream.events.XMLEvent;29import javax.xml.stream.XMLStreamException;3031/**32* This is the base class for deriving an XMLEventReader33* filter.34*35* This class is designed to sit between an XMLEventReader and an36* application's XMLEventReader. By default each method37* does nothing but call the corresponding method on the38* parent interface.39*40* @version 1.041* @author Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.42* @see javax.xml.stream.XMLEventReader43* @see StreamReaderDelegate44* @since 1.645*/4647public class EventReaderDelegate implements XMLEventReader {48private XMLEventReader reader;4950/**51* Construct an empty filter with no parent.52*/53public EventReaderDelegate(){}5455/**56* Construct an filter with the specified parent.57* @param reader the parent58*/59public EventReaderDelegate(XMLEventReader reader) {60this.reader = reader;61}6263/**64* Set the parent of this instance.65* @param reader the new parent66*/67public void setParent(XMLEventReader reader) {68this.reader = reader;69}7071/**72* Get the parent of this instance.73* @return the parent or null if none is set74*/75public XMLEventReader getParent() {76return reader;77}7879public XMLEvent nextEvent()80throws XMLStreamException81{82return reader.nextEvent();83}8485public Object next() {86return reader.next();87}8889public boolean hasNext()90{91return reader.hasNext();92}9394public XMLEvent peek()95throws XMLStreamException96{97return reader.peek();98}99100public void close()101throws XMLStreamException102{103reader.close();104}105106public String getElementText()107throws XMLStreamException108{109return reader.getElementText();110}111112public XMLEvent nextTag()113throws XMLStreamException114{115return reader.nextTag();116}117118public Object getProperty(java.lang.String name)119throws java.lang.IllegalArgumentException120{121return reader.getProperty(name);122}123124public void remove() {125reader.remove();126}127}128129130