Class InvisibleXmlParser


  • public class InvisibleXmlParser
    extends java.lang.Object
    A parser for a particular Invisible XML grammar.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String logcategory  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean constructed()
      Did the grammar parse succeed?
      java.lang.Exception getException()
      Return the exception that caused an attempt to build a parser to fail.
      InvisibleXmlDocument getFailedParse()
      If the attempt to parse the grammar failed, return a representation of that failure.
      org.nineml.coffeegrinder.parser.SourceGrammar getGrammar()
      Get the underlying grammar
      org.nineml.coffeegrinder.parser.HygieneReport getHygieneReport()
      Get the hygiene report for this parser's grammar
      java.lang.String getIxmlVersion()  
      java.util.Map<java.lang.String,​java.util.List<java.lang.String>> getMetadata()
      Get metadata.
      ParserOptions getOptions()
      Get the parser options.
      long getParseTime()
      Get the time spent parsing the input grammar.
      java.util.List<org.nineml.coffeefilter.model.IPragma> getPragmas()
      Get the pragmas associated with this parser.
      InvisibleXmlDocument parse​(java.io.File source)
      Get a document from a file.
      InvisibleXmlDocument parse​(java.io.File source, java.lang.String encoding)
      Get a document from a file with an explicit encoding.
      InvisibleXmlDocument parse​(java.io.InputStream stream, java.lang.String encoding)
      Get a document from a stream.
      InvisibleXmlDocument parse​(java.lang.String input)
      Get a document from a string.
      InvisibleXmlDocument parse​(java.net.URI source)
      Get a document from a URI.
      InvisibleXmlDocument parse​(java.net.URI source, java.lang.String encoding)
      Get a document from a URI with an explicit encoding.
      InvisibleXmlDocument parse​(org.nineml.coffeegrinder.tokens.Token[] input)
      Get a document from an array of tokens.
      java.lang.String readInputStream​(java.io.InputStream stream, java.lang.String charset)  
      • Methods inherited from class java.lang.Object

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

      • getIxmlVersion

        public java.lang.String getIxmlVersion()
      • getOptions

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

        public java.util.Map<java.lang.String,​java.util.List<java.lang.String>> getMetadata()
        Get metadata.

        Pragmas in the prolog that aren't recognized by the processor are returned as "data" pragmas associating a URI with (a list of) values.

        Returns:
        the metadata
      • getPragmas

        public java.util.List<org.nineml.coffeefilter.model.IPragma> getPragmas()
        Get the pragmas associated with this parser.
        Returns:
        the list of pragmas.
      • getException

        public java.lang.Exception getException()
        Return the exception that caused an attempt to build a parser to fail.

        If the attempt was successful, or if failure did not raise an exception, null will be returned.

        Returns:
        the exception, or null if no exception is available
      • getParseTime

        public long getParseTime()
        Get the time spent parsing the input grammar.

        This returns the number of milliseconds of "wall clock time" spent by the processor constructing this parser.

        Returns:
        the time in milliseconds
      • constructed

        public boolean constructed()
        Did the grammar parse succeed?
        Returns:
        true if the parse succeeded
      • getHygieneReport

        public org.nineml.coffeegrinder.parser.HygieneReport getHygieneReport()
        Get the hygiene report for this parser's grammar
        Returns:
        the hygiene report
      • getFailedParse

        public InvisibleXmlDocument getFailedParse()
        If the attempt to parse the grammar failed, return a representation of that failure.
        Returns:
        The failed parse, or null if the parse succeeded.
      • parse

        public InvisibleXmlDocument parse​(java.net.URI source)
                                   throws java.io.IOException
        Get a document from a URI.

        Attempts to read from the URI with source.toURL().openConnection(). Assumes the input is in UTF-8.

        Parameters:
        source - the source
        Returns:
        a document
        Throws:
        java.io.IOException - If the source cannot be read
        java.lang.NullPointerException - if this parser has no grammar
      • parse

        public InvisibleXmlDocument parse​(java.io.File source)
                                   throws java.io.IOException
        Get a document from a file.

        Assumes the input is in UTF-8.

        Parameters:
        source - the source
        Returns:
        a document
        Throws:
        java.io.IOException - If the source cannot be read
        java.lang.NullPointerException - if this parser has no grammar
      • parse

        public InvisibleXmlDocument parse​(java.net.URI source,
                                          java.lang.String encoding)
                                   throws java.io.IOException
        Get a document from a URI with an explicit encoding.

        Attempts to read from the URI with source.toURL().openConnection().

        Parameters:
        source - the source
        encoding - the encoding
        Returns:
        a document
        Throws:
        java.io.IOException - If the stream cannot be read or if the character set is unsupported.
        java.lang.NullPointerException - if this parser has no grammar
      • parse

        public InvisibleXmlDocument parse​(java.io.File source,
                                          java.lang.String encoding)
                                   throws java.io.IOException
        Get a document from a file with an explicit encoding.
        Parameters:
        source - the source
        encoding - the encoding
        Returns:
        a document
        Throws:
        java.io.IOException - If the stream cannot be read or if the character set is unsupported.
        java.lang.NullPointerException - if this parser has no grammar
      • parse

        public InvisibleXmlDocument parse​(java.io.InputStream stream,
                                          java.lang.String encoding)
                                   throws java.io.IOException
        Get a document from a stream.
        Parameters:
        stream - The input.
        encoding - The input encoding.
        Returns:
        A document.
        Throws:
        java.io.IOException - If the stream cannot be read or if the character set is unsupported.
        java.lang.NullPointerException - if this parser has no grammar
      • parse

        public InvisibleXmlDocument parse​(java.lang.String input)
        Get a document from a string.
        Parameters:
        input - The input.
        Returns:
        A document.
        Throws:
        java.lang.NullPointerException - if this parser has no grammar
      • parse

        public InvisibleXmlDocument parse​(org.nineml.coffeegrinder.tokens.Token[] input)
        Get a document from an array of tokens.
        Parameters:
        input - The input.
        Returns:
        A document.
        Throws:
        java.lang.NullPointerException - if this parser has no grammar
      • getGrammar

        public org.nineml.coffeegrinder.parser.SourceGrammar getGrammar()
        Get the underlying grammar
        Returns:
        the underlying CoffeeGrinder grammar
        Throws:
        java.lang.NullPointerException - if this parser has no grammar
      • readInputStream

        public java.lang.String readInputStream​(java.io.InputStream stream,
                                                java.lang.String charset)
                                         throws java.io.IOException
        Throws:
        java.io.IOException