Class RDF4JParser
- java.lang.Object
-
- org.apache.commons.rdf.simple.experimental.AbstractRDFParser<RDF4JParser>
-
- org.apache.commons.rdf.rdf4j.experimental.RDF4JParser
-
- All Implemented Interfaces:
java.lang.Cloneable
,RDFParser
public class RDF4JParser extends AbstractRDFParser<RDF4JParser>
RDF4J-based parser.This can handle the RDF syntaxes
RDFSyntax.JSONLD
,RDFSyntax.NQUADS
,RDFSyntax.NTRIPLES
,RDFSyntax.RDFXML
,RDFSyntax.TRIG
andRDFSyntax.TURTLE
- additional syntaxes can be supported by including the corresponding rdf4j-rio-* module on the classpath.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
RDF4JParser.AddToModel
private class
RDF4JParser.AddToQuadConsumer
-
Nested classes/interfaces inherited from interface org.apache.commons.rdf.experimental.RDFParser
RDFParser.ParseResult
-
-
Field Summary
Fields Modifier and Type Field Description private org.eclipse.rdf4j.rio.ParserConfig
parserConfig
private RDF4J
rdf4jTermFactory
-
Fields inherited from class org.apache.commons.rdf.simple.experimental.AbstractRDFParser
threadGroup
-
-
Constructor Summary
Constructors Constructor Description RDF4JParser()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected RDF4J
createRDFTermFactory()
Create a newRDF
for a parse session.org.eclipse.rdf4j.rio.ParserConfig
getParserConfig()
Get the RDF4JParserConfig
to use.protected org.eclipse.rdf4j.rio.RDFHandler
makeRDFHandler()
protected void
parseSynchronusly()
protected RDF4JParser
prepareForParsing()
Prepare a clone of this RDFParser which have been checked and completed.void
setParserConfig(org.eclipse.rdf4j.rio.ParserConfig parserConfig)
Set an RDF4JParserConfig
to use-
Methods inherited from class org.apache.commons.rdf.simple.experimental.AbstractRDFParser
asT, base, base, checkBaseRequired, checkContentType, checkIsAbsolute, checkSource, checkTarget, clone, contentType, contentType, getBase, getContentType, getContentTypeSyntax, getRdfTermFactory, getSourceFile, getSourceInputStream, getSourceIri, getTarget, getTargetDataset, getTargetGraph, guessRDFSyntax, parse, rdfTermFactory, resetSource, resetTarget, source, source, source, source, target, target, target
-
-
-
-
Field Detail
-
rdf4jTermFactory
private RDF4J rdf4jTermFactory
-
parserConfig
private org.eclipse.rdf4j.rio.ParserConfig parserConfig
-
-
Method Detail
-
createRDFTermFactory
protected RDF4J createRDFTermFactory()
Description copied from class:AbstractRDFParser
Create a newRDF
for a parse session.This is called by
AbstractRDFParser.parse()
to setAbstractRDFParser.rdfTermFactory(RDF)
if it isOptional.empty()
.As parsed blank nodes might be made with
RDF.createBlankNode(String)
, each call to this method SHOULD return a new RDF instance.- Overrides:
createRDFTermFactory
in classAbstractRDFParser<RDF4JParser>
- Returns:
- A new
RDF
-
prepareForParsing
protected RDF4JParser prepareForParsing() throws java.io.IOException, java.lang.IllegalStateException
Description copied from class:AbstractRDFParser
Prepare a clone of this RDFParser which have been checked and completed.The returned clone will always have
AbstractRDFParser.getTarget()
andAbstractRDFParser.getRdfTermFactory()
present.If the
AbstractRDFParser.getSourceFile()
is present, but theAbstractRDFParser.getBase()
is not present, the base will be set to thefile:///
IRI for the Path's real path (e.g. resolving any symbolic links).- Overrides:
prepareForParsing
in classAbstractRDFParser<RDF4JParser>
- Returns:
- A completed and checked clone of this RDFParser
- Throws:
java.io.IOException
- If the source was not accessible (e.g. a file was not found)java.lang.IllegalStateException
- If the parser was not in a compatible setting (e.g. contentType was an invalid string)
-
parseSynchronusly
protected void parseSynchronusly() throws java.io.IOException
Description copied from class:AbstractRDFParser
ParseAbstractRDFParser.sourceInputStream
,AbstractRDFParser.sourceFile
orAbstractRDFParser.sourceIri
.One of the source fields MUST be present, as checked by
AbstractRDFParser.checkSource()
.AbstractRDFParser.checkBaseRequired()
is called to verify ifAbstractRDFParser.getBase()
is required.- Specified by:
parseSynchronusly
in classAbstractRDFParser<RDF4JParser>
- Throws:
java.io.IOException
- If the source could not be read
-
getParserConfig
public org.eclipse.rdf4j.rio.ParserConfig getParserConfig()
Get the RDF4JParserConfig
to use.If no parser config is set, the default configuration is provided.
Note: The parser config is mutable - changes in the returned config is reflected in this instance of the parser. To avoid mutation, create a new
ParserConfig
and setsetParserConfig(ParserConfig)
.- Returns:
- The RDF4J
ParserConfig
-
setParserConfig
public void setParserConfig(org.eclipse.rdf4j.rio.ParserConfig parserConfig)
Set an RDF4JParserConfig
to use- Parameters:
parserConfig
- Parser configuration
-
makeRDFHandler
protected org.eclipse.rdf4j.rio.RDFHandler makeRDFHandler()
-
-