1 package com.quikj.application.web.talk.plugin; 2 3 import com.quikj.server.framework.*; 4 import java.util.*; 5 6 public class GroupList 7 { 14 15 public GroupList() 16 { 17 instance = this; 18 } 19 20 public static GroupList Instance() 21 { 22 if (instance == null) 23 { 24 new GroupList(); 25 } 26 27 return instance; 28 } 29 30 public void dispose() 31 { 32 activeGroups.clear(); 33 } 34 35 public int addGroup(GroupInfo groupinfo) 36 { 38 String name = groupinfo.getName(); 39 GroupInfo info = (GroupInfo) activeGroups.get(name); 40 if (info == null) { 42 activeGroups.put(name, groupinfo); 43 groupinfo.setActiveUserCount(1); 44 return 1; 45 } 46 else 47 { 48 int new_count = info.incrementActiveUserCount(); 49 activeGroups.remove(name); 50 activeGroups.put(name, groupinfo); 51 groupinfo.setActiveUserCount(new_count); 52 53 return new_count; 54 } 55 } 56 57 public int removeGroup(String name) 58 { 60 GroupInfo info = (GroupInfo) activeGroups.get(name); 61 if (info == null) { 63 AceLogger.Instance().log(AceLogger.ERROR, 64 AceLogger.SYSTEM_LOG, 65 name 66 + " group - GroupList.removeGroup() -- Couldn't find group " 67 + name 68 + " in active group list."); 69 return 0; 70 } 71 72 int ret = info.decrementActiveUserCount(); 73 if (ret == 0) 74 { 75 activeGroups.remove(name); 76 } 77 78 return ret; 79 } 80 81 public GroupInfo findGroup(String name) 82 { 83 return (GroupInfo)activeGroups.get(name); 84 } 85 86 87 private static GroupList instance = null; 88 private Hashtable activeGroups = new Hashtable(); 90 } 91 | Popular Tags |