public class TurtleParser extends AbstractRDFParser
This implementation is based on the 2006/01/02 version of the Turtle specification, with slight deviations:
| Modifier and Type | Field and Description |
|---|---|
protected int |
lineNumber |
protected org.openrdf.model.Value |
object |
protected org.openrdf.model.IRI |
predicate |
protected PushbackReader |
reader |
protected org.openrdf.model.Resource |
subject |
baseURI, namespaceTable, rdfHandler, valueFactory| Constructor and Description |
|---|
TurtleParser()
Creates a new TurtleParser.
|
| Modifier and Type | Method and Description |
|---|---|
protected org.openrdf.model.Resource |
getContext() |
org.openrdf.rio.RDFFormat |
getRDFFormat() |
Collection<org.openrdf.rio.RioSetting<?>> |
getSupportedSettings() |
protected void |
initConfigParams() |
void |
parse(InputStream in,
String baseURI)
Implementation of the parse(InputStream, String) method defined
in the RDFParser interface.
|
void |
parse(Reader reader,
String baseURI)
Implementation of the parse(Reader, String) method defined in the
RDFParser interface.
|
protected void |
parseBase() |
protected void |
parseBlock(String blockName) |
protected org.openrdf.model.Resource |
parseCollection()
Parses a collection, e.g.
|
protected boolean |
parseDirective() |
protected org.openrdf.model.Resource |
parseImplicitBlank(boolean verify)
Parses an implicit blank node.
|
protected void |
parseKeyword(String expected) |
protected String |
parseLongString(int closingCharacter)
Parses a """long string""".
|
protected org.openrdf.model.BNode |
parseNodeID()
Parses a blank node ID, e.g.
|
protected org.openrdf.model.Literal |
parseNumber() |
protected void |
parseObject() |
protected void |
parseObjectList() |
protected org.openrdf.model.IRI |
parsePredicate() |
protected void |
parsePredicateObjectList() |
protected void |
parsePrefixID() |
protected org.openrdf.model.Value |
parseQNameOrBoolean()
Parses qnames and boolean values, which have equivalent starting
characters.
|
protected org.openrdf.model.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 |
parseRule(org.openrdf.model.Resource ruleID) |
protected org.openrdf.model.Resource |
parseRuleID() |
protected void |
parseStatement() |
protected String |
parseString(int closingCharacter)
Parses a "normal string".
|
protected void |
parseSubject() |
protected void |
parseTriples() |
protected org.openrdf.model.IRI |
parseURI() |
org.openrdf.model.Value |
parseValue()
Parses an RDF value.
|
protected int |
peekCodePoint()
Peeks at the next Unicode code point without advancing the reader, and
returns its value.
|
protected void |
processComment()
Consumes characters from reader until the first EOL has been read.
|
protected void |
processComment(StringBuilder comment) |
protected int |
readCodePoint()
Reads the next Unicode code point.
|
protected void |
reportError(String msg,
org.openrdf.rio.RioSetting<Boolean> setting)
Overrides
AbstractRDFParser.reportError(String, RioSetting), adding
line number information to the error. |
protected void |
reportFatalError(Exception e)
Overrides
AbstractRDFParser.reportFatalError(Exception), adding line
number information to the error. |
protected void |
reportFatalError(String msg)
Overrides
AbstractRDFParser.reportFatalError(String), adding line
number information to the error. |
protected void |
reportLocation() |
protected void |
reportStatement(org.openrdf.model.Resource subj,
org.openrdf.model.IRI pred,
org.openrdf.model.Value obj) |
protected void |
reportWarning(String msg)
Overrides
AbstractRDFParser.reportWarning(String), adding line number
information to the error. |
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 codePoint)
Pushes back a single code point by copying it to the front of the buffer.
|
protected void |
unread(String string)
Pushes back the supplied string by copying it to the front of the buffer.
|
protected void |
verifyCharacterOrFail(int codePoint,
String expected)
Verifies that the supplied character code point codePoint is one
of the expected characters specified in expected.
|
clear, clearBNodeIDMap, createBNode, createBNode, createLiteral, createStatement, createStatement, createURI, createURI, datatypeHandling, getNamespace, getParseErrorListener, getParseLocationListener, getParserConfig, getRDFHandler, initializeNamespaceTableFromConfiguration, preserveBNodeIDs, reportError, reportError, reportFatalError, reportFatalError, reportLocation, reportWarning, resolveURI, set, setBaseURI, setBaseURI, setDatatypeHandling, setNamespace, setParseErrorListener, setParseLocationListener, setParserConfig, setPreserveBNodeIDs, setRDFHandler, setStopAtFirstError, setValueFactory, setVerifyData, stopAtFirstError, verifyDataprotected PushbackReader reader
protected org.openrdf.model.Resource subject
protected org.openrdf.model.IRI predicate
protected org.openrdf.model.Value object
protected int lineNumber
public org.openrdf.rio.RDFFormat getRDFFormat()
public Collection<org.openrdf.rio.RioSetting<?>> getSupportedSettings()
getSupportedSettings in interface org.openrdf.rio.RDFParsergetSupportedSettings in class AbstractRDFParserpublic void parse(InputStream in, String baseURI) throws IOException, org.openrdf.rio.RDFParseException, org.openrdf.rio.RDFHandlerException
in - The InputStream from which to read the data, must not be
null. The InputStream is supposed to contain UTF-8 encoded
Unicode characters, as per the Turtle specification.baseURI - The IRI associated with the data in the InputStream, must not be
null.IOException - If an I/O error occurred while data was read from the InputStream.org.openrdf.rio.RDFParseException - If the parser has found an unrecoverable parse error.org.openrdf.rio.RDFHandlerException - If the configured statement handler encountered an unrecoverable
error.IllegalArgumentException - If the supplied input stream or base IRI is null.protected void initConfigParams()
initConfigParams in class AbstractRDFParserpublic void parse(Reader reader, String baseURI) throws IOException, org.openrdf.rio.RDFParseException, org.openrdf.rio.RDFHandlerException
reader - The Reader from which to read the data, must not be null.baseURI - The URI associated with the data in the Reader, must not be
null.IOException - If an I/O error occurred while data was read from the InputStream.org.openrdf.rio.RDFParseException - If the parser has found an unrecoverable parse error.org.openrdf.rio.RDFHandlerException - If the configured statement handler encountered an unrecoverable
error.IllegalArgumentException - If the supplied reader or base URI is null.protected void parseStatement()
throws IOException,
org.openrdf.rio.RDFParseException,
org.openrdf.rio.RDFHandlerException
IOExceptionorg.openrdf.rio.RDFParseExceptionorg.openrdf.rio.RDFHandlerExceptionprotected boolean parseDirective()
throws IOException
IOExceptionprotected void parsePrefixID()
throws IOException,
org.openrdf.rio.RDFParseException,
org.openrdf.rio.RDFHandlerException
IOExceptionorg.openrdf.rio.RDFParseExceptionorg.openrdf.rio.RDFHandlerExceptionprotected void parseBase()
throws IOException,
org.openrdf.rio.RDFParseException,
org.openrdf.rio.RDFHandlerException
IOExceptionorg.openrdf.rio.RDFParseExceptionorg.openrdf.rio.RDFHandlerExceptionprotected void parseKeyword(String expected) throws IOException, org.openrdf.rio.RDFParseException, org.openrdf.rio.RDFHandlerException
IOExceptionorg.openrdf.rio.RDFParseExceptionorg.openrdf.rio.RDFHandlerExceptionprotected org.openrdf.model.Resource parseRuleID()
throws IOException,
org.openrdf.rio.RDFParseException,
org.openrdf.rio.RDFHandlerException
IOExceptionorg.openrdf.rio.RDFParseExceptionorg.openrdf.rio.RDFHandlerExceptionprotected void parseRule(org.openrdf.model.Resource ruleID)
throws IOException,
org.openrdf.rio.RDFParseException,
org.openrdf.rio.RDFHandlerException
IOExceptionorg.openrdf.rio.RDFParseExceptionorg.openrdf.rio.RDFHandlerExceptionprotected void parseBlock(String blockName) throws IOException, org.openrdf.rio.RDFParseException
IOExceptionorg.openrdf.rio.RDFParseExceptionprotected void parseTriples()
throws IOException,
org.openrdf.rio.RDFParseException,
org.openrdf.rio.RDFHandlerException
IOExceptionorg.openrdf.rio.RDFParseExceptionorg.openrdf.rio.RDFHandlerExceptionprotected void parsePredicateObjectList()
throws IOException,
org.openrdf.rio.RDFParseException,
org.openrdf.rio.RDFHandlerException
IOExceptionorg.openrdf.rio.RDFParseExceptionorg.openrdf.rio.RDFHandlerExceptionprotected void parseObjectList()
throws IOException,
org.openrdf.rio.RDFParseException,
org.openrdf.rio.RDFHandlerException
IOExceptionorg.openrdf.rio.RDFParseExceptionorg.openrdf.rio.RDFHandlerExceptionprotected void parseSubject()
throws IOException,
org.openrdf.rio.RDFParseException,
org.openrdf.rio.RDFHandlerException
IOExceptionorg.openrdf.rio.RDFParseExceptionorg.openrdf.rio.RDFHandlerExceptionprotected org.openrdf.model.IRI parsePredicate()
throws IOException,
org.openrdf.rio.RDFParseException
IOExceptionorg.openrdf.rio.RDFParseExceptionprotected void parseObject()
throws IOException,
org.openrdf.rio.RDFParseException,
org.openrdf.rio.RDFHandlerException
IOExceptionorg.openrdf.rio.RDFParseExceptionorg.openrdf.rio.RDFHandlerExceptionprotected org.openrdf.model.Resource parseCollection()
throws IOException,
org.openrdf.rio.RDFParseException,
org.openrdf.rio.RDFHandlerException
IOExceptionorg.openrdf.rio.RDFParseExceptionorg.openrdf.rio.RDFHandlerExceptionprotected org.openrdf.model.Resource parseImplicitBlank(boolean verify)
throws IOException,
org.openrdf.rio.RDFParseException,
org.openrdf.rio.RDFHandlerException
IOExceptionorg.openrdf.rio.RDFParseExceptionorg.openrdf.rio.RDFHandlerExceptionpublic org.openrdf.model.Value parseValue()
throws IOException,
org.openrdf.rio.RDFParseException
IOExceptionorg.openrdf.rio.RDFParseExceptionprotected org.openrdf.model.Literal parseQuotedLiteral()
throws IOException,
org.openrdf.rio.RDFParseException
IOExceptionorg.openrdf.rio.RDFParseExceptionprotected String parseQuotedString() throws IOException, org.openrdf.rio.RDFParseException
IOExceptionorg.openrdf.rio.RDFParseExceptionprotected String parseString(int closingCharacter) throws IOException, org.openrdf.rio.RDFParseException
IOExceptionorg.openrdf.rio.RDFParseExceptionprotected String parseLongString(int closingCharacter) throws IOException, org.openrdf.rio.RDFParseException
IOExceptionorg.openrdf.rio.RDFParseExceptionprotected org.openrdf.model.Literal parseNumber()
throws IOException,
org.openrdf.rio.RDFParseException
IOExceptionorg.openrdf.rio.RDFParseExceptionprotected org.openrdf.model.IRI parseURI()
throws IOException,
org.openrdf.rio.RDFParseException
IOExceptionorg.openrdf.rio.RDFParseExceptionprotected org.openrdf.model.Value parseQNameOrBoolean()
throws IOException,
org.openrdf.rio.RDFParseException
IOExceptionorg.openrdf.rio.RDFParseExceptionprotected org.openrdf.model.BNode parseNodeID()
throws IOException,
org.openrdf.rio.RDFParseException
IOExceptionorg.openrdf.rio.RDFParseExceptionprotected void reportStatement(org.openrdf.model.Resource subj,
org.openrdf.model.IRI pred,
org.openrdf.model.Value obj)
throws org.openrdf.rio.RDFParseException,
org.openrdf.rio.RDFHandlerException
org.openrdf.rio.RDFParseExceptionorg.openrdf.rio.RDFHandlerExceptionprotected void verifyCharacterOrFail(int codePoint,
String expected)
throws org.openrdf.rio.RDFParseException
org.openrdf.rio.RDFParseExceptionprotected int skipWSC()
throws IOException,
org.openrdf.rio.RDFHandlerException
IOExceptionorg.openrdf.rio.RDFHandlerExceptionprotected void processComment()
throws IOException,
org.openrdf.rio.RDFHandlerException
AbstractRDFParser.rdfHandler as a comment.IOExceptionorg.openrdf.rio.RDFHandlerExceptionprotected void processComment(StringBuilder comment) throws IOException, org.openrdf.rio.RDFHandlerException
IOExceptionorg.openrdf.rio.RDFHandlerExceptionprotected int readCodePoint()
throws IOException
IOExceptionprotected void unread(int codePoint)
throws IOException
readCodePoint() will return
the same code point c again.codePoint - a single Unicode code point.IOExceptionprotected void unread(String string) throws IOException
readCodePoint()
will return the code points in the supplied string again, starting at the
first in the String..string - the string to un-read.IOExceptionprotected int peekCodePoint()
throws IOException
IOExceptionprotected void reportLocation()
protected void reportWarning(String msg)
AbstractRDFParser.reportWarning(String), adding line number
information to the error.reportWarning in class AbstractRDFParserprotected void reportError(String msg, org.openrdf.rio.RioSetting<Boolean> setting) throws org.openrdf.rio.RDFParseException
AbstractRDFParser.reportError(String, RioSetting), adding
line number information to the error.reportError in class AbstractRDFParsermsg - The message to use for
ParseErrorListener.error(String, long, long) and for
RDFParseException.RDFParseException(String, long, long).setting - The boolean setting that will be checked to determine if this is an
issue that we need to look at at all. If this setting is true, then
the error listener will receive the error, and if
ParserConfig.isNonFatalError(RioSetting) returns true an
exception will be thrown.org.openrdf.rio.RDFParseException - If RioConfig.get(RioSetting) returns true, and
ParserConfig.isNonFatalError(RioSetting) returns true for
the given setting.protected void reportFatalError(String msg) throws org.openrdf.rio.RDFParseException
AbstractRDFParser.reportFatalError(String), adding line
number information to the error.reportFatalError in class AbstractRDFParserorg.openrdf.rio.RDFParseExceptionprotected void reportFatalError(Exception e) throws org.openrdf.rio.RDFParseException
AbstractRDFParser.reportFatalError(Exception), adding line
number information to the error.reportFatalError in class AbstractRDFParserorg.openrdf.rio.RDFParseExceptionprotected void throwEOFException()
throws org.openrdf.rio.RDFParseException
org.openrdf.rio.RDFParseExceptionprotected org.openrdf.model.Resource getContext()
Copyright © 2010-2016 Stardog Union. All Rights Reserved.