KickJava   Java API By Example, From Geeks To Geeks.

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


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

29 public class VersionCountImpl implements VersionCount
30 {
31     private StoreKey key;
32     private int versionCount;
33     private transient StoreRef storeRef;
34
35     public VersionCountImpl()
36     {
37         versionCount = 0;
38     }
39     
40     /**
41      * @see #getKey()
42      */

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

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

72     public String JavaDoc toString()
73     {
74         return getKey().toString();
75     }
76
77     public StoreKey getKey() {
78         return key;
79     }
80
81     public synchronized void setKey(StoreKey key) {
82         this.key = key;
83         this.storeRef = null;
84     }
85     
86     /**
87      * For Hibernate use
88      */

89     private void setVersionCount(int versionCount)
90     {
91         this.versionCount = versionCount;
92     }
93
94     public int incrementVersionCount()
95     {
96         return ++versionCount;
97     }
98
99     /**
100      * Reset back to 0
101      */

102     public void resetVersionCount()
103     {
104         setVersionCount(0);
105     }
106
107     public int getVersionCount()
108     {
109         return versionCount;
110     }
111 }
Popular Tags