groupimpl.java
来自「Java的面向对象数据库系统的源代码」· Java 代码 · 共 90 行
JAVA
90 行
// 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 + =
减小字号Ctrl + -
显示快捷键?