Class InvisibleXmlDocument

java.lang.Object
org.nineml.coffeefilter.InvisibleXmlDocument
Direct Known Subclasses:
InvisibleXmlFailureDocument

public class InvisibleXmlDocument extends Object
An InvisibleXmlDocument represents a document created with an InvisibleXmlParser.

From this object, you can obtain the parsed representation(s) of the document. For ambiguous grammars, there may be more than one.

  • Method Details

    • getParserVersion

      public String getParserVersion()
      Get the parser version.
      Returns:
      the parser version
    • getOptions

      public ParserOptions getOptions()
      Get the parser options.
      Returns:
      the parser options
    • getLineNumber

      public int getLineNumber()
      Get the line number of the last line processed.

      If the parse failed, this will be the line on which the error occurred. Lines are counted by occurrence of '\n'.

      Returns:
      the line number
    • getColumnNumber

      public int getColumnNumber()
      Get the column number of the last line processed.

      If the parse failed, this will be the position of the character in the last line where the error occurred.

      Returns:
      the column number
    • getOffset

      public int getOffset()
      Get the offset of the last character processed.

      If the parse failed, this will be the position of the character in the input stream.

      Returns:
      the offset
    • getResult

      public org.nineml.coffeegrinder.parser.GearleyResult getResult()
      Return the underlying GearleyResult result for this parse.
      Returns:
      the result
    • getParserType

      public org.nineml.coffeegrinder.parser.ParserType getParserType()
      Return the parser type.
      Returns:
      the parser type
    • succeeded

      public boolean succeeded()
      Did the parse succeed?
      Returns:
      true if the parse was successful
    • getNumberOfParses

      public long getNumberOfParses()
      Return the number of available parses of this document.

      Will return 0 if there are no successful parses.

      Returns:
      The number of parses.
    • isAmbiguous

      public boolean isAmbiguous()
      Is this document ambiguous?

      The return value is arbitrary if the parse did not succeed.

      Returns:
      true, if the document is ambiguous
    • isInfinitelyAmbiguous

      public boolean isInfinitelyAmbiguous()
      Is this document infinitely ambiguous?

      The return value is arbitrary if the parse did not succeed.

      Returns:
      true, if the document is ambiguous
    • parseTime

      public long parseTime()
      Returns the amount of time (roughly) spent parsing.
      Returns:
      The number of milliseconds spent parsing.
    • getAdapter

      public org.nineml.coffeegrinder.trees.TreeBuilder getAdapter(ContentHandler handler)
      Returns an adapter for SAX ContentHandlers.
      Parameters:
      handler - the content handler
      Returns:
      an adapting tree builder
    • getTree

      public String getTree()
      Return an XML representation of the current parse.
      Returns:
      the XML.
      Throws:
      IxmlException - if the parse failed
    • getTree

      public void getTree(PrintStream output)
      Write an XML representation of the current parse to the stream.
      Parameters:
      output - the output stream.
    • getTree

      public void getTree(ContentHandler handler)
      Write an XML representation of the current parse to a SAX ContentHandler.
      Parameters:
      handler - the content handler.
    • getTree

      public void getTree(ContentHandler handler, ParserOptions options)
      Write an XML representation of the current parse to a SAX ContentHandler using a different set of options.
      Parameters:
      handler - the content handler.
      options - the options.
    • getTree

      public void getTree(org.nineml.coffeegrinder.trees.TreeBuilder builder)
      Process the result with your own TreeBuilder.

      This API needs work.

      Parameters:
      builder - the tree builder.