Package org.nineml.coffeefilter
Class InvisibleXmlParser
- java.lang.Object
-
- org.nineml.coffeefilter.InvisibleXmlParser
-
public class InvisibleXmlParser extends java.lang.ObjectA parser for a particular Invisible XML grammar.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.Stringlogcategory
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanconstructed()Did the grammar parse succeed?java.lang.ExceptiongetException()Return the exception that caused an attempt to build a parser to fail.InvisibleXmlDocumentgetFailedParse()If the attempt to parse the grammar failed, return a representation of that failure.org.nineml.coffeegrinder.parser.SourceGrammargetGrammar()Get the underlying grammarorg.nineml.coffeegrinder.parser.HygieneReportgetHygieneReport()Get the hygiene report for this parser's grammarjava.lang.StringgetIxmlVersion()java.util.Map<java.lang.String,java.util.List<java.lang.String>>getMetadata()Get metadata.ParserOptionsgetOptions()Get the parser options.longgetParseTime()Get the time spent parsing the input grammar.java.util.List<org.nineml.coffeefilter.model.IPragma>getPragmas()Get the pragmas associated with this parser.InvisibleXmlDocumentparse(java.io.File source)Get a document from a file.InvisibleXmlDocumentparse(java.io.File source, java.lang.String encoding)Get a document from a file with an explicit encoding.InvisibleXmlDocumentparse(java.io.InputStream stream, java.lang.String encoding)Get a document from a stream.InvisibleXmlDocumentparse(java.lang.String input)Get a document from a string.InvisibleXmlDocumentparse(java.net.URI source)Get a document from a URI.InvisibleXmlDocumentparse(java.net.URI source, java.lang.String encoding)Get a document from a URI with an explicit encoding.InvisibleXmlDocumentparse(org.nineml.coffeegrinder.tokens.Token[] input)Get a document from an array of tokens.java.lang.StringreadInputStream(java.io.InputStream stream, java.lang.String charset)
-
-
-
Field Detail
-
logcategory
public static final java.lang.String logcategory
- See Also:
- Constant Field Values
-
-
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,
nullwill 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 readjava.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 readjava.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 sourceencoding- 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 sourceencoding- 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
-
-