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.TRIGandRDFSyntax.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 classRDF4JParser.AddToModelprivate classRDF4JParser.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.ParserConfigparserConfigprivate RDF4Jrdf4jTermFactory-
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 RDF4JcreateRDFTermFactory()Create a newRDFfor a parse session.org.eclipse.rdf4j.rio.ParserConfiggetParserConfig()Get the RDF4JParserConfigto use.protected org.eclipse.rdf4j.rio.RDFHandlermakeRDFHandler()protected voidparseSynchronusly()protected RDF4JParserprepareForParsing()Prepare a clone of this RDFParser which have been checked and completed.voidsetParserConfig(org.eclipse.rdf4j.rio.ParserConfig parserConfig)Set an RDF4JParserConfigto 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:AbstractRDFParserCreate a newRDFfor 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:
createRDFTermFactoryin classAbstractRDFParser<RDF4JParser>- Returns:
- A new
RDF
-
prepareForParsing
protected RDF4JParser prepareForParsing() throws java.io.IOException, java.lang.IllegalStateException
Description copied from class:AbstractRDFParserPrepare 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:
prepareForParsingin 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.IOExceptionDescription copied from class:AbstractRDFParserParseAbstractRDFParser.sourceInputStream,AbstractRDFParser.sourceFileorAbstractRDFParser.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:
parseSynchronuslyin classAbstractRDFParser<RDF4JParser>- Throws:
java.io.IOException- If the source could not be read
-
getParserConfig
public org.eclipse.rdf4j.rio.ParserConfig getParserConfig()
Get the RDF4JParserConfigto 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
ParserConfigand setsetParserConfig(ParserConfig).- Returns:
- The RDF4J
ParserConfig
-
setParserConfig
public void setParserConfig(org.eclipse.rdf4j.rio.ParserConfig parserConfig)
Set an RDF4JParserConfigto use- Parameters:
parserConfig- Parser configuration
-
makeRDFHandler
protected org.eclipse.rdf4j.rio.RDFHandler makeRDFHandler()
-
-