📄 grouplist.java
字号:
/*
* @(#)GroupList.java
*
* Copyright (c) 2001-2002, JangHo Hwang
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the JangHo Hwang nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: GroupList.java,v 2.0 2004/12/21 16:15:08 chenzs Exp $
*/
package vitular.msnp;
import java.util.Vector;
import java.util.Hashtable;
import java.util.Enumeration; //Iterator-->Enumeration ceze 2004/5/29
import vitular.msnp.entity.Group;
/**
* 好友组列表
* <p>Title: MSNP Lib</p>
* <p>Description: Unija 版Msn协议</p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: Vitular</p>
* @author ceze
* @version 1.0
*/
public class GroupList {
private final Vector list;
private final Hashtable map;
GroupList() {
list = new Vector();
map = new Hashtable();
}
/**
* 添加分组
* @param group Group
*/
public void addGroup(Group group) {
Object o = map.put(group.getIndex(), group);
if (o == null)
list.addElement(group);
else {
Group grp = (Group) o;
grp.setName(group.getName());
}
}
/**
*
* @param index int
* @return Group
*/
public Group getGroup(int index) {
return getGroup(new Integer(index));
}
/**
*
* @param index Integer
* @return Group
*/
public Group getGroup(Integer index) {
return (Group) map.get(index);
}
/**
*
* @param index int
*/
public void removeGroup(int index) {
removeGroup(new Integer(index));
}
/**
*
* @param index Integer
*/
public void removeGroup(Integer index) {
Object o = map.remove(index);
if (o == null)
throw new IllegalArgumentException("no group in " + index);
list.removeElement(o);
}
public Enumeration enumeration() {
return list.elements();
}
/**
* Group成员数量
* @return int
*/
public int size(){
return list.size();
}
// public synchronized void sort() {
// Collections.sort(list, new Comparator() {
// public int compare(Object o1, Object o2) {
// Group g0 = (Group) o1;
// Group g1 = (Group) o2;
// return g0.getFormattedName().compareTo(
// g1.getFormattedName());
// }
//
// public boolean equals(Object o) {
// return false;
// }
// });
// }
public void clear() {
list.removeAllElements();
map.clear();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -