Class InvisibleXml
- java.lang.Object
-
- org.nineml.coffeefilter.InvisibleXml
-
public class InvisibleXml extends java.lang.ObjectA static class for constructing instances of Invisible XML grammars.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringAMBIGUOUSThe iXML "ambiguous" state .static java.lang.StringCSV_HEADING_ATTRIBUTEstatic java.lang.StringDISCARD_ATTRIBUTEThe internal name for the discard parser attribute.static java.lang.StringINSERTION_ATTRIBUTEThe internal name for the insertion parser attribute.static java.lang.StringIXML_10static java.lang.StringIXML_10_NINEMLstatic java.lang.StringIXML_11static java.lang.StringIXML_11_NINEMLstatic java.lang.Stringixml_nsThe Invisible XML namespace URI.static java.lang.Stringixml_prefixThe namespace prefix for the Invisilble XML namespace.static java.lang.StringlogcategoryThe category name used for InvisibleXml log messages.static java.lang.StringMARK_ATTRIBUTEThe internal name for the mark parser attribute.static java.lang.StringNAME_ATTRIBUTEThe internal name for the name parser attribute.static java.lang.Stringnineml_nsTHe NineML namespace URI.static java.lang.Stringnineml_prefixThe namespace prefix for the NineML namespace.static java.lang.StringTMARK_ATTRIBUTEThe internal name for the tmark parser attribute.static java.lang.StringVERSION_MISMATCHThe iXML "version-mismatch" state.static java.lang.StringXMLNS_ATTRIBUTEThe 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.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ParserOptionsgetOptions()Get the parser options currently being used to construct parsers.InvisibleXmlParsergetParser()The parser for ixml grammars.InvisibleXmlParsergetParser(java.io.File source)Get a parser from a file.InvisibleXmlParsergetParser(java.io.File source, java.lang.String encoding)Get a parser from a file with an explicit encoding.InvisibleXmlParsergetParser(java.io.InputStream stream, java.lang.String systemId)Get a parser from an input stream.InvisibleXmlParsergetParser(java.io.InputStream stream, java.lang.String systemId, java.lang.String encoding)Get a parser from an input stream with an explicit encoding.InvisibleXmlParsergetParser(java.net.URI source)Get a parser from a URI.InvisibleXmlParsergetParser(java.net.URI source, java.lang.String encoding)Get a parser from a URI with an explicit encoding.InvisibleXmlParsergetParserFromIxml(java.io.InputStream stream, java.lang.String charset)Constructs a parser from an ixml grammar.InvisibleXmlParsergetParserFromIxml(java.lang.String input)Constructs a parser from an ixml grammar.InvisibleXmlParsergetParserFromVxml(java.io.InputStream stream, java.lang.String systemId)Construct a parser from an XML representation (vxml) of an ixml grammarstatic java.util.List<java.lang.String>knownPragmas()The known pragma names.static java.util.List<java.lang.String>knownStates()The known states.static booleansatisfiesVersion10(java.lang.String version)Is this version a valid "1.0" version?static booleansatisfiesVersion11(java.lang.String version)Is this version a valid "1.1" version?
-
-
-
Field Detail
-
logcategory
public static final java.lang.String logcategory
The category name used for InvisibleXml log messages.- See Also:
- Constant Field Values
-
IXML_10
public static final java.lang.String IXML_10
- See Also:
- Constant Field Values
-
IXML_10_NINEML
public static final java.lang.String IXML_10_NINEML
- See Also:
- Constant Field Values
-
IXML_11
public static final java.lang.String IXML_11
- See Also:
- Constant Field Values
-
IXML_11_NINEML
public static final java.lang.String IXML_11_NINEML
- 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 failsIxmlException- 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 failsIxmlException- 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 failsIxmlException- 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 failsIxmlException- 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 sourcesystemId- the system identifier (for XML grammars)- Returns:
- a parser for that grammar
- Throws:
java.io.IOException- if attempting to read the source failsIxmlException- 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 sourcesystemId- 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 failsIxmlException- 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 streamsystemId- 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 readIxmlException- 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
-
-