KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > repo > domain > NodeKey


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.repo.domain;
18
19 import java.io.Serializable JavaDoc;
20
21 import org.alfresco.util.EqualsHelper;
22
23 /**
24  * Compound key for persistence of {@link org.alfresco.repo.domain.Node}
25  *
26  * @author Derek Hulley
27  */

28 public class NodeKey implements Serializable JavaDoc
29 {
30     private static final long serialVersionUID = 3258695403221300023L;
31     
32     private String JavaDoc guid;
33     private String JavaDoc protocol;
34     private String JavaDoc identifier;
35
36     public NodeKey()
37     {
38     }
39     
40     public NodeKey(StoreKey storeKey, String JavaDoc guid)
41     {
42         setGuid(guid);
43         setProtocol(storeKey.getProtocol());
44         setIdentifier(storeKey.getIdentifier());
45     }
46     
47     public NodeKey(String JavaDoc protocol, String JavaDoc identifier, String JavaDoc guid)
48     {
49         setGuid(guid);
50         setProtocol(protocol);
51         setIdentifier(identifier);
52     }
53     
54     public String JavaDoc toString()
55     {
56         return ("NodeKey[" +
57                 " id=" + guid +
58                 ", protocol=" + protocol +
59                 ", identifier=" + identifier +
60                 "]");
61     }
62     
63     public int hashCode()
64     {
65         return this.guid.hashCode();
66     }
67
68     public boolean equals(Object JavaDoc obj)
69     {
70         if (this == obj)
71         {
72             return true;
73         }
74         else if (!(obj instanceof NodeKey))
75         {
76             return false;
77         }
78         NodeKey that = (NodeKey) obj;
79         return (EqualsHelper.nullSafeEquals(this.guid, that.guid) &&
80                 EqualsHelper.nullSafeEquals(this.protocol, that.protocol) &&
81                 EqualsHelper.nullSafeEquals(this.identifier, that.identifier)
82                 );
83     }
84     
85     public String JavaDoc getGuid()
86     {
87         return guid;
88     }
89     
90     /**
91      * Tamper-proof method only to be used by introspectors
92      */

93     private void setGuid(String JavaDoc id)
94     {
95         this.guid = id;
96     }
97     
98     public String JavaDoc getProtocol()
99     {
100         return protocol;
101     }
102     
103     /**
104      * Tamper-proof method only to be used by introspectors
105      */

106     private void setProtocol(String JavaDoc protocol)
107     {
108         this.protocol = protocol;
109     }
110     
111     public String JavaDoc getIdentifier()
112     {
113         return identifier;
114     }
115     
116     /**
117      * Tamper-proof method only to be used by introspectors
118      */

119     private void setIdentifier(String JavaDoc identifier)
120     {
121         this.identifier = identifier;
122     }
123 }
124
Popular Tags