⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 friendslist.java

📁 是一款国外的网络游戏平台的源码*不是类似浩方那种虚拟局域网技术
💻 JAVA
字号:
/*
 * Created on Nov 26, 2005
 *
 * To change the template for this generated file go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
package org.GTADS.usermanager;

import java.util.*;
/**
 * @author sday
 *
 * To change the template for this generated type comment go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
public class FriendsList {
	private Hashtable FriendsListData = new Hashtable();
	public static int STATE_OFFLINE = 0;
	public static int STATE_ONLINE = 1;
	public static int STATE_AWAY = 2;
	
	public static String BUDDY_ONLINE = "BUDDY_ONLINE";
	public static String BUDDY_OFFLINE = "BUDDY_OFFLINE";
	
	public static String SEND_FRIENDSLIST = "SEND_FRIENDSLIST";

	public FriendsList () {
		FriendsListData = new Hashtable();
	}

	public void addFriend(String newUser){
			addFriend(newUser, STATE_OFFLINE);
	}
	
	public void addFriend(String newUser, int state){
		if (FriendsListData.containsKey(newUser))
			return;
		if (newUser != null){
			FriendsListData.put(newUser, new Integer(state));
		}
	}
	
	public void modifyFriendState(String currentUser, int state){
		if (!FriendsListData.containsKey(currentUser))
			return;
		if (currentUser != null){
			FriendsListData.put(currentUser, new Integer(state));
		}
	}
	
	public int getFriendState(String currentUser){
		Integer state;
		if (FriendsListData.containsKey(currentUser)){
			state = (Integer)FriendsListData.get(currentUser);
			return state.intValue();
		}
		else {
			return -1;
		}
	}
	
	public boolean isFriendOnList(String queryUser){
		return FriendsListData.containsKey(queryUser);
	}
	
	public void removeFriendFromList(String currentUser){
		if (FriendsListData.containsKey(currentUser)){
			FriendsListData.remove(currentUser);
		}
	}
	
	public Vector getFriendsNamesList(){
		Enumeration userNames = FriendsListData.keys();
		Vector friendsVector = new Vector();
		
		while (userNames.hasMoreElements()){
			friendsVector.add(userNames.nextElement());
		}
		
		return friendsVector;
	}

	
	public void clearFriends(){
		FriendsListData.clear();
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -