1 package rero.ircfw; 2 3 import java.util.*; 4 5 import rero.ircfw.interfaces.FrameworkConstants; 6 import rero.ircfw.data.*; 7 8 public class Channel implements FrameworkConstants, Comparator 9 { 10 protected String topic = ""; 11 12 public void setTopic(String t) { topic = t; } 13 public String getTopic() { return topic; } 14 15 protected int limit; 16 17 public void setLimit(int l) { limit = l; } 18 public int getLimit() { return limit; } 19 20 protected String key; 21 22 public void setKey(String k) { key = k; } 23 public String getKey() { return key; } 24 25 protected GenericMode mode = new GenericMode(); 26 27 public void setMode(String m) { mode = new GenericMode(m); } 28 public GenericMode getMode() { return mode; } 29 30 protected String name; 31 32 public String getName() { return name; } 33 34 public Channel(String name) 35 { 36 this.name = name; 37 } 38 39 protected SortedSet allusers = Collections.synchronizedSortedSet(new TreeSet(this)); 41 public int compare(Object aa, Object bb) 42 { 43 User a = (User)aa; 44 User b = (User)bb; 45 46 if (a == null || b == null) 47 return 0; 48 49 int aM = a.getModeFor(this); 50 int bM = b.getModeFor(this); 51 52 int result = bM - aM; 53 54 if (result == 0) 55 { 56 return a.compareTo(b); 57 } 58 59 return result; 60 } 61 62 public Set getAllUsers() 63 { 64 return allusers; 65 } 66 67 public String toString() 68 { 69 StringBuffer temp = new StringBuffer (); 70 temp.append(getName()); 71 temp.append(" \""); 72 temp.append(getTopic()); 73 temp.append("\", "); 74 75 temp.append(getMode()); 76 77 if (getMode().isSet('k')) 78 { 79 temp.append(" key="+key); 80 } 81 82 if (getMode().isSet('l')) 83 { 84 temp.append(" limit="+limit); 85 } 86 87 temp.append(", "); 88 89 Iterator iter = getAllUsers().iterator(); 90 while (iter.hasNext()) 91 { 92 User tempa = (User)iter.next(); 93 temp.append("?"); 94 temp.append(tempa.getNick()); 95 temp.append(" "); 96 } 97 98 return temp.toString(); 99 } 100 } 101 | Popular Tags |