RDFParser
is a process that will generate triples; RDFParserBuilder
provides the means to setup the parser.
An RDFParser
has a predefined source; the target for output is given when the
"parse" method is called. It can be used multiple times in which case the same source
is reread. The destination can vary. The application is responsible for concurrency of
the destination of the parse operation.
The process is
StreamRDF destination = ... RDFParser parser = RDFParser.create().source("filename.ttl").build(); parser.parse(destination);or using abbreviated forms:
RDFParser.source("filename.ttl").parse(destination);The
destination
StreamRDF
and can be given as a
Graph
or DatasetGraph
as well.-
Method Summary
Modifier and TypeMethodDescriptionstatic RDFParserBuilder
create()
Create anRDFParserBuilder
.static RDFParserBuilder
fromString
(String string) Create anRDFParserBuilder
and set content to parse to be the given string.void
Parse the source, sending the results to aGraph
.void
Parse the source, sending the results to aDataset
.void
Parse the source, sending the results to aModel
.void
Parse the source, sending the results to aStreamRDF
.void
parse
(DatasetGraph dataset) Parse the source, sending the results to aDatasetGraph
.static RDFParserBuilder
source
(InputStream input) Create anRDFParserBuilder
and set the source toInputStream
.static RDFParserBuilder
Create anRDFParserBuilder
and set the source to the URI, which can be a filename.static RDFParserBuilder
Create anRDFParserBuilder
and set the source to thePath
.Parse the source in to a freshDataset
and return the dataset.Parse the source in to a freshDatasetGraph
and return the DatasetGraph.toGraph()
Parse the source in to a freshGraph
and return the graph.toModel()
Parse the source in to a freshModel
and return the model.
-
Method Details
-
create
Create anRDFParserBuilder
.Often used in a pattern such as:
RDFParser.create() .source("data.ttl") .parse(graph);
-
source
Create anRDFParserBuilder
and set the source to thePath
.This is a shortcut for
RDFParser.create().source(path)
.- Parameters:
path
-- Returns:
- RDFParserBuilder
-
source
Create anRDFParserBuilder
and set the source to the URI, which can be a filename.This is a shortcut for
RDFParser.create().source(uriOrFile)
.- Parameters:
uriOrFile
-- Returns:
- RDFParserBuilder
-
fromString
Create anRDFParserBuilder
and set content to parse to be the given string. The syntax must be set with.lang(...)
.Shortcut for
RDFParser.create.fromString(string)
.- Parameters:
string
-- Returns:
- RDFParserBuilder
-
source
Create anRDFParserBuilder
and set the source toInputStream
. TheInputStream
will be closed when the parser is called and the parser can not be reused. The syntax must be set with.lang(...)
.This is a shortcut for
RDFParser.create().source(input)
.- Parameters:
input
-- Returns:
- RDFParserBuilder
-
parse
Parse the source, sending the results to aGraph
.The source must be for triples; any quads are discarded.
-
parse
Parse the source, sending the results to aModel
.The source must be for triples; any quads are discarded.
This method is equivalent to
parse(model.getGraph())
. -
parse
Parse the source, sending the results to aDatasetGraph
. -
parse
Parse the source, sending the results to aDataset
. This method is equivalent toparse(dataset.asDatasetGraph())
. -
toGraph
Parse the source in to a freshGraph
and return the graph.The source must be for triples; any quads are discarded.
-
toModel
Parse the source in to a freshModel
and return the model.The source must be for triples; any quads are discarded.
-
toDataset
Parse the source in to a freshDataset
and return the dataset. -
toDatasetGraph
Parse the source in to a freshDatasetGraph
and return the DatasetGraph. -
parse
Parse the source, sending the results to aStreamRDF
.
-