Class Parser

Direct Known Subclasses:
DirParser, DOMWrapper, SingleParser

public abstract class Parser extends Job
This class defines a parser, which is used to create new databases instances.
Author:
BaseX Team 2005-21, BSD License, Christian Gruen
  • Field Details

    • source

      public IO source
      Source document or null.
    • atts

      protected final Atts atts
      Attributes of currently parsed element.
    • nsp

      protected final Atts nsp
      Namespaces of currently parsed element.
    • options

      protected final MainOptions options
      Main options.
  • Constructor Details

    • Parser

      protected Parser(String source, MainOptions options)
      Constructor.
      Parameters:
      source - document source or null
      options - main options
    • Parser

      protected Parser(IO source, MainOptions options)
      Constructor.
      Parameters:
      source - document source or null
      options - main options
  • Method Details

    • parse

      public abstract void parse(Builder build) throws IOException
      Parses all nodes and sends events to the specified builder.
      Parameters:
      build - database builder
      Throws:
      IOException - I/O exception
    • close

      public void close() throws IOException
      Closes the parser.
      Throws:
      IOException - I/O exception
    • info

      public String info()
      Returns parser information.
      Returns:
      info string
    • target

      public Parser target(String path)
      Sets the target path.
      Parameters:
      path - target path
      Returns:
      self reference
    • emptyParser

      public static Parser emptyParser(MainOptions options)
      Returns a parser instance for creating empty databases.
      Parameters:
      options - database options
      Returns:
      parser
    • xmlParser

      public static SAXWrapper xmlParser(IO source)
      Returns an XML parser instance, using the Java default parser.
      Parameters:
      source - input source
      Returns:
      xml parser
    • singleParser

      public static SingleParser singleParser(IO source, MainOptions options, String target) throws IOException
      Returns a parser instance, based on the current options.
      Parameters:
      source - input source
      options - database options
      target - relative path reference
      Returns:
      parser
      Throws:
      IOException - I/O exception