Package org.apache.jena.riot
Class RDFParser
- java.lang.Object
-
- org.apache.jena.riot.RDFParser
-
public class RDFParser extends java.lang.ObjectAnRDFParseris a process that will generate triples;RDFParserBuilderprovides the means to setup the parser.An
RDFParserhas 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 isStreamRDF destination = ... RDFParser parser = RDFParser.create().source("filename.ttl").build(); parser.parse(destination);or using abbreviated forms:RDFParser.source("filename.ttl").parse(destination);ThedestinationStreamRDFand can be given as aGraphorDatasetGraphas well.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static RDFParserBuildercreate()Create anRDFParserBuilder.static RDFParserBuilderfromString(java.lang.String string)Create anRDFParserBuilderand set content to parse to be the given string.voidparse(Graph graph)Parse the source, sending the results to aGraph.voidparse(Dataset dataset)Parse the source, sending the results to aDataset.voidparse(Model model)Parse the source, sending the results to aModel.voidparse(StreamRDF destination)Parse the source, sending the results to aStreamRDF.voidparse(DatasetGraph dataset)Parse the source, sending the results to aDatasetGraph.static RDFParserBuildersource(java.io.InputStream input)Create anRDFParserBuilderand set the source toInputStream.static RDFParserBuildersource(java.lang.String uriOrFile)Create anRDFParserBuilderand set the source to the URI, which can be a filename.static RDFParserBuildersource(java.nio.file.Path path)Create anRDFParserBuilderand set the source to thePath.
-
-
-
Method Detail
-
create
public static RDFParserBuilder create()
Create anRDFParserBuilder.Often used in a pattern such as:
RDFParser.create() .source("data.ttl") .parse(graph);
-
source
public static RDFParserBuilder source(java.nio.file.Path path)
Create anRDFParserBuilderand set the source to thePath.This is a shortcut for
RDFParser.create().source(path).- Parameters:
path-- Returns:
- RDFParserBuilder
-
source
public static RDFParserBuilder source(java.lang.String uriOrFile)
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
public static RDFParserBuilder fromString(java.lang.String string)
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
public static RDFParserBuilder source(java.io.InputStream input)
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
public void parse(Graph graph)
Parse the source, sending the results to aGraph. The source must be for triples; any quads are discarded.
-
parse
public void parse(Model model)
Parse the source, sending the results to aModel. The source must be for triples; any quads are discarded. This method is equivalent toparse(model.getGraph()).
-
parse
public void parse(DatasetGraph dataset)
Parse the source, sending the results to aDatasetGraph.
-
parse
public void parse(Dataset dataset)
Parse the source, sending the results to aDataset. This method is equivalent toparse(dataset.asDatasetGraph()).
-
-