public class TurtleParser extends AbstractRDFParser
RDFParser.DatatypeHandling
Modifier and Type | Field and Description |
---|---|
protected Value |
object |
protected IRI |
predicate |
protected Resource |
subject |
rdfHandler, valueFactory
Constructor and Description |
---|
TurtleParser()
Creates a new TurtleParser that will use a
SimpleValueFactory to create RDF model objects. |
TurtleParser(ValueFactory valueFactory)
Creates a new TurtleParser that will use the supplied ValueFactory to create RDF model objects.
|
Modifier and Type | Method and Description |
---|---|
protected int |
getLineNumber() |
RDFFormat |
getRDFFormat()
Gets the RDF format that this parser can parse.
|
Collection<RioSetting<?>> |
getSupportedSettings() |
void |
parse(InputStream in,
String baseURI)
Parses the data from the supplied InputStream, using the supplied baseURI to resolve any relative URI references.
|
void |
parse(Reader reader,
String baseURI)
Parses the data from the supplied Reader, using the supplied baseURI to resolve any relative URI references.
|
protected void |
parseBase() |
protected Resource |
parseCollection()
Parses a collection, e.g.
|
protected void |
parseDirective(String directive) |
protected Resource |
parseImplicitBlank()
Parses an implicit blank node.
|
protected String |
parseLongString(int closingCharacter)
Parses a """long string""".
|
protected Resource |
parseNodeID()
Parses a blank node ID, e.g.
|
protected Literal |
parseNumber() |
protected void |
parseObject()
Parse an object
|
protected void |
parseObjectList() |
protected IRI |
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(int closingCharacter)
Parses a "normal string".
|
protected void |
parseSubject() |
protected void |
parseTriples() |
protected Triple |
parseTripleValue()
Parser an RDF* triple value and returns it.
|
protected IRI |
parseURI() |
protected 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 boolean |
peekIsTripleValue()
Peeks at the next two Unicode code points without advancing the reader and returns true if they indicate the
start of an RDF* triple value.
|
protected void |
processComment()
Consumes characters from reader until the first EOL has been read.
|
protected int |
readCodePoint()
Reads the next Unicode code point.
|
protected void |
reportError(String msg,
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(Resource subj,
IRI pred,
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, createLiteral, createNode, createNode, createStatement, createStatement, createURI, datatypeHandling, getNamespace, getParseErrorListener, getParseLocationListener, getParserConfig, getRDFHandler, initializeNamespaceTableFromConfiguration, preserveBNodeIDs, reportError, reportError, reportError, reportError, reportFatalError, reportFatalError, reportFatalError, reportLocation, reportWarning, resolveURI, set, setBaseURI, setBaseURI, setDatatypeHandling, setNamespace, setParseErrorListener, setParseLocationListener, setParserConfig, setPreserveBNodeIDs, setRDFHandler, setStopAtFirstError, setValueFactory, setVerifyData, stopAtFirstError, verifyData
protected Resource subject
protected IRI predicate
protected Value object
public TurtleParser()
SimpleValueFactory
to create RDF model objects.public TurtleParser(ValueFactory valueFactory)
valueFactory
- A ValueFactory.public RDFFormat getRDFFormat()
RDFParser
public Collection<RioSetting<?>> getSupportedSettings()
getSupportedSettings
in interface RDFParser
getSupportedSettings
in class AbstractRDFParser
RioSetting
s that are supported by this RDFParser.public void parse(InputStream in, String baseURI) throws IOException, RDFParseException, RDFHandlerException
RDFParser
in
- The InputStream from which to read the data.baseURI
- The URI associated with the data in the InputStream. May be null
. Parsers for syntax
formats that do not support relative URIs will ignore this argument.
Note that if the data contains an embedded base URI, that embedded base URI will overrule the value supplied here (see RFC 3986 section 5.1 for details).
IOException
- If an I/O error occurred while data was read from the InputStream.RDFParseException
- If the parser has found an unrecoverable parse error.RDFHandlerException
- If the configured statement handler has encountered an unrecoverable error.public void parse(Reader reader, String baseURI) throws IOException, RDFParseException, RDFHandlerException
RDFParser
reader
- The Reader from which to read the data.baseURI
- The URI associated with the data in the InputStream. May be null
. Parsers for syntax
formats that do not support relative URIs will ignore this argument.
Note that if the data contains an embedded base URI, that embedded base URI will overrule the value supplied here (see RFC 3986 section 5.1 for details).
IOException
- If an I/O error occurred while data was read from the InputStream.RDFParseException
- If the parser has found an unrecoverable parse error.RDFHandlerException
- If the configured statement handler has encountered an unrecoverable error.protected void parseStatement() throws IOException, RDFParseException, RDFHandlerException
protected void parseDirective(String directive) throws IOException, RDFParseException, RDFHandlerException
protected void parsePrefixID() throws IOException, RDFParseException, RDFHandlerException
protected void parseBase() throws IOException, RDFParseException, RDFHandlerException
protected void parseTriples() throws IOException, RDFParseException, RDFHandlerException
protected void parsePredicateObjectList() throws IOException, RDFParseException, RDFHandlerException
protected void parseObjectList() throws IOException, RDFParseException, RDFHandlerException
protected void parseSubject() throws IOException, RDFParseException, RDFHandlerException
protected IRI parsePredicate() throws IOException, RDFParseException, RDFHandlerException
protected void parseObject() throws IOException, RDFParseException, RDFHandlerException
protected Resource parseCollection() throws IOException, RDFParseException, RDFHandlerException
protected Resource parseImplicitBlank() throws IOException, RDFParseException, RDFHandlerException
protected Value parseValue() throws IOException, RDFParseException, RDFHandlerException
protected Literal parseQuotedLiteral() throws IOException, RDFParseException, RDFHandlerException
protected String parseQuotedString() throws IOException, RDFParseException
IOException
RDFParseException
protected String parseString(int closingCharacter) throws IOException, RDFParseException
IOException
RDFParseException
protected String parseLongString(int closingCharacter) throws IOException, RDFParseException
IOException
RDFParseException
protected Literal parseNumber() throws IOException, RDFParseException
IOException
RDFParseException
protected IRI parseURI() throws IOException, RDFParseException
IOException
RDFParseException
protected Value parseQNameOrBoolean() throws IOException, RDFParseException
IOException
RDFParseException
protected Resource parseNodeID() throws IOException, RDFParseException
IOException
RDFParseException
protected void reportStatement(Resource subj, IRI pred, Value obj) throws RDFParseException, RDFHandlerException
RDFParseException
RDFHandlerException
protected void verifyCharacterOrFail(int codePoint, String expected) throws RDFParseException
RDFParseException
protected int skipWSC() throws IOException, RDFHandlerException
IOException
RDFHandlerException
protected void processComment() throws IOException, RDFHandlerException
AbstractRDFParser.rdfHandler
as a comment.IOException
RDFHandlerException
protected int readCodePoint() throws IOException
IOException
protected void unread(int codePoint) throws IOException
readCodePoint()
will return the same code point c again.codePoint
- a single Unicode code point.IOException
protected 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.IOException
protected int peekCodePoint() throws IOException
IOException
protected void reportLocation()
protected void reportWarning(String msg)
AbstractRDFParser.reportWarning(String)
, adding line number information to the error.reportWarning
in class AbstractRDFParser
protected void reportError(String msg, RioSetting<Boolean> setting) throws RDFParseException
AbstractRDFParser.reportError(String, RioSetting)
, adding line number information to the error.reportError
in class AbstractRDFParser
msg
- 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.RDFParseException
- If RioConfig.get(RioSetting)
returns true, and
ParserConfig.isNonFatalError(RioSetting)
returns true for the given setting.protected void reportFatalError(String msg) throws RDFParseException
AbstractRDFParser.reportFatalError(String)
, adding line number information to the error.reportFatalError
in class AbstractRDFParser
RDFParseException
protected void reportFatalError(Exception e) throws RDFParseException
AbstractRDFParser.reportFatalError(Exception)
, adding line number information to the error.reportFatalError
in class AbstractRDFParser
RDFParseException
protected void throwEOFException() throws RDFParseException
RDFParseException
protected int getLineNumber()
protected boolean peekIsTripleValue() throws IOException
IOException
protected Triple parseTripleValue() throws IOException
IOException
Copyright © 2015-2020 Eclipse Foundation. All Rights Reserved.