public class NTriplesParser extends AbstractRDFParser
RDFParser.DatatypeHandling
Modifier and Type | Field and Description |
---|---|
protected int |
currentIndex |
protected char[] |
lineChars |
protected long |
lineNo |
protected Value |
object |
protected IRI |
predicate |
protected BufferedReader |
reader |
protected Resource |
subject |
rdfHandler, valueFactory
Constructor and Description |
---|
NTriplesParser()
Creates a new NTriplesParser that will use a
SimpleValueFactory to create object for resources, bNodes
and literals. |
NTriplesParser(ValueFactory valueFactory)
Creates a new NTriplesParser that will use the supplied ValueFactory to create RDF model objects.
|
Modifier and Type | Method and Description |
---|---|
protected void |
assertLineTerminates()
Verifies that there is only whitespace or comments until the end of the line.
|
protected void |
clear()
Clears any information that has been collected while parsing.
|
protected IRI |
createURI(String uri)
Creates a
IRI object for the specified URI-string. |
RDFFormat |
getRDFFormat()
Gets the RDF format that this parser can parse.
|
Collection<RioSetting<?>> |
getSupportedSettings() |
protected void |
handleStatement(boolean ignoredAnError) |
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 IRI |
parseIRI() |
protected Resource |
parseNode() |
protected void |
parseObject() |
protected void |
parsePredicate() |
protected void |
parseStatement() |
protected void |
parseSubject() |
protected void |
reportError(Exception e,
RioSetting<Boolean> setting)
Reports an error with associated line- and column number to the registered ParseErrorListener, if the given
setting has been set to true.
|
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 |
reportWarning(String msg)
Overrides
AbstractRDFParser.reportWarning(String) , adding line number information to the error. |
protected boolean |
shouldParseLine() |
protected void |
skipWhitespace(boolean throwEOF) |
protected void |
throwEOFException() |
clearBNodeIDMap, createBNode, createBNode, createLiteral, createLiteral, createNode, createNode, createStatement, createStatement, datatypeHandling, getNamespace, getParseErrorListener, getParseLocationListener, getParserConfig, getRDFHandler, initializeNamespaceTableFromConfiguration, preserveBNodeIDs, 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 BufferedReader reader
protected char[] lineChars
protected int currentIndex
protected long lineNo
protected Resource subject
protected IRI predicate
protected Value object
public NTriplesParser()
SimpleValueFactory
to create object for resources, bNodes
and literals.public NTriplesParser(ValueFactory valueFactory)
valueFactory
- A ValueFactory.public RDFFormat getRDFFormat()
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 RDFParseException, RDFHandlerException
RDFParseException
RDFHandlerException
protected void skipWhitespace(boolean throwEOF)
protected boolean shouldParseLine()
protected void parseSubject()
protected void parsePredicate()
protected void parseObject()
protected void assertLineTerminates() throws RDFParseException
RDFParseException
protected void handleStatement(boolean ignoredAnError)
protected IRI parseIRI()
protected Resource parseNode()
protected IRI createURI(String uri) throws RDFParseException
AbstractRDFParser
IRI
object for the specified URI-string.createURI
in class AbstractRDFParser
RDFParseException
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(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 reportError(Exception e, RioSetting<Boolean> setting) throws RDFParseException
AbstractRDFParser
This method also throws an RDFParseException
when the given setting has been set to true and it
is not a nonFatalError.
reportError
in class AbstractRDFParser
e
- The exception whose message will be used for
ParseErrorListener.error(String, long, long)
and for
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 void clear()
AbstractRDFParser
clear
in class AbstractRDFParser
public Collection<RioSetting<?>> getSupportedSettings()
getSupportedSettings
in interface RDFParser
getSupportedSettings
in class AbstractRDFParser
RioSetting
s that are supported by this RDFParser.Copyright © 2015-2022 Eclipse Foundation. All Rights Reserved.