⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 garageimpl.java

📁 Java的面向对象数据库系统的源代码
💻 JAVA
字号:
// You can redistribute this software and/or modify it under the terms of
// the Ozone Library License version 1 published by ozone-db.org.
//
// The original code and portions created by SMB are
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
//
// $Id$

package test.simple;

import org.ozoneDB.DxLib.*;
import org.ozoneDB.OzoneObject;


public class GarageImpl extends OzoneObject implements Garage {
    String name = "Morris";
    DxHashMap table = new DxHashMap();
    DxBag list = new DxArrayBag();


    /** */
    public GarageImpl() {
    }


    /** */
    public void print() {
        System.out.println(toString());
    }


    /** */
    public void printAll() throws Exception {
        DxIterator it = table.iterator();
        Auto auto;
        while ((auto = (Auto) it.next()) != null) {
            auto.print();
        }
    }


    /** */
    public Auto[] getAll() throws Exception {
        Auto[] ans = new Auto[table.count()];
        DxIterator it = table.iterator();
        for (int c = 0; it.next() != null; c++) {
            ans[c] = (Auto) it.object();
        }
        return ans;
    }


    /** */
    public int[] _setAll(Auto a0, int[] a1, Integer[] a2) throws Exception {
        System.out.println("Got " + a1.length + " ints...");
        System.out.println("Got " + a2.length + " Integrs...");
        return a1;
    }


    /** */
    public void setAll(Integer age) throws Exception {
        DxIterator it = table.iterator();
        Auto auto;
        while ((auto = (Auto) it.next()) != null) {
            auto.setAge(age);
        }
    }


    /** */
    public void _addAuto(Auto auto) throws Exception {
        table.addForKey(auto, auto.name());
    }


    /** */
    public void _newAuto(String name) throws Exception {
        Auto auto = (Auto) database().createObject(AutoImpl.class.getName());
        auto.setName(name.toString());
        table.addForKey(auto, name);
        list.add(auto);
    }


    /** */
    public void _populate(Integer num) throws Exception {
        for (int i = 0; i < num.intValue(); i++) {
            String name = "Auto" + String.valueOf(i);
            _newAuto(name);
        }
    }


    /** */
    public Auto autoForName(String search) {
        return (Auto) table.elementForKey(search);
    }


    /** */
    public void setAlter(DxInteger alter) throws Exception {
        DxIterator it = table.iterator();
        Auto auto;
        while ((auto = (Auto) it.next()) != null) {
            auto.setAge(new Integer(alter.toInt()));
        }
    }


    /** */
    public void crunch(DxInteger num) throws Exception {
        int n = num.toInt();
        for (int i = 0; i < n; i++) {
            _newAuto(String.valueOf(i));
        }

        DxIterator it = table.iterator();
        Auto auto;
        while ((auto = (Auto) it.next()) != null) {
            auto.age();
        }
    }


    /** */
    public void _lockThis() throws Exception {
    }


    /** */
    public void _langeTA(Garage garage) throws Exception {
        Thread.currentThread().sleep(10000);
        if (garage != null) {
            garage._lockThis();
        }
    }


    /**
     * destructor fuer db-objekte
     */
    public void done() throws Exception {
        System.out.println(toString() + " done.");
        DxIterator it = table.iterator();
        Auto auto;
        while ((auto = (Auto) it.next()) != null) {
            database().deleteObject(auto);
        }
    }


    /** */
    public String toString() {
        return "Garage:" + name;
    }


    /*
     *   public Object invoke (String methodName, int argNum, Object arg1, Object arg2, Object arg3)
         throws MethodNotFoundException, IllegalAccessException, IllegalArgumentException, Throwable {
      if (methodName.equals("toString"))
         return toString();
      else if (methodName.equals("print"))
         print();
      else if (methodName.equals("crunch"))
         crunch ((DxInteger)arg1);
      else if (methodName.equals("langeTA"))
         langeTA ((Auto)arg1);
      else if (methodName.equals("lockThis"))
         lockThis();
      else if (methodName.equals("printAll"))
         printAll();
      else
         throw new MethodNotFoundException();
      return null;
      }
     */
    protected void finalize() throws Throwable {
        // System.out.println (toString() + " abgeraeumt...");
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -