Class InvisibleXmlDocument

  • Direct Known Subclasses:
    InvisibleXmlFailureDocument

    public class InvisibleXmlDocument
    extends java.lang.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 Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.nineml.coffeegrinder.trees.TreeBuilder getAdapter​(org.xml.sax.ContentHandler handler)
      Returns an adapter for SAX ContentHandlers.
      int getColumnNumber()
      Get the column number of the last line processed.
      int getLineNumber()
      Get the line number of the last line processed.
      long getNumberOfParses()
      Return the number of available parses of this document.
      int getOffset()
      Get the offset of the last character processed.
      ParserOptions getOptions()
      Get the parser options.
      org.nineml.coffeegrinder.parser.ParserType getParserType()
      Return the parser type.
      java.lang.String getParserVersion()
      Get the parser version.
      org.nineml.coffeegrinder.parser.GearleyResult getResult()
      Return the underlying GearleyResult result for this parse.
      java.lang.String getTree()
      Return an XML representation of the current parse.
      void getTree​(java.io.PrintStream output)
      Write an XML representation of the current parse to the stream.
      void getTree​(org.nineml.coffeegrinder.trees.TreeBuilder builder)
      Process the result with your own TreeBuilder.
      void getTree​(org.xml.sax.ContentHandler handler)
      Write an XML representation of the current parse to a SAX ContentHandler.
      void getTree​(org.xml.sax.ContentHandler handler, ParserOptions options)
      Write an XML representation of the current parse to a SAX ContentHandler using a different set of options.
      boolean isAmbiguous()
      Is this document ambiguous?
      boolean isInfinitelyAmbiguous()
      Is this document infinitely ambiguous?
      long parseTime()
      Returns the amount of time (roughly) spent parsing.
      boolean succeeded()
      Did the parse succeed?
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getParserVersion

        public java.lang.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​(org.xml.sax.ContentHandler handler)
        Returns an adapter for SAX ContentHandlers.
        Parameters:
        handler - the content handler
        Returns:
        an adapting tree builder
      • getTree

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

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

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

        public void getTree​(org.xml.sax.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.