Package org.eclipse.rdf4j.rio.ntriples
Class NTriplesParser
- java.lang.Object
-
- org.eclipse.rdf4j.rio.helpers.AbstractRDFParser
-
- org.eclipse.rdf4j.rio.ntriples.NTriplesParser
-
- All Implemented Interfaces:
RDFParser
public class NTriplesParser extends AbstractRDFParser
RDF parser for N-Triples files. A specification of NTriples can be found in this section of the RDF Test Cases document. This parser is not thread-safe, therefore its public methods are synchronized.- Author:
- Arjohn Kampman
-
-
Field Summary
Fields Modifier and Type Field Description protected intcurrentIndexprotected char[]lineCharsprotected longlineNoprotected org.eclipse.rdf4j.model.Valueobjectprotected org.eclipse.rdf4j.model.IRIpredicateprotected BufferedReaderreaderprotected org.eclipse.rdf4j.model.Resourcesubject-
Fields inherited from class org.eclipse.rdf4j.rio.helpers.AbstractRDFParser
rdfHandler, valueFactory
-
-
Constructor Summary
Constructors Constructor Description NTriplesParser()Creates a new NTriplesParser that will use aSimpleValueFactoryto create object for resources, bNodes and literals.NTriplesParser(org.eclipse.rdf4j.model.ValueFactory valueFactory)Creates a new NTriplesParser that will use the supplied ValueFactory to create RDF model objects.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidassertLineTerminates()Verifies that there is only whitespace or comments until the end of the line.protected voidclear()protected org.eclipse.rdf4j.model.IRIcreateURI(String uri)RDFFormatgetRDFFormat()Collection<RioSetting<?>>getSupportedSettings()protected voidhandleStatement(boolean ignoredAnError)voidparse(InputStream in, String baseURI)voidparse(Reader reader, String baseURI)protected org.eclipse.rdf4j.model.IRIparseIRI()protected org.eclipse.rdf4j.model.ResourceparseNode()protected voidparseObject()protected voidparsePredicate()protected voidparseStatement()protected voidparseSubject()protected voidreportError(Exception e, RioSetting<Boolean> setting)protected voidreportError(String msg, RioSetting<Boolean> setting)OverridesAbstractRDFParser.reportError(String, RioSetting), adding line number information to the error.protected voidreportFatalError(Exception e)OverridesAbstractRDFParser.reportFatalError(Exception), adding line number information to the error.protected voidreportFatalError(String msg)OverridesAbstractRDFParser.reportFatalError(String), adding line number information to the error.protected voidreportWarning(String msg)OverridesAbstractRDFParser.reportWarning(String), adding line number information to the error.protected booleanshouldParseLine()protected voidskipWhitespace(boolean throwEOF)protected voidthrowEOFException()-
Methods inherited from class org.eclipse.rdf4j.rio.helpers.AbstractRDFParser
clearBNodeIDMap, createBNode, createBNode, createLiteral, createLiteral, createLiteral, createNode, createNode, createStatement, createStatement, getNamespace, getParseErrorListener, getParseLocationListener, getParserConfig, getRDFHandler, initializeNamespaceTableFromConfiguration, preserveBNodeIDs, reportError, reportError, reportError, reportFatalError, reportFatalError, reportFatalError, reportLocation, reportWarning, resolveURI, set, setBaseURI, setBaseURI, setNamespace, setParseErrorListener, setParseLocationListener, setParserConfig, setPreserveBNodeIDs, setRDFHandler, setValueFactory
-
-
-
-
Field Detail
-
reader
protected BufferedReader reader
-
lineChars
protected char[] lineChars
-
currentIndex
protected int currentIndex
-
lineNo
protected long lineNo
-
subject
protected org.eclipse.rdf4j.model.Resource subject
-
predicate
protected org.eclipse.rdf4j.model.IRI predicate
-
object
protected org.eclipse.rdf4j.model.Value object
-
-
Constructor Detail
-
NTriplesParser
public NTriplesParser()
Creates a new NTriplesParser that will use aSimpleValueFactoryto create object for resources, bNodes and literals.
-
NTriplesParser
public NTriplesParser(org.eclipse.rdf4j.model.ValueFactory valueFactory)
Creates a new NTriplesParser that will use the supplied ValueFactory to create RDF model objects.- Parameters:
valueFactory- A ValueFactory.
-
-
Method Detail
-
getRDFFormat
public RDFFormat getRDFFormat()
-
parse
public void parse(InputStream in, String baseURI) throws IOException, RDFParseException, RDFHandlerException
-
parse
public void parse(Reader reader, String baseURI) throws IOException, RDFParseException, RDFHandlerException
-
parseStatement
protected void parseStatement() throws RDFParseException, RDFHandlerException- Throws:
RDFParseExceptionRDFHandlerException
-
skipWhitespace
protected void skipWhitespace(boolean throwEOF)
-
shouldParseLine
protected boolean shouldParseLine()
-
parseSubject
protected void parseSubject()
-
parsePredicate
protected void parsePredicate()
-
parseObject
protected void parseObject()
-
assertLineTerminates
protected void assertLineTerminates() throws RDFParseExceptionVerifies that there is only whitespace or comments until the end of the line.- Throws:
RDFParseException
-
handleStatement
protected void handleStatement(boolean ignoredAnError)
-
parseIRI
protected org.eclipse.rdf4j.model.IRI parseIRI()
-
parseNode
protected org.eclipse.rdf4j.model.Resource parseNode()
-
createURI
protected org.eclipse.rdf4j.model.IRI createURI(String uri) throws RDFParseException
- Overrides:
createURIin classAbstractRDFParser- Throws:
RDFParseException
-
reportWarning
protected void reportWarning(String msg)
OverridesAbstractRDFParser.reportWarning(String), adding line number information to the error.- Overrides:
reportWarningin classAbstractRDFParser
-
reportError
protected void reportError(String msg, RioSetting<Boolean> setting) throws RDFParseException
OverridesAbstractRDFParser.reportError(String, RioSetting), adding line number information to the error.- Overrides:
reportErrorin classAbstractRDFParser- Throws:
RDFParseException
-
reportError
protected void reportError(Exception e, RioSetting<Boolean> setting) throws RDFParseException
- Overrides:
reportErrorin classAbstractRDFParser- Throws:
RDFParseException
-
reportFatalError
protected void reportFatalError(String msg) throws RDFParseException
OverridesAbstractRDFParser.reportFatalError(String), adding line number information to the error.- Overrides:
reportFatalErrorin classAbstractRDFParser- Throws:
RDFParseException
-
reportFatalError
protected void reportFatalError(Exception e) throws RDFParseException
OverridesAbstractRDFParser.reportFatalError(Exception), adding line number information to the error.- Overrides:
reportFatalErrorin classAbstractRDFParser- Throws:
RDFParseException
-
throwEOFException
protected void throwEOFException() throws RDFParseException- Throws:
RDFParseException
-
clear
protected void clear()
- Overrides:
clearin classAbstractRDFParser
-
getSupportedSettings
public Collection<RioSetting<?>> getSupportedSettings()
- Specified by:
getSupportedSettingsin interfaceRDFParser- Overrides:
getSupportedSettingsin classAbstractRDFParser
-
-