We're updating the issue view to help you get more done. 

Add Rio.parse static methods to parse directly to a Model

Description

There are currently no static methods in Rio for parsing to a Model using the other Rio methods:

RDFFormat format = Rio.getParserFormatForFileName(filename) [or by MIMEType]

Model model = new LinkedHashModel();
RDFParser parser = Rio.createParser(format);
parser.setRDFHandler(new StatementCollector(model));
parser.parse(inputStream, baseURI);
return model;

In the worst case, the lack of these methods is causing people (on my projects and other projects) to create a SailRepository(MemoryStore) so that they can use the RepositoryConnection.add method.

Current ideas for signatures are (based on RepositoryConnection.add):

class Rio {

static Model parse(InputStream in, String baseURI, RDFFormat dataFormat, Resource... contexts) throws IOException, UnsupportedRDFormatException, RDFParseException;

static Model parse(Reader reader, String baseURI, RDFFormat dataFormat, Resource... contexts) throws IOException, UnsupportedRDFormatException, RDFParseException;

}

Then users would only need to decide on the RDFFormat before parsing in a single line.

The contexts would get assigned to all statements that were parsed, or if there were no contexts given and the format supported contexts, then the original contexts would be preserved.

Environment

None

Status

Assignee

Peter Ansell

Reporter

Peter Ansell

Labels

None

Components

Fix versions

Affects versions

2.7.0

Priority

Major