KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > simple > AutoImpl


1 // You can redistribute this software and/or modify it under the terms of
2
// the Ozone Library License version 1 published by ozone-db.org.
3
//
4
// The original code and portions created by SMB are
5
// Copyright (C) 1997-2000 by SMB GmbH. All rights reserved.
6
//
7
// $Id$
8

9 package test.simple;
10
11 import org.apache.log4j.Category;
12 import org.ozoneDB.OzoneObject;
13
14 import java.util.Enumeration JavaDoc;
15 import java.util.Vector JavaDoc;
16
17 public class AutoImpl extends OzoneObject implements Auto {
18
19     /**
20      * log4j logger
21      */

22     private static Category fLog = Category.getInstance(AutoImpl.class);
23
24     /**
25      * The serialization version id used by the Java serialization.
26      * Please, see also the Java documentation.
27      */

28     final static long serialVersionUID = 1L;
29
30     String JavaDoc name = "Ford";
31
32     int age = 0;
33
34     Auto link;
35
36     Vector JavaDoc v;
37
38
39     public AutoImpl() {
40         // fLog.debug ("Auto ctor...");
41
v = new Vector JavaDoc();
42         v.add("dani");
43
44     }
45
46
47     public void onCreate() {
48         fLog.debug("onCreate()...");
49         // try {
50
// link = (Auto)database().createObject (BusImpl.class.getName(), 0, null);
51
// fLog.debug (link.getClass().getName());
52
// }
53
// catch (Exception e) {
54
// fLog.debug (e);
55
// }
56
}
57
58
59     public void onDelete() {
60         fLog.debug("onDelete()...");
61         if (link != null) {
62             database().deleteObject(link);
63         }
64     }
65
66
67     public boolean equals(Object JavaDoc obj) {
68         Auto auto = (Auto) obj;
69         return name.equals(auto.name());
70     }
71
72
73     public String JavaDoc nameName() throws Exception JavaDoc {
74         fLog.debug(self());
75         fLog.debug(((Auto) self()).link());
76         fLog.debug(((Auto) self()).link().name());
77         return ((Auto) self()).link().name();
78     }
79
80
81     public Auto doSomthing(Auto auto) throws Exception JavaDoc {
82         String JavaDoc linkName = link.name();
83         fLog.debug("doSomething(): linkName=" + linkName);
84         return link;
85     }
86
87
88     public Auto setLink(Auto auto) throws Exception JavaDoc {
89         // fLog.debug ("setLink(): " + auto.toString() + " (" + auto.getClass().getName() + ")");
90
link = auto;
91         return this;
92     }
93
94
95     public Auto link() {
96         return link;
97     }
98
99
100     public void print() {
101         fLog.debug(toString());
102
103         fLog.debug("Vector:");
104         for (Enumeration JavaDoc e = v.elements(); e.hasMoreElements();) {
105             fLog.debug(e.nextElement());
106         }
107     }
108
109
110     public void setName(String JavaDoc newName) {
111         name = newName;
112     }
113
114
115     public String JavaDoc name() {
116         return name;
117     }
118
119
120     public void setAge(Integer JavaDoc newAge) {
121         age = newAge.intValue();
122         // throw new NullPointerException();
123
}
124
125
126     public int setAge(int newAge) {
127         age = newAge;
128         return age;
129     }
130
131
132     public Integer JavaDoc age() {
133         return new Integer JavaDoc(age);
134     }
135
136
137     public String JavaDoc toString() {
138         // fLog.debug ("toString()...");
139
return "Auto:" + name + ", " + String.valueOf(age);
140     }
141
142
143     public void done() throws Exception JavaDoc {
144         // fLog.debug (toString() + " done.");
145
}
146
147 }
148
Popular Tags