View Javadoc

    1   package org.codehaus.xfire.util;
    2
    3   import javax.xml.namespace.NamespaceContext;
    4   import javax.xml.namespace.QName;
    5   import javax.xml.stream.Location;
    6   import javax.xml.stream.XMLStreamException;
    7   import javax.xml.stream.XMLStreamReader;
    8
    9   /***
    10   * An XMLStreamReader which keeps track of the depth where we are.
    11   *
    12   * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse </a>
    13   * @since Nov 4, 2004
    14   */
    15  public class DepthXMLStreamReader
    16      implements XMLStreamReader
    17  {
    18      XMLStreamReader reader;
    19
    20      private int depth = 0;
    21
    22      public DepthXMLStreamReader(XMLStreamReader reader)
    23      {
    24          this.reader = reader;
    25      }
    26
    27      public int getDepth()
    28      {
    29          return depth;
    30      }
    31
    32      public void close() throws XMLStreamException
    33      {
    34          reader.close();
    35      }
    36
    37      public int getAttributeCount()
    38      {
    39          return reader.getAttributeCount();
    40      }
    41
    42      public String getAttributeLocalName(int arg0)
    43      {
    44          return reader.getAttributeLocalName(arg0);
    45      }
    46
    47      public QName getAttributeName(int arg0)
    48      {
    49          return reader.getAttributeName(arg0);
    50      }
    51
    52      public String getAttributeNamespace(int arg0)
    53      {
    54          return reader.getAttributeNamespace(arg0);
    55      }
    56
    57      public String getAttributePrefix(int arg0)
    58      {
    59          return reader.getAttributePrefix(arg0);
    60      }
    61
    62      public String getAttributeType(int arg0)
    63      {
    64          return reader.getAttributeType(arg0);
    65      }
    66
    67      public String getAttributeValue(int arg0)
    68      {
    69          return reader.getAttributeValue(arg0);
    70      }
    71
    72      public String getAttributeValue(String arg0, String arg1)
    73      {
    74          return reader.getAttributeValue(arg0, arg1);
    75      }
    76
    77      public String getCharacterEncodingScheme()
    78      {
    79          return reader.getCharacterEncodingScheme();
    80      }
    81
    82      public String getElementText() throws XMLStreamException
    83      {
    84          return reader.getElementText();
    85      }
    86
    87      public String getEncoding()
    88      {
    89          return reader.getEncoding();
    90      }
    91
    92      public int getEventType()
    93      {
    94          return reader.getEventType();
    95      }
    96
    97      public String getLocalName()
    98      {
    99          return reader.getLocalName();
    100     }
    101
    102     public Location getLocation()
    103     {
    104         return reader.getLocation();
    105     }
    106
    107     public QName getName()
    108     {
    109         return reader.getName();
    110     }
    111
    112     public NamespaceContext getNamespaceContext()
    113     {
    114         return reader.getNamespaceContext();
    115     }
    116
    117     public int getNamespaceCount()
    118     {
    119
    120         return reader.getNamespaceCount();
    121     }
    122
    123     public String getNamespacePrefix(int arg0)
    124     {
    125
    126         return reader.getNamespacePrefix(arg0);
    127     }
    128
    129     public String getNamespaceURI()
    130     {
    131
    132         return reader.getNamespaceURI();
    133     }
    134
    135     public String getNamespaceURI(int arg0)
    136     {
    137
    138         return reader.getNamespaceURI(arg0);
    139     }
    140
    141     public String getNamespaceURI(String arg0)
    142     {
    143
    144         return reader.getNamespaceURI(arg0);
    145     }
    146
    147     public String getPIData()
    148     {
    149
    150         return reader.getPIData();
    151     }
    152
    153     public String getPITarget()
    154     {
    155
    156         return reader.getPITarget();
    157     }
    158
    159     public String getPrefix()
    160     {
    161
    162         return reader.getPrefix();
    163     }
    164
    165     public Object getProperty(String arg0) throws IllegalArgumentException
    166     {
    167
    168         return reader.getProperty(arg0);
    169     }
    170
    171     public String getText()
    172     {
    173
    174         return reader.getText();
    175     }
    176
    177     public char[] getTextCharacters()
    178     {
    179         return reader.getTextCharacters();
    180     }
    181
    182     public int getTextCharacters(int arg0, char[] arg1, int arg2, int arg3)
    183             throws XMLStreamException
    184     {
    185         return reader.getTextCharacters(arg0, arg1, arg2, arg3);
    186     }
    187
    188     public int getTextLength()
    189     {
    190         return reader.getTextLength();
    191     }
    192
    193     public int getTextStart()
    194     {
    195
    196         return reader.getTextStart();
    197     }
    198
    199     public String getVersion()
    200     {
    201         return reader.getVersion();
    202     }
    203
    204     public boolean hasName()
    205     {
    206
    207         return reader.hasName();
    208     }
    209
    210     public boolean hasNext() throws XMLStreamException
    211     {
    212         return reader.hasNext();
    213     }
    214
    215     public boolean hasText()
    216     {
    217         return reader.hasText();
    218     }
    219
    220     public boolean isAttributeSpecified(int arg0)
    221     {
    222         return reader.isAttributeSpecified(arg0);
    223     }
    224
    225     public boolean isCharacters()
    226     {
    227
    228         return reader.isCharacters();
    229     }
    230
    231     public boolean isEndElement()
    232     {
    233
    234         return reader.isEndElement();
    235     }
    236
    237     public boolean isStandalone()
    238     {
    239
    240         return reader.isStandalone();
    241     }
    242
    243     public boolean isStartElement()
    244     {
    245
    246         return reader.isStartElement();
    247     }
    248
    249     public boolean isWhiteSpace()
    250     {
    251
    252         return reader.isWhiteSpace();
    253     }
    254
    255     public int next() throws XMLStreamException
    256     {
    257         int next = reader.next();
    258
    259         if ( next == START_ELEMENT )
    260         {
    261             depth++;
    262         }
    263         else if ( next == END_ELEMENT )
    264         {
    265             depth--;
    266         }
    267
    268         return next;
    269     }
    270
    271     public int nextTag() throws XMLStreamException
    272     {
    273         return reader.nextTag();
    274     }
    275
    276     public void require(int arg0, String arg1, String arg2)
    277             throws XMLStreamException
    278     {
    279         reader.require(arg0, arg1, arg2);
    280     }
    281
    282     public boolean standaloneSet()
    283     {
    284         return reader.standaloneSet();
    285     }
    286
    287     public int hashCode()
    288     {
    289         return reader.hashCode();
    290     }
    291
    292     public boolean equals(Object arg0)
    293     {
    294         return reader.equals(arg0);
    295     }
    296
    297     public String toString()
    298     {
    299         return reader.toString();
    300     }
    301
    302 }