01: /**
02: * Copyright (C) 2008 NetMind Consulting Bt.
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */package hu.netmind.persistence.node;
18:
19: import java.io.Serializable;
20:
21: /**
22: * Meta-data for locking objects.
23: * @author Brautigam Robert
24: * @version CVS Revision: $Revision$
25: */
26: public class LockMetaData implements Comparable, Serializable {
27: private Long objectId;
28: private Class objectClass;
29: private Long querySerial;
30: private Long startSerial;
31: private Long endSerial;
32:
33: public String toString() {
34: if (objectId == null)
35: return "[Lock class " + objectClass.getName() + " ("
36: + querySerial + ")" + "]";
37: else
38: return "[Lock object " + objectClass.getName() + ":"
39: + objectId + " (" + querySerial + ")]";
40: }
41:
42: public int compareTo(Object obj) {
43: LockMetaData o = (LockMetaData) obj;
44: if ((o.objectId == null) && (objectId == null)) {
45: // Two classes, compare with names
46: return objectClass.getName().compareTo(
47: o.objectClass.getName());
48: } else if ((o.objectId != null) && (objectId == null)) {
49: // This is a class, other is not, so this is first
50: return -1;
51: } else if ((o.objectId == null) && (objectId != null)) {
52: // Other way around
53: return 1;
54: }
55: // Default, both are objects
56: return objectId.compareTo(o.objectId);
57: }
58:
59: public Long getObjectId() {
60: return objectId;
61: }
62:
63: public void setObjectId(Long objectId) {
64: this .objectId = objectId;
65: }
66:
67: public Class getObjectClass() {
68: return objectClass;
69: }
70:
71: public void setObjectClass(Class objectClass) {
72: this .objectClass = objectClass;
73: }
74:
75: public Long getQuerySerial() {
76: return querySerial;
77: }
78:
79: public void setQuerySerial(Long querySerial) {
80: this .querySerial = querySerial;
81: }
82:
83: public Long getStartSerial() {
84: return startSerial;
85: }
86:
87: public void setStartSerial(Long startSerial) {
88: this .startSerial = startSerial;
89: }
90:
91: public Long getEndSerial() {
92: return endSerial;
93: }
94:
95: public void setEndSerial(Long endSerial) {
96: this.endSerial = endSerial;
97: }
98:
99: }
|