1 /*
   2  * Copyright (c) 2009, 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 
  26 package javax.xml.stream.util;
  27 
  28 import javax.xml.stream.XMLEventReader;
  29 import javax.xml.stream.events.XMLEvent;
  30 import javax.xml.stream.XMLStreamException;
  31 
  32 /**
  33  * This is the base class for deriving an XMLEventReader
  34  * filter.
  35  *
  36  * This class is designed to sit between an XMLEventReader and an
  37  * application's XMLEventReader.  By default each method
  38  * does nothing but call the corresponding method on the
  39  * parent interface.
  40  *
  41  * @version 1.0
  42  * @author Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.
  43  * @see javax.xml.stream.XMLEventReader
  44  * @see StreamReaderDelegate
  45  * @since 1.6
  46  */
  47 
  48 public class EventReaderDelegate implements XMLEventReader {
  49   private XMLEventReader reader;
  50 
  51   /**
  52    * Construct an empty filter with no parent.
  53    */
  54   public EventReaderDelegate(){}
  55 
  56   /**
  57    * Construct an filter with the specified parent.
  58    * @param reader the parent
  59    */
  60   public EventReaderDelegate(XMLEventReader reader) {
  61     this.reader = reader;
  62   }
  63 
  64   /**
  65    * Set the parent of this instance.
  66    * @param reader the new parent
  67    */
  68   public void setParent(XMLEventReader reader) {
  69     this.reader = reader;
  70   }
  71 
  72   /**
  73    * Get the parent of this instance.
  74    * @return the parent or null if none is set
  75    */
  76   public XMLEventReader getParent() {
  77     return reader;
  78   }
  79 
  80   public XMLEvent nextEvent()
  81     throws XMLStreamException
  82   {
  83     return reader.nextEvent();
  84   }
  85 
  86   public Object next() {
  87     return reader.next();
  88   }
  89 
  90   public boolean hasNext()
  91   {
  92     return reader.hasNext();
  93   }
  94 
  95   public XMLEvent peek()
  96     throws XMLStreamException
  97   {
  98     return reader.peek();
  99   }
 100 
 101   public void close()
 102     throws XMLStreamException
 103   {
 104     reader.close();
 105   }
 106 
 107   public String getElementText()
 108     throws XMLStreamException
 109   {
 110     return reader.getElementText();
 111   }
 112 
 113   public XMLEvent nextTag()
 114     throws XMLStreamException
 115   {
 116     return reader.nextTag();
 117   }
 118 
 119   public Object getProperty(java.lang.String name)
 120     throws java.lang.IllegalArgumentException
 121   {
 122     return reader.getProperty(name);
 123   }
 124 
 125   public void remove() {
 126     reader.remove();
 127   }
 128 }