KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > repo > domain > hibernate > StoreImpl


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.hibernate;
18
19 import org.alfresco.repo.domain.Node;
20 import org.alfresco.repo.domain.Store;
21 import org.alfresco.repo.domain.StoreKey;
22 import org.alfresco.service.cmr.repository.StoreRef;
23
24 /**
25  * Hibernate-specific implementation of the domain entity <b>store</b>.
26  *
27  * @author Derek Hulley
28  */

29 public class StoreImpl implements Store
30 {
31     private StoreKey key;
32     private Node rootNode;
33     private transient StoreRef storeRef;
34
35     public StoreImpl()
36     {
37     }
38     
39     /**
40      * @see #getKey()
41      */

42     public boolean equals(Object JavaDoc obj)
43     {
44         if (obj == null)
45         {
46             return false;
47         }
48         else if (obj == this)
49         {
50             return true;
51         }
52         else if (!(obj instanceof Node))
53         {
54             return false;
55         }
56         Node that = (Node) obj;
57         return (this.getKey().equals(that.getKey()));
58     }
59     
60     /**
61      * @see #getKey()
62      */

63     public int hashCode()
64     {
65         return getKey().hashCode();
66     }
67     
68     /**
69      * @see #getStoreRef()()
70      */

71     public String JavaDoc toString()
72     {
73         return getStoreRef().toString();
74     }
75
76     public StoreKey getKey() {
77         return key;
78     }
79
80     public synchronized void setKey(StoreKey key) {
81         this.key = key;
82         this.storeRef = null;
83     }
84
85     public Node getRootNode()
86     {
87         return rootNode;
88     }
89
90     public void setRootNode(Node rootNode)
91     {
92         this.rootNode = rootNode;
93     }
94     
95     /**
96      * Lazily constructs <code>StoreRef</code> instance referencing this entity
97      */

98     public synchronized StoreRef getStoreRef()
99     {
100         if (storeRef == null && key != null)
101         {
102             storeRef = new StoreRef(key.getProtocol(), key.getIdentifier());
103         }
104         return storeRef;
105     }
106 }
Popular Tags