Source for javax.xml.stream.util.StreamReaderDelegate

   1: /* StreamReaderDelegate.java --
   2:    Copyright (C) 2005,2006,2009  Free Software Foundation, Inc.
   3: 
   4: This file is part of GNU Classpath.
   5: 
   6: GNU Classpath is free software; you can redistribute it and/or modify
   7: it under the terms of the GNU General Public License as published by
   8: the Free Software Foundation; either version 2, or (at your option)
   9: any later version.
  10: 
  11: GNU Classpath is distributed in the hope that it will be useful, but
  12: WITHOUT ANY WARRANTY; without even the implied warranty of
  13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14: General Public License for more details.
  15: 
  16: You should have received a copy of the GNU General Public License
  17: along with GNU Classpath; see the file COPYING.  If not, write to the
  18: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  19: 02110-1301 USA.
  20: 
  21: Linking this library statically or dynamically with other modules is
  22: making a combined work based on this library.  Thus, the terms and
  23: conditions of the GNU General Public License cover the whole
  24: combination.
  25: 
  26: As a special exception, the copyright holders of this library give you
  27: permission to link this library with independent modules to produce an
  28: executable, regardless of the license terms of these independent
  29: modules, and to copy and distribute the resulting executable under
  30: terms of your choice, provided that you also meet, for each linked
  31: independent module, the terms and conditions of the license of that
  32: module.  An independent module is a module which is not derived from
  33: or based on this library.  If you modify this library, you may extend
  34: this exception to your version of the library, but you are not
  35: obligated to do so.  If you do not wish to do so, delete this
  36: exception statement from your version. */
  37: 
  38: package javax.xml.stream.util;
  39: 
  40: import javax.xml.namespace.NamespaceContext;
  41: import javax.xml.namespace.QName;
  42: import javax.xml.stream.Location;
  43: import javax.xml.stream.XMLStreamConstants;
  44: import javax.xml.stream.XMLStreamException;
  45: import javax.xml.stream.XMLStreamReader;
  46: 
  47: /**
  48:  * Base class for XML stream reader filters.
  49:  */
  50: public class StreamReaderDelegate
  51:   implements XMLStreamReader, XMLStreamConstants
  52: {
  53: 
  54:   private XMLStreamReader parent;
  55: 
  56:   /**
  57:    * Constructs an empty filter with no parent set.
  58:    */
  59:   public StreamReaderDelegate()
  60:   {
  61:   }
  62: 
  63:   /**
  64:    * Constructs an empty filter with the specfied parent.
  65:    */
  66:   public StreamReaderDelegate(XMLStreamReader reader)
  67:   {
  68:     parent = reader;
  69:   }
  70: 
  71:   /**
  72:    * Sets the parent.
  73:    */
  74:   public void setParent(XMLStreamReader reader)
  75:   {
  76:     parent = reader;
  77:   }
  78: 
  79:   /**
  80:    * Returns the parent.
  81:    */
  82:   public XMLStreamReader getParent()
  83:   {
  84:     return parent;
  85:   }
  86: 
  87:   public int next()
  88:     throws XMLStreamException
  89:   {
  90:     if (parent != null)
  91:       return parent.next();
  92:     throw new XMLStreamException();
  93:   }
  94: 
  95:   public int nextTag()
  96:     throws XMLStreamException
  97:   {
  98:     if (parent != null)
  99:       return parent.nextTag();
 100:     throw new XMLStreamException();
 101:   }
 102: 
 103:   public String getElementText()
 104:     throws XMLStreamException
 105:   {
 106:     if (parent != null)
 107:       return parent.getElementText();
 108:     throw new XMLStreamException();
 109:   }
 110: 
 111:   public void require(int type, String namespaceURI, String localName)
 112:     throws XMLStreamException
 113:   {
 114:     if (parent != null)
 115:       parent.require(type, namespaceURI, localName);
 116:   }
 117: 
 118:   public boolean hasNext()
 119:     throws XMLStreamException
 120:   {
 121:     if (parent != null)
 122:       return parent.hasNext();
 123:     return false;
 124:   }
 125: 
 126:   public void close()
 127:     throws XMLStreamException
 128:   {
 129:     if (parent != null)
 130:       parent.close();
 131:   }
 132: 
 133:   public String getNamespaceURI(String prefix)
 134:   {
 135:     if (parent != null)
 136:       return parent.getNamespaceURI(prefix);
 137:     return null;
 138:   }
 139: 
 140:   public NamespaceContext getNamespaceContext()
 141:   {
 142:     if (parent != null)
 143:       return parent.getNamespaceContext();
 144:     return null;
 145:   }
 146: 
 147:   public boolean isStartElement()
 148:   {
 149:     if (parent != null)
 150:       return parent.isStartElement();
 151:     return false;
 152:   }
 153: 
 154:   public boolean isEndElement()
 155:   {
 156:     if (parent != null)
 157:       return parent.isEndElement();
 158:     return false;
 159:   }
 160: 
 161:   public boolean isCharacters()
 162:   {
 163:     if (parent != null)
 164:       return parent.isCharacters();
 165:     return false;
 166:   }
 167: 
 168:   public boolean isWhiteSpace()
 169:   {
 170:     if (parent != null)
 171:       return parent.isWhiteSpace();
 172:     return false;
 173:   }
 174: 
 175:   public String getAttributeValue(String namespaceUri, String localName)
 176:   {
 177:     if (parent != null)
 178:       return parent.getAttributeValue(namespaceUri, localName);
 179:     return null;
 180:   }
 181: 
 182:   public int getAttributeCount()
 183:   {
 184:     if (parent != null)
 185:       return parent.getAttributeCount();
 186:     return 0;
 187:   }
 188: 
 189:   public QName getAttributeName(int index)
 190:   {
 191:     if (parent != null)
 192:       return parent.getAttributeName(index);
 193:     return null;
 194:   }
 195: 
 196:   public String getAttributePrefix(int index)
 197:   {
 198:     if (parent != null)
 199:       return parent.getAttributePrefix(index);
 200:     return null;
 201:   }
 202: 
 203:   public String getAttributeNamespace(int index)
 204:   {
 205:     if (parent != null)
 206:       return parent.getAttributeNamespace(index);
 207:     return null;
 208:   }
 209: 
 210:   public String getAttributeLocalName(int index)
 211:   {
 212:     if (parent != null)
 213:       return parent.getAttributeLocalName(index);
 214:     return null;
 215:   }
 216: 
 217:   public String getAttributeType(int index)
 218:   {
 219:     if (parent != null)
 220:       return parent.getAttributeType(index);
 221:     return null;
 222:   }
 223: 
 224:   public String getAttributeValue(int index)
 225:   {
 226:     if (parent != null)
 227:       return parent.getAttributeValue(index);
 228:     return null;
 229:   }
 230: 
 231:   public boolean isAttributeSpecified(int index)
 232:   {
 233:     if (parent != null)
 234:       return parent.isAttributeSpecified(index);
 235:     return false;
 236:   }
 237: 
 238:   public int getNamespaceCount()
 239:   {
 240:     if (parent != null)
 241:       return parent.getNamespaceCount();
 242:     return 0;
 243:   }
 244: 
 245:   public String getNamespacePrefix(int index)
 246:   {
 247:     if (parent != null)
 248:       return parent.getNamespacePrefix(index);
 249:     return null;
 250:   }
 251: 
 252:   public String getNamespaceURI(int index)
 253:   {
 254:     if (parent != null)
 255:       return parent.getNamespaceURI(index);
 256:     return null;
 257:   }
 258: 
 259:   public int getEventType()
 260:   {
 261:     if (parent != null)
 262:       return parent.getEventType();
 263:     return 0;
 264:   }
 265: 
 266:   public String getText()
 267:   {
 268:     if (parent != null)
 269:       return parent.getText();
 270:     return null;
 271:   }
 272: 
 273:   public int getTextCharacters(int sourceStart, char[] target,
 274:                                int targetStart, int length)
 275:     throws XMLStreamException
 276:   {
 277:     if (parent != null)
 278:       return parent.getTextCharacters(sourceStart, target, targetStart, length);
 279:     return 0;
 280:   }
 281: 
 282:   public char[] getTextCharacters()
 283:   {
 284:     if (parent != null)
 285:       return parent.getTextCharacters();
 286:     return null;
 287:   }
 288: 
 289:   public int getTextStart()
 290:   {
 291:     if (parent != null)
 292:       return parent.getTextStart();
 293:     return 0;
 294:   }
 295: 
 296:   public int getTextLength()
 297:   {
 298:     if (parent != null)
 299:       return parent.getTextLength();
 300:     return 0;
 301:   }
 302: 
 303:   public String getEncoding()
 304:   {
 305:     if (parent != null)
 306:       return parent.getEncoding();
 307:     return null;
 308:   }
 309: 
 310:   public boolean hasText()
 311:   {
 312:     if (parent != null)
 313:       return parent.hasText();
 314:     return false;
 315:   }
 316: 
 317:   public Location getLocation()
 318:   {
 319:     if (parent != null)
 320:       return parent.getLocation();
 321:     return null;
 322:   }
 323: 
 324:   public QName getName()
 325:   {
 326:     if (parent != null)
 327:       return parent.getName();
 328:     return null;
 329:   }
 330: 
 331:   public String getLocalName()
 332:   {
 333:     if (parent != null)
 334:       return parent.getLocalName();
 335:     return null;
 336:   }
 337: 
 338:   public boolean hasName()
 339:   {
 340:     if (parent != null)
 341:       return parent.hasName();
 342:     return false;
 343:   }
 344: 
 345:   public String getNamespaceURI()
 346:   {
 347:     if (parent != null)
 348:       return parent.getNamespaceURI();
 349:     return null;
 350:   }
 351: 
 352:   public String getPrefix()
 353:   {
 354:     if (parent != null)
 355:       return parent.getPrefix();
 356:     return null;
 357:   }
 358: 
 359:   public String getVersion()
 360:   {
 361:     if (parent != null)
 362:       return parent.getVersion();
 363:     return null;
 364:   }
 365: 
 366:   public boolean isStandalone()
 367:   {
 368:     if (parent != null)
 369:       return parent.isStandalone();
 370:     return false;
 371:   }
 372: 
 373:   public boolean standaloneSet()
 374:   {
 375:     if (parent != null)
 376:       return parent.standaloneSet();
 377:     return false;
 378:   }
 379: 
 380:   public String getCharacterEncodingScheme()
 381:   {
 382:     if (parent != null)
 383:       return parent.getCharacterEncodingScheme();
 384:     return null;
 385:   }
 386: 
 387:   public String getPITarget()
 388:   {
 389:     if (parent != null)
 390:       return parent.getPITarget();
 391:     return null;
 392:   }
 393: 
 394:   public String getPIData()
 395:   {
 396:     if (parent != null)
 397:       return parent.getPIData();
 398:     return null;
 399:   }
 400: 
 401:   public Object getProperty(String name)
 402:   {
 403:     if (parent != null)
 404:       return parent.getProperty(name);
 405:     throw new IllegalArgumentException();
 406:   }
 407: 
 408: }