1 package org.cacert.gigi.dbObjects;
3 import java.util.HashMap;
5 import org.cacert.gigi.database.DatabaseConnection;
6 import org.cacert.gigi.database.GigiPreparedStatement;
7 import org.cacert.gigi.database.GigiResultSet;
11 private static HashMap<String, Group> cache = new HashMap<>();
13 private final String dbName;
15 private Group(String name) {
20 public int hashCode() {
23 result = prime * result + ((dbName == null) ? 0 : dbName.hashCode());
28 public boolean equals(Object obj) {
35 if (getClass() != obj.getClass()) {
38 Group other = (Group) obj;
40 if (other.dbName != null) {
43 } else if ( !dbName.equals(other.dbName)) {
49 public static synchronized Group getByString(String name) {
50 Group g = cache.get(name);
58 public String getDatabaseName() {
62 public User[] getMembers(int offset, int count) {
63 GigiPreparedStatement gps = DatabaseConnection.getInstance().prepare("SELECT user FROM user_groups WHERE permission=? AND deleted is NULL LIMIT ?,?");
64 gps.setString(1, dbName);
65 gps.setInt(2, offset);
67 GigiResultSet grs = gps.executeQuery();
69 User[] users = new User[grs.getRow()];
73 users[i++] = User.getById(grs.getInt(1));