Class NodeletParser

java.lang.Object
com.aspectran.utils.nodelet.NodeletParser

public class NodeletParser extends Object
The NodeletParser is a callback based parser similar to SAX. The big difference is that rather than having a single callback for all nodes, the NodeletParser has a number of callbacks mapped to various nodes. The callback is called a Nodelet, and it is registered with the NodeletParser against a specific XPath.
  • Constructor Details

    • NodeletParser

      public NodeletParser(Object nodeParser)
  • Method Details

    • getNodeParser

      public <N> N getNodeParser()
    • setValidating

      public void setValidating(boolean validating)
    • setEntityResolver

      public void setEntityResolver(EntityResolver entityResolver)
    • trackingLocation

      public NodeTracker trackingLocation()
    • getNodeTracker

      public NodeTracker getNodeTracker()
    • getXpath

      public String getXpath()
    • setXpath

      public void setXpath(String xpath)
    • addNodelet

      public void addNodelet(Nodelet nodelet)
      Registers a nodelet to process attributes for the specified XPath. It supports the following XPaths:
      • Element Path - /rootElement/childElement/theElement
      Parameters:
      nodelet - the nodelet for processing start elements and attributes
    • addEndNodelet

      public void addEndNodelet(EndNodelet nodelet)
      Registers the nodelet to process the end elements of the specified XPath and the text and CDATA data collected.
      Parameters:
      nodelet - the nodelet for processing end elements, text and CDATA data collected
    • addNodelet

      public void addNodelet(SubnodeParser subnodeParser)
      Adds the nodelet.
      Parameters:
      subnodeParser - the subnode parser
    • addNodelet

      public void addNodelet(String xpath, @NonNull SubnodeParser subnodeParser)
      Add nodelets through the subnode parser.
      Parameters:
      xpath - the xpath
      subnodeParser - the subnode parser
    • pushObject

      public void pushObject(Object object)
    • popObject

      public <T> T popObject()
    • peekObject

      public <T> T peekObject()
    • peekObject

      public <T> T peekObject(int n)
    • peekObject

      public <T> T peekObject(Class<?> target)
    • clearObjectStack

      public void clearObjectStack()
      Clear object stack.
    • parse

      public void parse(Reader reader) throws NodeletException
      Begins parsing from the provided Reader.
      Parameters:
      reader - the reader
      Throws:
      NodeletException - the nodelet exception
    • parse

      public void parse(InputStream inputStream) throws NodeletException
      Begins parsing from the provided InputStream.
      Parameters:
      inputStream - the input stream
      Throws:
      NodeletException - the nodelet exception
    • parse

      public void parse(InputSource inputSource) throws NodeletException
      Begins parsing from the provided InputSource.
      Parameters:
      inputSource - the input source
      Throws:
      NodeletException - the nodelet exception