KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > odmg > AutoImpl


1 // $Id: AutoImpl.java,v 1.3 2003/11/23 15:19:37 per_nyfelt Exp $
2
package odmg;
3
4 import org.ozoneDB.*;
5 import org.ozoneDB.odmg.*;
6
7 /**
8  * @author <a HREF="http://www.softwarebuero.de/">SMB</a>
9  * @version $Revision: 1.3 $Date: 2003/11/23 15:19:37 $
10  */

11 public class AutoImpl extends OzoneObject implements Auto, Common {
12     
13     /**
14      * The serialization version id used by the Java serialization.
15      * See also the Java documentation.
16      */

17     final static long serialVersionUID = 1L;
18     
19     protected String JavaDoc name = "Auto";
20     
21     protected int age = 0;
22     
23     protected Auto link;
24     
25     
26     public AutoImpl() {
27         // System.out.println ("Auto ctor...");
28
}
29     
30     
31     public AutoImpl( String JavaDoc _name ) throws Exception JavaDoc{
32         name = _name;
33     }
34     
35     
36     public boolean equals( Object JavaDoc obj ) {
37         Auto auto = (Auto)obj;
38         return name.equals( auto.name() );
39     }
40     
41     
42     public Auto doSomething() throws Exception JavaDoc {
43         EnhDatabase db = (EnhDatabase)ODMG.getDatabase2( this );
44         Auto auto = (Auto)db.createPersistent( AutoImpl.class );
45         return doSomething( auto );
46     }
47     
48     
49     public Auto doSomething( Auto auto ) throws Exception JavaDoc {
50         System.out.println( "doSomething(): got: " + auto.toString() + " (" + auto.getClass().getName() + ")" );
51         return this;
52     }
53     
54     
55     public void setLink( Auto auto ) {
56         // System.out.println ("setLink(): " + auto.toString() + " (" + auto.getClass().getName() + ")");
57
link = auto;
58     }
59     
60     
61     public Auto link() {
62         return link;
63     }
64     
65     
66     public void setName( String JavaDoc newName ) {
67         name = newName;
68     }
69     
70     
71     public String JavaDoc name() {
72         return name;
73     }
74     
75     
76     public int setAge( int newAge ) {
77         int old = age;
78         age = newAge;
79         return old;
80     }
81     
82     
83     public int age() {
84         return age;
85     }
86     
87     
88     public void print() {
89         System.out.println( toString() );
90     }
91     
92     
93     public String JavaDoc toString() {
94         // System.out.println ("toString()...");
95
String JavaDoc linkString = link != null ? String.valueOf( ((OzoneProxy)link).remoteID() ) : "null";
96         return "Auto: name=" + name + ", age=" + age + ", link=" + linkString;
97     }
98     
99     
100     public void done() throws Exception JavaDoc {
101     // System.out.println (toString() + " done.");
102
}
103     
104 }
105
Popular Tags