groupimpl.java

来自「用Java写的面相对象的数据库管理系统」· Java 代码 · 共 85 行

JAVA
85
字号
// 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: GroupImpl.java,v 1.4 2000/10/28 16:55:20 daniela Exp $package org.ozoneDB.test.tx;import java.io.*;import org.ozoneDB.*;import org.ozoneDB.DxLib.*;public class GroupImpl extends OzoneObject implements Group {        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() {        System.out.println( "*** 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 + =
减小字号Ctrl + -
显示快捷键?