Skip to content

Commit

Permalink
JENA-1389: Merge commit 'refs/pull/362/head' of https://github.com/ap…
Browse files Browse the repository at this point in the history
  • Loading branch information
afs committed Feb 16, 2018
2 parents b70c39a + d21aba2 commit 89e6a8d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 12 deletions.
38 changes: 30 additions & 8 deletions jena-arq/src/main/java/org/apache/jena/query/Dataset.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,45 @@ public interface Dataset extends Transactional
/** Get the graph which is the unionof all named graphs as a Jena Model */
public Model getUnionModel() ;

/** Set the default graph. Can be set to null for none. */
public void setDefaultModel(Model model) ;
/**
* Set the default graph. Can be set to null for none.
*
* @param model the default graph to set
* @return this {@code Dataset} for continued usage
*/
public Dataset setDefaultModel(Model model);

/** Get a graph by name as a Jena Model */
public Model getNamedModel(String uri) ;

/** Does the dataset contain a model with the name supplied? */
public boolean containsNamedModel(String uri) ;

/** Set a named graph. */
public void addNamedModel(String uri, Model model) ;
/**
* Set a named graph.
*
* @param uri the name of the graph to set
* @param model the graph to set
* @return this {@code Dataset} for continued usage
*/
public Dataset addNamedModel(String uri, Model model);

/** Remove a named graph. */
public void removeNamedModel(String uri) ;
/**
* Remove a named graph.
*
* @param uri the name of the gaph to remove
* @return this {@code Dataset} for continued usage
*/
public Dataset removeNamedModel(String uri);

/** Change a named graph for another using the same name */
public void replaceNamedModel(String uri, Model model) ;
/**
* Change a named graph for another using the same name
*
* @param uri the name of the graph to replace
* @param model the graph with which to replace it
* @return this {@code Dataset} for continued usage
*/
public Dataset replaceNamedModel(String uri, Model model);

/** List the names */
public Iterator<String> listNames() ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,33 +182,37 @@ public Model getNamedModel(String uri) {
}

@Override
public void addNamedModel(String uri, Model model) {
public Dataset addNamedModel(String uri, Model model) {
checkGraphName(uri) ;
Node n = NodeFactory.createURI(uri) ;
dsg.addGraph(n, model.getGraph()) ;
return this;
}

@Override
public void removeNamedModel(String uri) {
public Dataset removeNamedModel(String uri) {
checkGraphName(uri) ;
Node n = NodeFactory.createURI(uri) ;
dsg.removeGraph(n) ;
return this;
}

@Override
public void replaceNamedModel(String uri, Model model) {
public Dataset replaceNamedModel(String uri, Model model) {
// Assumes single writer.
checkGraphName(uri) ;
Node n = NodeFactory.createURI(uri) ;
dsg.removeGraph(n) ;
dsg.addGraph(n, model.getGraph() ) ;
return this;
}

@Override
public void setDefaultModel(Model model) {
public Dataset setDefaultModel(Model model) {
if ( model == null )
model = ModelFactory.createDefaultModel() ;
dsg.setDefaultGraph(model.getGraph()) ;
return this;
}

@Override
Expand Down

0 comments on commit 89e6a8d

Please sign in to comment.