Class InvisibleXml


  • public class InvisibleXml
    extends java.lang.Object
    A static class for constructing instances of Invisible XML grammars.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String AMBIGUOUS
      The iXML "ambiguous" state .
      static java.lang.String CSV_HEADING_ATTRIBUTE  
      static java.lang.String DISCARD_ATTRIBUTE
      The internal name for the discard parser attribute.
      static java.lang.String INSERTION_ATTRIBUTE
      The internal name for the insertion parser attribute.
      static java.lang.String IXML_10  
      static java.lang.String IXML_10_NINEML  
      static java.lang.String IXML_11  
      static java.lang.String IXML_11_NINEML  
      static java.lang.String ixml_ns
      The Invisible XML namespace URI.
      static java.lang.String ixml_prefix
      The namespace prefix for the Invisilble XML namespace.
      static java.lang.String logcategory
      The category name used for InvisibleXml log messages.
      static java.lang.String MARK_ATTRIBUTE
      The internal name for the mark parser attribute.
      static java.lang.String NAME_ATTRIBUTE
      The internal name for the name parser attribute.
      static java.lang.String nineml_ns
      THe NineML namespace URI.
      static java.lang.String nineml_prefix
      The namespace prefix for the NineML namespace.
      static java.lang.String TMARK_ATTRIBUTE
      The internal name for the tmark parser attribute.
      static java.lang.String VERSION_MISMATCH
      The iXML "version-mismatch" state.
      static java.lang.String XMLNS_ATTRIBUTE
      The internal name for the xmlns parser attribute.
    • Constructor Summary

      Constructors 
      Constructor Description
      InvisibleXml()
      Creates a new InvisibleXml object (with default options) from which parsers can be constructed.
      InvisibleXml​(ParserOptions options)
      Creates a new InvisibleXml object (with custom options) from which parsers can be constructed.
    • Field Detail

      • logcategory

        public static final java.lang.String logcategory
        The category name used for InvisibleXml log messages.
        See Also:
        Constant Field Values
      • XMLNS_ATTRIBUTE

        public static final java.lang.String XMLNS_ATTRIBUTE
        The internal name for the xmlns parser attribute.
        See Also:
        Constant Field Values
      • NAME_ATTRIBUTE

        public static final java.lang.String NAME_ATTRIBUTE
        The internal name for the name parser attribute.
        See Also:
        Constant Field Values
      • MARK_ATTRIBUTE

        public static final java.lang.String MARK_ATTRIBUTE
        The internal name for the mark parser attribute.
        See Also:
        Constant Field Values
      • TMARK_ATTRIBUTE

        public static final java.lang.String TMARK_ATTRIBUTE
        The internal name for the tmark parser attribute.
        See Also:
        Constant Field Values
      • INSERTION_ATTRIBUTE

        public static final java.lang.String INSERTION_ATTRIBUTE
        The internal name for the insertion parser attribute.
        See Also:
        Constant Field Values
      • DISCARD_ATTRIBUTE

        public static final java.lang.String DISCARD_ATTRIBUTE
        The internal name for the discard parser attribute.
        See Also:
        Constant Field Values
      • CSV_HEADING_ATTRIBUTE

        public static final java.lang.String CSV_HEADING_ATTRIBUTE
        See Also:
        Constant Field Values
      • ixml_prefix

        public static final java.lang.String ixml_prefix
        The namespace prefix for the Invisilble XML namespace.
        See Also:
        Constant Field Values
      • ixml_ns

        public static final java.lang.String ixml_ns
        The Invisible XML namespace URI.
        See Also:
        Constant Field Values
      • nineml_prefix

        public static final java.lang.String nineml_prefix
        The namespace prefix for the NineML namespace.
        See Also:
        Constant Field Values
      • nineml_ns

        public static final java.lang.String nineml_ns
        THe NineML namespace URI.
        See Also:
        Constant Field Values
      • AMBIGUOUS

        public static final java.lang.String AMBIGUOUS
        The iXML "ambiguous" state .
        See Also:
        Constant Field Values
      • VERSION_MISMATCH

        public static final java.lang.String VERSION_MISMATCH
        The iXML "version-mismatch" state.
        See Also:
        Constant Field Values
    • Constructor Detail

      • InvisibleXml

        public InvisibleXml()
        Creates a new InvisibleXml object (with default options) from which parsers can be constructed.

        Attempts to load the Invisible XML parser for Invisible XML from resources. This constructor uses default options.

        Throws:
        IxmlException - if the Invisible XML parser for Invisible XML cannot be loaded
      • InvisibleXml

        public InvisibleXml​(ParserOptions options)
        Creates a new InvisibleXml object (with custom options) from which parsers can be constructed.

        Attempts to load the Invisible XML parser for Invisible XML from resources.

        Parameters:
        options - the parser options
        Throws:
        IxmlException - if the Invisible XML parser for Invisible XML cannot be loaded
    • Method Detail

      • knownPragmas

        public static java.util.List<java.lang.String> knownPragmas()
        The known pragma names.
        Returns:
        the list of pragma names known to the processor
      • knownStates

        public static java.util.List<java.lang.String> knownStates()
        The known states.
        Returns:
        the list of states known to the processor.
      • satisfiesVersion10

        public static boolean satisfiesVersion10​(java.lang.String version)
        Is this version a valid "1.0" version?

        The valid 1.0 versions are "1.0" and "1.0-nineml".

        Parameters:
        version - the version string
        Returns:
        true if this is a 1.0 version
      • satisfiesVersion11

        public static boolean satisfiesVersion11​(java.lang.String version)
        Is this version a valid "1.1" version?

        The valid 1.1 versions are "1.1" and "1.1-nineml".

        Parameters:
        version - the version string
        Returns:
        true if this is a 1.1 version
      • getOptions

        public ParserOptions getOptions()
        Get the parser options currently being used to construct parsers.

        Changing properties on the options will only effect subsequently constructed parsers. Each parser gets its own copy of the options.

        Returns:
        the current options
      • getParser

        public InvisibleXmlParser getParser()
        The parser for ixml grammars.
        Returns:
        A parser for the ixml specification grammar.
      • getParser

        public InvisibleXmlParser getParser​(java.net.URI source)
                                     throws java.io.IOException
        Get a parser from a URI.

        Attempts to read from the URI with source.toURL().openConnection(). Sniffs the first 4095 bytes of the input to identify the input as an ixml grammar, a vxml grammar, or a compiled grammar. Assumes the input is in UTF-8.

        Parameters:
        source - the grammar source.
        Returns:
        a parser for that grammar
        Throws:
        java.io.IOException - if attempting to open or read the source fails
        IxmlException - if the source cannot be identified or is not a valid grammar
      • getParser

        public InvisibleXmlParser getParser​(java.io.File source)
                                     throws java.io.IOException
        Get a parser from a file.

        Sniffs the first 4095 bytes of the input to identify the input as an ixml grammar, a vxml grammar, or a compiled grammar. Assumes the input is in UTF-8.

        Parameters:
        source - the grammar source.
        Returns:
        a parser for that grammar
        Throws:
        java.io.IOException - if attempting to open or read the source fails
        IxmlException - if the source cannot be identified or is not a valid grammar
      • getParser

        public InvisibleXmlParser getParser​(java.net.URI source,
                                            java.lang.String encoding)
                                     throws java.io.IOException
        Get a parser from a URI with an explicit encoding.

        Attempts to read from the URI with source.toURL().openConnection(). Sniffs the first 4095 bytes of the input to identify the input as an ixml grammar, a vxml grammar, or a compiled grammar. The encoding is irrelevant for vxml or compiled grammars.

        Parameters:
        source - the grammar source.
        encoding - the character encoding.
        Returns:
        a parser for that grammar
        Throws:
        java.io.IOException - if attempting to open or read the source fails
        IxmlException - if the source cannot be identified or is not a valid grammar
      • getParser

        public InvisibleXmlParser getParser​(java.io.File source,
                                            java.lang.String encoding)
                                     throws java.io.IOException
        Get a parser from a file with an explicit encoding.

        Sniffs the first 4095 bytes of the input to identify the input as an ixml grammar, a vxml grammar, or a compiled grammar.The encoding is irrelevant for vxml or compiled grammars.

        Parameters:
        source - the grammar source.
        encoding - the encoding
        Returns:
        a parser for that grammar
        Throws:
        java.io.IOException - if attempting to open or read the source fails
        IxmlException - if the source cannot be identified or is not a valid grammar
      • getParser

        public InvisibleXmlParser getParser​(java.io.InputStream stream,
                                            java.lang.String systemId)
                                     throws java.io.IOException
        Get a parser from an input stream.

        Sniffs the first 4095 bytes of the input stream to identify the input as an ixml grammar, a vxml grammar, or a compiled grammar. Assumes the input is in UTF-8.

        Parameters:
        stream - the grammar source
        systemId - the system identifier (for XML grammars)
        Returns:
        a parser for that grammar
        Throws:
        java.io.IOException - if attempting to read the source fails
        IxmlException - if the source cannot be identified or is not a valid grammar
      • getParser

        public InvisibleXmlParser getParser​(java.io.InputStream stream,
                                            java.lang.String systemId,
                                            java.lang.String encoding)
                                     throws java.io.IOException
        Get a parser from an input stream with an explicit encoding.

        Sniffs the first 4095 bytes of the input stream to identify the input as an ixml grammar, a vxml grammar, or a compiled grammar. The encoding is irrelevant for vxml or compiled grammars.

        Parameters:
        stream - the grammar source
        systemId - the system identifier (for XML grammars)
        encoding - the character encoding.
        Returns:
        a parser for that grammar
        Throws:
        java.io.IOException - if attempting to open or read the source fails
        IxmlException - if the source cannot be identified or is not a valid grammar
      • getParserFromVxml

        public InvisibleXmlParser getParserFromVxml​(java.io.InputStream stream,
                                                    java.lang.String systemId)
                                             throws java.io.IOException
        Construct a parser from an XML representation (vxml) of an ixml grammar
        Parameters:
        stream - the input stream
        systemId - The system ID of an XML document containing an Invisible XML vxml grammar.
        Returns:
        A parser for that grammar.
        Throws:
        java.io.IOException - if the input cannot be read
        IxmlException - if the input is not an ixml grammar
      • getParserFromIxml

        public InvisibleXmlParser getParserFromIxml​(java.io.InputStream stream,
                                                    java.lang.String charset)
                                             throws java.io.IOException
        Constructs a parser from an ixml grammar.
        Parameters:
        stream - A stream returning an ixml grammar.
        charset - The character set of the grammar file.
        Returns:
        A parser for the grammar.
        Throws:
        java.io.IOException - If an error occurs reading the stream or if the character set is unsupported.
        IxmlException - if the input is not an ixml grammar
      • getParserFromIxml

        public InvisibleXmlParser getParserFromIxml​(java.lang.String input)
        Constructs a parser from an ixml grammar.
        Parameters:
        input - An input string that contains an ixml grammar.
        Returns:
        A parser for the grammar.
        Throws:
        IxmlException - if the input is not an ixml grammar