01: /*
02: * Copyright Aduna (http://www.aduna-software.com/) (c) 1997-2007.
03: *
04: * Licensed under the Aduna BSD-style license.
05: */
06: package org.openrdf.http.protocol.transaction.operations;
07:
08: import info.aduna.lang.ObjectUtil;
09:
10: import org.openrdf.repository.RepositoryConnection;
11: import org.openrdf.repository.RepositoryException;
12:
13: /**
14: * Operation that sets the namespace for a specific prefix.
15: *
16: * @author Arjohn Kampman
17: */
18: public class SetNamespaceOperation implements TransactionOperation {
19:
20: private String prefix;
21:
22: private String name;
23:
24: public SetNamespaceOperation() {
25: }
26:
27: public SetNamespaceOperation(String prefix, String name) {
28: setPrefix(prefix);
29: setName(name);
30: }
31:
32: public String getName() {
33: return name;
34: }
35:
36: public void setName(String name) {
37: this .name = name;
38: }
39:
40: public String getPrefix() {
41: return prefix;
42: }
43:
44: public void setPrefix(String prefix) {
45: this .prefix = prefix;
46: }
47:
48: public void execute(RepositoryConnection con)
49: throws RepositoryException {
50: con.setNamespace(prefix, name);
51: }
52:
53: @Override
54: public boolean equals(Object other) {
55: if (other instanceof SetNamespaceOperation) {
56: SetNamespaceOperation o = (SetNamespaceOperation) other;
57: return ObjectUtil.nullEquals(getPrefix(), o.getPrefix())
58: && ObjectUtil.nullEquals(getName(), o.getName());
59: }
60:
61: return false;
62: }
63:
64: @Override
65: public int hashCode() {
66: int hashCode = ObjectUtil.nullHashCode(getPrefix());
67: hashCode = 31 * hashCode + ObjectUtil.nullHashCode(getName());
68: return hashCode;
69: }
70: }
|