public class RDFParser extends Object
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.Modifier and Type | Method and Description |
---|---|
static RDFParserBuilder |
create()
Create an
RDFParserBuilder . |
static RDFParserBuilder |
fromString(String string)
Create an
RDFParserBuilder and set content to parse to be the
given string. |
void |
parse(Dataset dataset)
Parse the source, sending the results to a
Dataset . |
void |
parse(DatasetGraph dataset)
Parse the source, sending the results to a
DatasetGraph . |
void |
parse(Graph graph)
Parse the source, sending the results to a
Graph . |
void |
parse(Model model)
Parse the source, sending the results to a
Model . |
void |
parse(StreamRDF destination)
Parse the source, sending the results to a
StreamRDF . |
static RDFParserBuilder |
source(InputStream input)
Create an
RDFParserBuilder and set the source to InputStream . |
static RDFParserBuilder |
source(Path path)
Create an
RDFParserBuilder and set the source to the
Path . |
static RDFParserBuilder |
source(String uriOrFile)
Create an
RDFParserBuilder and set the source to the URI, which
can be a filename. |
public static RDFParserBuilder create()
RDFParserBuilder
.
Often used in a pattern such as:
RDFParser.create() .source("data.ttl") .parse(graph);
public static RDFParserBuilder source(Path path)
RDFParserBuilder
and set the source to the
Path
.
This is a shortcut for RDFParser.create().source(path)
.
path
- public static RDFParserBuilder source(String uriOrFile)
RDFParserBuilder
and set the source to the URI, which
can be a filename.
This is a shortcut for RDFParser.create().source(uriOrFile)
.
uriOrFile
- public static RDFParserBuilder fromString(String string)
RDFParserBuilder
and set content to parse to be the
given string. The syntax must be set with .lang(...)
.
Shortcut for RDFParser.create.fromString(string)
.
string
- public static RDFParserBuilder source(InputStream input)
RDFParserBuilder
and set the source to InputStream
.
The InputStream
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)
.
input
- public void parse(Graph graph)
Graph
. The source must be for
triples; any quads are discarded.public void parse(Model model)
Model
.
The source must be for triples; any quads are discarded.
This method is equivalent to parse(model.getGraph())
.public void parse(DatasetGraph dataset)
DatasetGraph
.public void parse(Dataset dataset)
Dataset
.
This method is equivalent to parse(dataset.asDatasetGraph())
.Licenced under the Apache License, Version 2.0