KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > myoodb > MyOodbObject


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;
25
26 public class MyOodbObject implements MyOodbLocal
27 {
28     private transient boolean m_convertFlag = true;
29     private transient org.myoodb.core.AbstractObjectContainer m_container = null;
30
31     public MyOodbObject()
32     {
33     }
34
35     public void onCreate()
36     {
37     }
38
39     public void onDelete()
40     {
41     }
42
43     public final void setConvertFlag(boolean convertFlag)
44     {
45         m_convertFlag = convertFlag;
46     }
47
48     public final boolean getConvertFlag()
49     {
50         return m_convertFlag;
51     }
52
53     public final void setContainer(org.myoodb.core.AbstractObjectContainer container)
54     {
55         m_container = container;
56     }
57
58     public final org.myoodb.core.AbstractObjectContainer getContainer()
59     {
60         if (m_container == null)
61         {
62             throw new org.myoodb.exception.PermissionException("Invalid access (" + this.getClass() + " is not (yet) associated to a database");
63         }
64
65         return m_container;
66     }
67
68     public final MyOodbProxy getSelf()
69     {
70         return getContainer().getProxy();
71     }
72
73     public final org.myoodb.core.Identifier getDatabaseHandle()
74     {
75         return getContainer().getObjectId();
76     }
77
78     public final org.myoodb.core.AbstractDatabase getDatabase()
79     {
80         return org.myoodb.core.MyOodbManager.getTheManager().getDatabase();
81     }
82
83     public final void setBean(MyOodbBean bean)
84     {
85         getContainer().setBean(bean);
86     }
87
88     public final MyOodbBean getBean()
89     {
90         return getContainer().getBean();
91     }
92
93     public final void setXML(String JavaDoc xml)
94     {
95         getContainer().setXML(xml);
96     }
97
98     public final String JavaDoc getXML()
99     {
100         return getContainer().getXML();
101     }
102
103     public int hashCode()
104     {
105         return getDatabaseHandle().hashCode();
106     }
107
108     public boolean equals(Object JavaDoc obj)
109     {
110         if (obj == this)
111         {
112             return true;
113         }
114         else if (obj instanceof MyOodbObject)
115         {
116             return getDatabaseHandle().equals(((MyOodbObject) obj).getDatabaseHandle());
117         }
118         else if (obj instanceof MyOodbProxy)
119         {
120             return getDatabaseHandle().equals(((MyOodbProxy) obj).getDatabaseHandle());
121         }
122         else if (obj instanceof org.myoodb.core.Identifier)
123         {
124             return getDatabaseHandle().equals(obj);
125         }
126         else
127         {
128             return false;
129         }
130     }
131
132     public int compareTo(Object JavaDoc obj)
133     {
134         if (obj instanceof MyOodbObject)
135         {
136             return getDatabaseHandle().compareTo(((MyOodbObject) obj).getDatabaseHandle());
137         }
138         else if (obj instanceof MyOodbProxy)
139         {
140             return getDatabaseHandle().compareTo(((MyOodbProxy) obj).getDatabaseHandle());
141         }
142         else if (obj instanceof org.myoodb.core.Identifier)
143         {
144             return getDatabaseHandle().compareTo(obj);
145         }
146         else
147         {
148             return -1;
149         }
150     }
151
152     public String JavaDoc toString()
153     {
154         return "Object Handle: " + getDatabaseHandle();
155     }
156 }
157
Popular Tags