public class NTriplesParser extends AbstractRDFParser
RDFParser.DatatypeHandling
Modifier and Type | Field and Description |
---|---|
protected long |
lineNo |
protected Value |
object |
protected IRI |
predicate |
protected PushbackReader |
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 int |
assertLineTerminates(int c)
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 Literal |
createLiteral(String label,
String lang,
String datatype) |
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() |
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 int |
parseNodeID(int c,
StringBuilder name) |
protected int |
parseObject(int c) |
protected int |
parsePredicate(int c) |
protected int |
parseSubject(int c) |
protected int |
parseUriRef(int c,
StringBuilder uriRef) |
protected int |
peekCodePoint()
Peeks at the next Unicode code point without advancing the reader, and returns its value.
|
protected int |
readCodePoint()
Reads the next Unicode code point.
|
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 int |
skipLine(int c) |
protected int |
skipLine(int c,
StringBuilder sb)
Reads characters from reader until the first EOL has been read.
|
protected int |
skipToEndOfLine(int c)
Reads characters from reader until the first EOL has been read.
|
protected int |
skipWhitespace(int c)
Reads characters from reader until it finds a character that is not a space or tab, and returns this last
character code point.
|
protected void |
throwEOFException() |
protected void |
unread(int codePoint)
Pushes back a single code point by copying it to the front of the buffer.
|
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 PushbackReader reader
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
in
- The InputStream from which to read the data, must not be null. The InputStream is
supposed to contain 7-bit US-ASCII characters, as per the N-Triples specification.baseURI
- The URI 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.RDFParseException
- If the parser has found an unrecoverable parse error.RDFHandlerException
- If the configured statement handler encountered an unrecoverable error.IllegalArgumentException
- If the supplied input stream or base URI is null.public void parse(Reader reader, String baseURI) throws IOException, RDFParseException, 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.RDFParseException
- If the parser has found an unrecoverable parse error.RDFHandlerException
- If the configured statement handler encountered an unrecoverable error.IllegalArgumentException
- If the supplied reader or base URI is null.protected int skipWhitespace(int c) throws IOException
IOException
protected int assertLineTerminates(int c) throws IOException, RDFParseException
IOException
RDFParseException
protected int skipToEndOfLine(int c) throws IOException
IOException
protected int skipLine(int c, StringBuilder sb) throws IOException
IOException
protected int skipLine(int c) throws IOException
IOException
protected int parseSubject(int c) throws IOException, RDFParseException
IOException
RDFParseException
protected int parsePredicate(int c) throws IOException, RDFParseException
IOException
RDFParseException
protected int parseObject(int c) throws IOException, RDFParseException
IOException
RDFParseException
protected int parseUriRef(int c, StringBuilder uriRef) throws IOException, RDFParseException
IOException
RDFParseException
protected int parseNodeID(int c, StringBuilder name) throws IOException, RDFParseException
IOException
RDFParseException
protected int peekCodePoint() 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 IRI createURI(String uri) throws RDFParseException
AbstractRDFParser
IRI
object for the specified URI-string.createURI
in class AbstractRDFParser
RDFParseException
protected int readCodePoint() throws IOException
IOException
protected Literal createLiteral(String label, String lang, String datatype) throws RDFParseException
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.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.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-2020 Eclipse Foundation. All Rights Reserved.