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 RDFParserBuildercreate()Create anRDFParserBuilder.static RDFParserBuilderfromString(String string) Create anRDFParserBuilderand set content to parse to be the given string.voidParse the source, sending the results to aGraph.voidParse the source, sending the results to aDataset.voidParse the source, sending the results to aModel.voidParse the source, sending the results to aStreamRDF.voidparse(DatasetGraph dataset) Parse the source, sending the results to aDatasetGraph.static RDFParserBuildersource(InputStream input) Create anRDFParserBuilderand set the source toInputStream.static RDFParserBuilderCreate anRDFParserBuilderand set the source to the URI, which can be a filename.static RDFParserBuilderCreate anRDFParserBuilderand set the source to thePath.Parse the source in to a freshDatasetand return the dataset.Parse the source in to a freshDatasetGraphand return the DatasetGraph.toGraph()Parse the source in to a freshGraphand return the graph.toModel()Parse the source in to a freshModeland return the model.
-
Method Details
-
create
Create anRDFParserBuilder.Often used in a pattern such as:
RDFParser.create() .source("data.ttl") .parse(graph); -
source
Create anRDFParserBuilderand set the source to thePath.This is a shortcut for
RDFParser.create().source(path).- Parameters:
path-- Returns:
- RDFParserBuilder
-
source
Create anRDFParserBuilderand 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 anRDFParserBuilderand 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 anRDFParserBuilderand set the source toInputStream. TheInputStreamwill 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 freshGraphand return the graph.The source must be for triples; any quads are discarded.
-
toModel
Parse the source in to a freshModeland return the model.The source must be for triples; any quads are discarded.
-
toDataset
Parse the source in to a freshDatasetand return the dataset. -
toDatasetGraph
Parse the source in to a freshDatasetGraphand return the DatasetGraph. -
parse
Parse the source, sending the results to aStreamRDF.
-