Class XppReader

All Implemented Interfaces:
ErrorReporter, ExtendedHierarchicalStreamReader, HierarchicalStreamReader

public class XppReader extends AbstractPullReader
XStream reader that pulls directly from the stream using the XmlPullParser API.
  • Field Details

    • parser

      private final org.xmlpull.v1.XmlPullParser parser
    • reader

      private final Reader reader
  • Constructor Details

    • XppReader

      public XppReader(Reader reader, org.xmlpull.v1.XmlPullParser parser)
      Construct an XppReader.
      Parameters:
      reader - the reader with the input data
      parser - the XPP parser to use
      Since:
      1.4
    • XppReader

      public XppReader(Reader reader, org.xmlpull.v1.XmlPullParser parser, NameCoder nameCoder)
      Construct an XppReader.
      Parameters:
      reader - the reader with the input data
      parser - the XPP parser to use
      nameCoder - the coder for XML friendly tag and attribute names
      Since:
      1.4
    • XppReader

      public XppReader(Reader reader)
      Deprecated.
      As of 1.4, use XppReader(Reader, XmlPullParser) instead
    • XppReader

      public XppReader(Reader reader, XmlFriendlyReplacer replacer)
      Deprecated.
      Since:
      1.2
  • Method Details

    • createParser

      protected org.xmlpull.v1.XmlPullParser createParser()
      Deprecated.
      As of 1.4, use XppReader(Reader, XmlPullParser) instead
      To use another implementation of org.xmlpull.v1.XmlPullParser, override this method.
    • pullNextEvent

      protected int pullNextEvent()
      Description copied from class: AbstractPullReader
      Pull the next event from the stream.

      This MUST return AbstractPullReader.START_NODE, AbstractPullReader.END_NODE, AbstractPullReader.TEXT, AbstractPullReader.COMMENT, AbstractPullReader.OTHER or throw StreamException.

      The underlying pull parser will most likely return its own event types. These must be mapped to the appropriate events.

      Specified by:
      pullNextEvent in class AbstractPullReader
    • pullElementName

      protected String pullElementName()
      Description copied from class: AbstractPullReader
      Pull the name of the current element from the stream.
      Specified by:
      pullElementName in class AbstractPullReader
    • pullText

      protected String pullText()
      Description copied from class: AbstractPullReader
      Pull the contents of the current text node from the stream.
      Specified by:
      pullText in class AbstractPullReader
    • getAttribute

      public String getAttribute(String name)
      Description copied from interface: HierarchicalStreamReader
      Get the value of an attribute of the current node.

      If no such attribute exists, the method returns null.

    • getAttribute

      public String getAttribute(int index)
      Description copied from interface: HierarchicalStreamReader
      Get the value of an attribute of the current node, by index.

      Note, the behavior of this method is dependent on the underlying parser when calling it with a non-existing index. Typically some kind of RuntimeException is thrown.

    • getAttributeCount

      public int getAttributeCount()
      Description copied from interface: HierarchicalStreamReader
      Number of attributes in current node.
    • getAttributeName

      public String getAttributeName(int index)
      Description copied from interface: HierarchicalStreamReader
      Name of attribute in current node.

      Note, the behavior of this method is dependent on the underlying parser when calling it with a non-existing index. Typically some kind of RuntimeException is thrown.

    • appendErrors

      public void appendErrors(ErrorWriter errorWriter)
      Description copied from interface: HierarchicalStreamReader
      If any errors are detected, allow the reader to add any additional information that can aid debugging (such as line numbers, XPath expressions, etc).
      Parameters:
      errorWriter - the error writer
    • close

      public void close()
      Description copied from interface: HierarchicalStreamReader
      Close the reader, if necessary.