Class PullReader

java.lang.Object
org.simpleframework.xml.stream.PullReader
All Implemented Interfaces:
EventReader

class PullReader extends Object implements EventReader
The PullReader is used to provide an event reader thats makes use of the XML pull API. This provides the best performance on the Google Android platform. Providing support for the XML pull API ensures that a full DOM model does not need to be build for large documents. It also ensures that line numbers are available when each event is extracted.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private static class 
    The End object is used to represent the end of an element.
    private static class 
    The Entry object is used to represent an attribute within a start element.
    private static class 
    The Start object is used to represent the start of an XML element.
    private static class 
    The Text object is used to represent a text event.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private org.xmlpull.v1.XmlPullParser
    This is the XML pull parser that is used to create events.
    private EventNode
    This is the previous node that has been read by a peek.
  • Constructor Summary

    Constructors
    Constructor
    Description
    PullReader(org.xmlpull.v1.XmlPullParser parser)
    Constructor for the PullReader object.
  • Method Summary

    Modifier and Type
    Method
    Description
    attribute(int index)
    This is used to convert the provided object to an attribute.
    This is used to build the attributes that are to be used to populate the start event.
    end()
    This is used to create an event to signify that an element has just ended.
    This is used to take the next node from the document.
    This is used to peek at the node from the document.
    private EventNode
    This is used to read the next node from the document.
    This is used to convert the next event to a start event.
    This is used to convert the next event to a text event.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • parser

      private org.xmlpull.v1.XmlPullParser parser
      This is the XML pull parser that is used to create events.
    • peek

      private EventNode peek
      This is the previous node that has been read by a peek.
  • Constructor Details

    • PullReader

      public PullReader(org.xmlpull.v1.XmlPullParser parser)
      Constructor for the PullReader object. This is provided an XML pull parser which has been initialized with the XML source document. Each even produced by this reader will be extracted from the provided XML pull parser.
      Parameters:
      parser - this is the parser used to create all events
  • Method Details

    • peek

      public EventNode peek() throws Exception
      This is used to peek at the node from the document. This will scan through the document, ignoring any comments to find the next relevant XML event to acquire. Typically events will be the start and end of an element, as well as any text nodes.
      Specified by:
      peek in interface EventReader
      Returns:
      this returns the next event taken from the source XML
      Throws:
      Exception
    • next

      public EventNode next() throws Exception
      This is used to take the next node from the document. This will scan through the document, ignoring any comments to find the next relevant XML event to acquire. Typically events will be the start and end of an element, as well as any text nodes.
      Specified by:
      next in interface EventReader
      Returns:
      this returns the next event taken from the source XML
      Throws:
      Exception
    • read

      private EventNode read() throws Exception
      This is used to read the next node from the document. This will scan through the document, ignoring any comments to find the next relevant XML event to acquire. Typically events will be the start and end of an element, as well as any text nodes.
      Returns:
      this returns the next event taken from the document
      Throws:
      Exception
    • text

      private PullReader.Text text() throws Exception
      This is used to convert the next event to a text event. The conversion process ensures the node can be digested by the core reader and used to provide an InputNode that can be used to represent an XML attribute within the source document.
      Returns:
      this returns the text event from the XML pull parser
      Throws:
      Exception
    • start

      private PullReader.Start start() throws Exception
      This is used to convert the next event to a start event. The conversion process ensures the node can be digested by the core reader and used to provide an InputNode that can be used to represent an XML elements within the source document.
      Returns:
      this returns a start event created from the parser
      Throws:
      Exception
    • build

      private PullReader.Start build(PullReader.Start event) throws Exception
      This is used to build the attributes that are to be used to populate the start event. Populating the start event with the attributes it contains is required so that each element will contain its associated attributes. Only attributes that are not reserved will be added to the start event.
      Parameters:
      event - this is the start event that is to be populated
      Returns:
      this returns a start event with its attributes
      Throws:
      Exception
    • attribute

      private PullReader.Entry attribute(int index) throws Exception
      This is used to convert the provided object to an attribute. The conversion process ensures the node can be digested by the core reader and used to provide an InputNode that can be used to represent an XML attribute within the source document.
      Parameters:
      index - this is the index of this attribute to create
      Returns:
      this returns an attribute created from the given object
      Throws:
      Exception
    • end

      private PullReader.End end() throws Exception
      This is used to create an event to signify that an element has just ended. End events are important as they allow the core reader to determine if a node is still in context. This provides a more convenient way to use InputNode objects as they should only ever be able to extract their children.
      Returns:
      this returns an end event to signify an element close
      Throws:
      Exception