Class RDF4JParser
This can handle the RDF syntaxes RDFSyntax.JSONLD
,
RDFSyntax.NQUADS
, RDFSyntax.NTRIPLES
,
RDFSyntax.RDFXML
, RDFSyntax.TRIG
and RDFSyntax.TURTLE
- additional syntaxes can be supported by including the corresponding
rdf4j-rio-* module on the classpath.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
private final class
Nested classes/interfaces inherited from interface org.apache.commons.rdf.experimental.RDFParser
RDFParser.ParseResult
-
Field Summary
FieldsFields inherited from class org.apache.commons.rdf.simple.experimental.AbstractRDFParser
threadGroup
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected RDF4J
Create a newRDF
for a parse session.org.eclipse.rdf4j.rio.ParserConfig
Get the RDF4JParserConfig
to use.protected org.eclipse.rdf4j.rio.RDFHandler
protected void
protected RDF4JParser
Prepare a clone of this RDFParser which have been checked and completed.void
setParserConfig
(org.eclipse.rdf4j.rio.ParserConfig parserConfig) Set an RDF4JParserConfig
to useMethods 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 Details
-
rdf4jTermFactory
-
parserConfig
private org.eclipse.rdf4j.rio.ParserConfig parserConfig
-
-
Constructor Details
-
RDF4JParser
public RDF4JParser()
-
-
Method Details
-
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
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:
IOException
- If the source was not accessible (e.g. a file was not found)IllegalStateException
- If the parser was not in a compatible setting (e.g. contentType was an invalid string)
-
parseSynchronusly
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:
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()
-