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.repository.RepositoryConnection;
9   import org.openrdf.repository.RepositoryException;
10  
11  /**
12   * Saves a single change to the namespace.
13   * 
14   * @author James Leigh
15   * 
16   */
17  class OverrideNamespaceCommand implements Command {
18  	private String prefix;
19  
20  	private String oldNS;
21  
22  	private String newNS;
23  
24  	public OverrideNamespaceCommand(String prefix, String oldNS, String newNS) {
25  		super();
26  		this.prefix = prefix;
27  		this.oldNS = oldNS;
28  		this.newNS = newNS;
29  	}
30  
31  	public void undo(RepositoryConnection conn) throws RepositoryException {
32  		if (oldNS == null) {
33  			conn.removeNamespace(prefix);
34  		} else {
35  			conn.setNamespace(prefix, oldNS);
36  		}
37  	}
38  
39  	public void redo(RepositoryConnection conn) throws RepositoryException {
40  		if (newNS == null) {
41  			conn.removeNamespace(prefix);
42  		} else {
43  			conn.setNamespace(prefix, newNS);
44  		}
45  	}
46  
47  }