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

📄 groupimpl.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-2000 by SMB GmbH. All rights reserved.
//
// $Id$

package test.tx;

import org.apache.log4j.Category;
import org.ozoneDB.DxLib.DxHashMap;
import org.ozoneDB.DxLib.DxIterator;
import org.ozoneDB.OzoneObject;

public class GroupImpl extends OzoneObject implements Group {

    /**
     * log4j logger
     */
    private static Category fLog = Category.getInstance(GroupImpl.class);

    protected final static long serialVersionUID = 1;

    protected String name;

    protected DxHashMap users;


    public GroupImpl() {
        name = "Group";
        users = new DxHashMap();
    }


    public void setName(String _name) {
        name = _name;
    }


    public String name() {
        return name;
    }


    public User[] getAll() {
        fLog.debug("*** getAll():");

        User[] result = new User[users.count()];
        DxIterator it = users.iterator();
        for (int i = 0; it.next() != null; i++) {
            result[i] = (User) it.object();
        }
        return result;

        // return (User[])users.toArray();
    }


    public void addUser(User user) throws Exception {
        users.addForKey(user, user.name());
    }


    public void populate(int n) throws Exception {
        for (int i = 0; i < n; i++) {
            User user = (User) database().createObject(UserImpl.class.getName());
            users.addForKey(user, user.name());
        }
    }


    public void crash() {
        throw new NullPointerException();
    }


    public String toString() {
        return "Group: name=" + name + ", userCount=" + users.count();
    }


    public void done() throws Exception {
        DxIterator it = users.iterator();
        while (it.next() != null) {
            database().deleteObject((User) it.object());
        }
    }
}

⌨️ 快捷键说明

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