001: // You can redistribute this software and/or modify it under the terms of
002: // the Ozone Library License version 1 published by ozone-db.org.
003: //
004: // The original code and portions created by SMB are
005: // Copyright (C) 1997-2000 by SMB GmbH. All rights reserved.
006: //
007: // $Id: AutoImpl.java,v 1.1 2001/12/18 10:31:31 per_nyfelt Exp $
008:
009: package org.ozoneDB.test.simple;
010:
011: import org.ozoneDB.*;
012: import java.util.*;
013:
014: import org.apache.log4j.Category;
015:
016: public class AutoImpl extends OzoneObject implements Auto {
017:
018: /**
019: * log4j logger
020: */
021: private static Category fLog = Category.getInstance(AutoImpl.class);
022:
023: /**
024: * The serialization version id used by the Java serialization.
025: * Please, see also the Java documentation.
026: */
027: final static long serialVersionUID = 1L;
028:
029: String name = "Ford";
030:
031: int age = 0;
032:
033: Auto link;
034:
035: Vector v;
036:
037: public AutoImpl() {
038: // fLog.debug ("Auto ctor...");
039: v = new Vector();
040: v.add("dani");
041:
042: }
043:
044: public void onCreate() throws Exception {
045: fLog.debug("onCreate()...");
046: // try {
047: // link = (Auto)database().createObject (BusImpl.class.getName(), 0, null);
048: // fLog.debug (link.getClass().getName());
049: // }
050: // catch (Exception e) {
051: // fLog.debug (e);
052: // }
053: }
054:
055: public void onDelete() throws Exception {
056: fLog.debug("onDelete()...");
057: if (link != null) {
058: database().deleteObject(link);
059: }
060: }
061:
062: public boolean equals(Object obj) {
063: Auto auto = (Auto) obj;
064: return name.equals(auto.name());
065: }
066:
067: public String nameName() throws Exception {
068: fLog.debug(self());
069: fLog.debug(((Auto) self()).link());
070: fLog.debug(((Auto) self()).link().name());
071: return ((Auto) self()).link().name();
072: }
073:
074: public Auto doSomthing(Auto auto) throws Exception {
075: String linkName = link.name();
076: fLog.debug("doSomething(): linkName=" + linkName);
077: return link;
078: }
079:
080: public Auto setLink(Auto auto) throws Exception {
081: // fLog.debug ("setLink(): " + auto.toString() + " (" + auto.getClass().getName() + ")");
082: link = auto;
083: return this ;
084: }
085:
086: public Auto link() {
087: return link;
088: }
089:
090: public void print() {
091: fLog.debug(toString());
092:
093: fLog.debug("Vector:");
094: for (Enumeration e = v.elements(); e.hasMoreElements();) {
095: fLog.debug(e.nextElement());
096: }
097: }
098:
099: public void setName(String newName) {
100: name = newName;
101: }
102:
103: public String name() {
104: return name;
105: }
106:
107: public void setAge(Integer newAge) {
108: age = newAge.intValue();
109: // throw new NullPointerException();
110: }
111:
112: public int setAge(int newAge) {
113: int ret = age;
114: age = newAge;
115: return age;
116: }
117:
118: public Integer age() {
119: return new Integer(age);
120: }
121:
122: public String toString() {
123: // fLog.debug ("toString()...");
124: return "Auto:" + name + ", " + String.valueOf(age);
125: }
126:
127: public void done() throws Exception {
128: // fLog.debug (toString() + " done.");
129: }
130:
131: }
|