KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > myoodb > collectable > LogObjectDbImpl


1 ///////////////////////////////////////////////////////////////////////////////
2
//
3
// Copyright (C) 2003-@year@ by Thomas M. Hazel, MyOODB (www.myoodb.org)
4
//
5
// All Rights Reserved
6
//
7
// This program is free software; you can redistribute it and/or modify
8
// it under the terms of the GNU General Public License and GNU Library
9
// General Public License as published by the Free Software Foundation;
10
// either version 2, or (at your option) any later version.
11
//
12
// This program is distributed in the hope that it will be useful,
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
// GNU General Public License and GNU Library General Public License
16
// for more details.
17
//
18
// You should have received a copy of the GNU General Public License
19
// and GNU Library General Public License along with this program; if
20
// not, write to the Free Software Foundation, 675 Mass Ave, Cambridge,
21
// MA 02139, USA.
22
//
23
///////////////////////////////////////////////////////////////////////////////
24
package org.myoodb.collectable;
25
26 public class LogObjectDbImpl extends CollectableDbImpl implements LogObject
27 {
28     protected long m_time;
29     protected LogStore m_logStore;
30
31     public LogObjectDbImpl()
32     {
33         m_time = -1;
34         m_logStore = null;
35     }
36
37     public void onDelete()
38     {
39         if (m_logStore != null)
40         {
41             m_logStore.removeLogObject(this);
42         }
43     }
44
45     public void setTime(long time)
46     {
47         m_time = time;
48     }
49
50     public long getTime()
51     {
52         return m_time;
53     }
54
55     public void setLogStore(LogStore logStore)
56     {
57         m_logStore = logStore;
58
59         if (logStore != null)
60         {
61             m_time = getLocalTime();
62         }
63         else
64         {
65             m_time = -1;
66         }
67     }
68
69     public LogStore getLogStore()
70     {
71         return m_logStore;
72     }
73
74     public void activate() throws Exception JavaDoc
75     {
76         getContainer().setDeactivationFlag(false);
77     }
78
79     public void deactivate() throws Exception JavaDoc
80     {
81         getContainer().setDeactivationFlag(true);
82     }
83
84     public int hashCode()
85     {
86         return (int) m_time;
87     }
88
89     public boolean equals(Object JavaDoc obj)
90     {
91         if (this == obj)
92         {
93             return true;
94         }
95         else if (obj instanceof LogObject)
96         {
97             return (getTime() == ((LogObject) obj).getTime());
98         }
99         else
100         {
101             return false;
102         }
103     }
104
105     public int compareTo(Object JavaDoc obj)
106     {
107         if (obj instanceof LogObject)
108         {
109             long diff = getTime()-((LogObject) obj).getTime();
110             return diff>0?1:diff<0?-1:0;
111         }
112         else
113         {
114             return -1;
115         }
116     }
117 }
118
Popular Tags