01: // You can redistribute this software and/or modify it under the terms of
02: // the Ozone Library License version 1 published by ozone-db.org.
03: //
04: // The original code and portions created by SMB are
05: // Copyright (C) 1997-2000 by SMB GmbH. All rights reserved.
06: //
07: // $Id: GroupImpl.java,v 1.1 2001/12/18 10:31:31 per_nyfelt Exp $
08:
09: package org.ozoneDB.test.tx;
10:
11: import java.io.*;
12: import org.ozoneDB.*;
13: import org.ozoneDB.DxLib.*;
14:
15: import org.apache.log4j.Category;
16:
17: public class GroupImpl extends OzoneObject implements Group {
18:
19: /**
20: * log4j logger
21: */
22: private static Category fLog = Category
23: .getInstance(GroupImpl.class);
24:
25: protected final static long serialVersionUID = 1;
26:
27: protected String name;
28:
29: protected DxHashMap users;
30:
31: public GroupImpl() {
32: name = "Group";
33: users = new DxHashMap();
34: }
35:
36: public void setName(String _name) {
37: name = _name;
38: }
39:
40: public String name() {
41: return name;
42: }
43:
44: public User[] getAll() {
45: fLog.debug("*** getAll():");
46:
47: User[] result = new User[users.count()];
48: DxIterator it = users.iterator();
49: for (int i = 0; it.next() != null; i++) {
50: result[i] = (User) it.object();
51: }
52: return result;
53:
54: // return (User[])users.toArray();
55: }
56:
57: public void addUser(User user) throws Exception {
58: users.addForKey(user, user.name());
59: }
60:
61: public void populate(int n) throws Exception {
62: for (int i = 0; i < n; i++) {
63: User user = (User) database().createObject(
64: UserImpl.class.getName());
65: users.addForKey(user, user.name());
66: }
67: }
68:
69: public void crash() {
70: throw new NullPointerException();
71: }
72:
73: public String toString() {
74: return "Group: name=" + name + ", userCount=" + users.count();
75: }
76:
77: public void done() throws Exception {
78: DxIterator it = users.iterator();
79: while (it.next() != null) {
80: database().deleteObject((User) it.object());
81: }
82: }
83: }
|