View Javadoc

1   /*
2    * Copyright James Leigh (c) 2007.
3    *
4    * Licensed under the Aduna BSD-style license.
5    */
6   package org.openrdf.repository.memento;
7   
8   import org.openrdf.model.Resource;
9   import org.openrdf.model.URI;
10  import org.openrdf.model.Value;
11  import org.openrdf.repository.RepositoryConnection;
12  import org.openrdf.repository.RepositoryException;
13  
14  /**
15   * Command object for statements that are removed from the repository.
16   * 
17   * @author James Leigh
18   * 
19   */
20  class RemoveCommand implements Command {
21  	private Resource subj;
22  
23  	private URI pred;
24  
25  	private Value obj;
26  
27  	private Resource[] ctx;
28  
29  	public RemoveCommand(Resource subj, URI pred, Value obj, Resource... ctx) {
30  		this.subj = subj;
31  		this.pred = pred;
32  		this.obj = obj;
33  		this.ctx = ctx;
34  	}
35  
36  	public void undo(RepositoryConnection conn) throws RepositoryException {
37  		conn.add(subj, pred, obj, ctx);
38  	}
39  
40  	public void redo(RepositoryConnection conn) throws RepositoryException {
41  		conn.remove(subj, pred, obj, ctx);
42  	}
43  }