| java.lang.Object org.openrdf.rio.helpers.RDFParserBase org.openrdf.rio.turtle.TurtleParser
All known Subclasses: org.openrdf.rio.trig.TriGParser,
TurtleParser | public class TurtleParser extends RDFParserBase (Code) | | RDF parser for Turtle
files. This parser is not thread-safe, therefore its public methods are
synchronized.
This implementation is based on the 2006/01/02 version of the Turtle
specification, with slight deviations:
- Normalization of integer, floating point and boolean values is dependent
on the specified datatype handling. According to the specification, integers
and booleans should be normalized, but floats don't.
- Comments can be used anywhere in the document, and extend to the end of
the line. The Turtle grammar doesn't allow comments to be used inside triple
constructs that extend over multiple lines, but the author's own parser
deviates from this too.
author: Arjohn Kampman |
Constructor Summary | |
public | TurtleParser() Creates a new TurtleParser that will use a
ValueFactoryImpl to
create RDF model objects. | public | TurtleParser(ValueFactory valueFactory) Creates a new TurtleParser that will use the supplied ValueFactory to
create RDF model objects. |
Method Summary | |
public RDFFormat | getRDFFormat() | public synchronized void | parse(InputStream in, String baseURI) Implementation of the parse(InputStream, String) method defined
in the RDFParser interface.
Parameters: in - The InputStream from which to read the data, must not benull. | public synchronized void | parse(Reader reader, String baseURI) Implementation of the parse(Reader, String) method defined in
the RDFParser interface. | protected void | parseBase() | protected Resource | parseCollection() Parses a collection, e.g. | protected void | parseDirective() | protected Resource | parseImplicitBlank() Parses an implicit blank node. | protected String | parseLongString() Parses a """long string""". | protected BNode | parseNodeID() Parses a blank node ID, e.g. | protected Literal | parseNumber() | protected void | parseObject() | protected void | parseObjectList() | protected URI | parsePredicate() | protected void | parsePredicateObjectList() | protected void | parsePrefixID() | protected Value | parseQNameOrBoolean() Parses qnames and boolean values, which have equivalent starting
characters. | protected Literal | parseQuotedLiteral() Parses a quoted string, optionally followed by a language tag or datatype. | protected String | parseQuotedString() Parses a quoted string, which is either a "normal string" or a """long
string""". | protected void | parseStatement() | protected String | parseString() Parses a "normal string". | protected void | parseSubject() | protected void | parseTriples() | protected URI | parseURI() | protected Value | parseValue() Parses an RDF value. | protected int | peek() | protected int | read() | protected void | reportError(String msg) Overrides
RDFParserBase.reportError(String) , adding line number
information to the error. | protected void | reportFatalError(String msg) Overrides
RDFParserBase.reportFatalError(String) , adding line
number information to the error. | protected void | reportFatalError(Exception e) Overrides
RDFParserBase.reportFatalError(Exception) , adding line
number information to the error. | protected void | reportLocation() | protected void | reportStatement(Resource subj, URI pred, Value obj) | protected void | reportWarning(String msg) Overrides
RDFParserBase.reportWarning(String) , adding line number
information to the error. | protected void | skipLine() Consumes characters from reader until the first EOL has been read. | protected int | skipWSC() Consumes any white space characters (space, tab, line feed, newline) and
comments (#-style) from reader. | protected void | throwEOFException() | protected void | unread(int c) | protected void | verifyCharacter(int c, String expected) Verifies that the supplied character c is one of the expected
characters specified in expected. |
TurtleParser | public TurtleParser()(Code) | | Creates a new TurtleParser that will use a
ValueFactoryImpl to
create RDF model objects.
|
TurtleParser | public TurtleParser(ValueFactory valueFactory)(Code) | | Creates a new TurtleParser that will use the supplied ValueFactory to
create RDF model objects.
Parameters: valueFactory - A ValueFactory. |
parse | public synchronized void parse(InputStream in, String baseURI) throws IOException, RDFParseException, RDFHandlerException(Code) | | Implementation of the parse(InputStream, String) method defined
in the RDFParser interface.
Parameters: in - The InputStream from which to read the data, must not benull. The InputStream is supposed to contain UTF-8encoded Unicode characters, as per the Turtle specification. Parameters: baseURI - The URI associated with the data in the InputStream, must not benull. throws: IOException - If an I/O error occurred while data was read from the InputStream. throws: RDFParseException - If the parser has found an unrecoverable parse error. throws: RDFHandlerException - If the configured statement handler encountered an unrecoverableerror. throws: IllegalArgumentException - If the supplied input stream or base URI is null. |
parse | public synchronized void parse(Reader reader, String baseURI) throws IOException, RDFParseException, RDFHandlerException(Code) | | Implementation of the parse(Reader, String) method defined in
the RDFParser interface.
Parameters: reader - The Reader from which to read the data, must not be null. Parameters: baseURI - The URI associated with the data in the Reader, must not benull. throws: IOException - If an I/O error occurred while data was read from the InputStream. throws: RDFParseException - If the parser has found an unrecoverable parse error. throws: RDFHandlerException - If the configured statement handler encountered an unrecoverableerror. throws: IllegalArgumentException - If the supplied reader or base URI is null. |
parseLongString | protected String parseLongString() throws IOException, RDFParseException(Code) | | Parses a """long string""". This method assumes that the first three
double quotes have already been parsed.
|
reportLocation | protected void reportLocation()(Code) | | |
skipLine | protected void skipLine() throws IOException(Code) | | Consumes characters from reader until the first EOL has been read.
|
skipWSC | protected int skipWSC() throws IOException(Code) | | Consumes any white space characters (space, tab, line feed, newline) and
comments (#-style) from reader. After this method has been
called, the first character that is returned by reader is
either a non-ignorable character, or EOF. For convenience, this character
is also returned by this method.
The next character that will be returned by reader. |
verifyCharacter | protected void verifyCharacter(int c, String expected) throws RDFParseException(Code) | | Verifies that the supplied character c is one of the expected
characters specified in expected. This method will throw a
ParseException if this is not the case.
|
Methods inherited from org.openrdf.rio.helpers.RDFParserBase | protected void clear()(Code)(Java Doc) protected void clearBNodeIDMap()(Code)(Java Doc) protected BNode createBNode() throws RDFParseException(Code)(Java Doc) protected BNode createBNode(String nodeID) throws RDFParseException(Code)(Java Doc) protected Literal createLiteral(String label, String lang, URI datatype) throws RDFParseException(Code)(Java Doc) protected Statement createStatement(Resource subj, URI pred, Value obj) throws RDFParseException(Code)(Java Doc) protected Statement createStatement(Resource subj, URI pred, Value obj, Resource context) throws RDFParseException(Code)(Java Doc) protected URI createURI(String uri) throws RDFParseException(Code)(Java Doc) public DatatypeHandling datatypeHandling()(Code)(Java Doc) protected String getNamespace(String prefix)(Code)(Java Doc) public ParseErrorListener getParseErrorListener()(Code)(Java Doc) public ParseLocationListener getParseLocationListener()(Code)(Java Doc) public RDFHandler getRDFHandler()(Code)(Java Doc) public boolean preserveBNodeIDs()(Code)(Java Doc) protected void reportError(String msg) throws RDFParseException(Code)(Java Doc) protected void reportError(String msg, int lineNo, int columnNo) throws RDFParseException(Code)(Java Doc) protected void reportFatalError(String msg) throws RDFParseException(Code)(Java Doc) protected void reportFatalError(String msg, int lineNo, int columnNo) throws RDFParseException(Code)(Java Doc) protected void reportFatalError(Exception e) throws RDFParseException(Code)(Java Doc) protected void reportFatalError(Exception e, int lineNo, int columnNo) throws RDFParseException(Code)(Java Doc) protected void reportLocation(int lineNo, int columnNo)(Code)(Java Doc) protected void reportWarning(String msg)(Code)(Java Doc) protected void reportWarning(String msg, int lineNo, int columnNo)(Code)(Java Doc) protected URI resolveURI(String uriSpec) throws RDFParseException(Code)(Java Doc) protected void setBaseURI(String uriSpec)(Code)(Java Doc) protected void setBaseURI(ParsedURI baseURI)(Code)(Java Doc) public void setDatatypeHandling(DatatypeHandling datatypeHandling)(Code)(Java Doc) protected void setNamespace(String prefix, String namespace)(Code)(Java Doc) public void setParseErrorListener(ParseErrorListener el)(Code)(Java Doc) public void setParseLocationListener(ParseLocationListener el)(Code)(Java Doc) public void setPreserveBNodeIDs(boolean preserveBNodeIDs)(Code)(Java Doc) public void setRDFHandler(RDFHandler handler)(Code)(Java Doc) public void setStopAtFirstError(boolean stopAtFirstError)(Code)(Java Doc) public void setValueFactory(ValueFactory valueFactory)(Code)(Java Doc) public void setVerifyData(boolean verifyData)(Code)(Java Doc) public boolean stopAtFirstError()(Code)(Java Doc) public boolean verifyData()(Code)(Java Doc)
|
|
|