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

📄 msnfriend.java

📁 聊天程序
💻 JAVA
字号:
/*
 * @(#)MsnFriend.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: MsnFriend.java,v 1.7 2002/03/15 05:16:15 xrath Exp $
 */
package rath.msnm.entity;

import java.io.UnsupportedEncodingException;

import rath.msnm.UserStatus;
import rath.msnm.msg.MimeUtility;
import rath.msnm.util.StringUtil;
/**
 *
 * @author Jang-Ho Hwang, rath@linuxkorea.co.kr
 * @version $Id: MsnFriend.java,v 1.7 2002/03/15 05:16:15 xrath Exp $
 */
public class MsnFriend implements UserStatus
{
	private Integer groupIndex = new Integer(0);
	private String status = null;
	private String oldStatus = null;
	private String loginName = null;
	private String friendlyName = null;
	private String formatFriendlyName = null;

	public MsnFriend( String loginName )
	{
		this( loginName, null );
	}

	public MsnFriend( String loginName, String friendlyName )
	{
		this.loginName = loginName;
		this.friendlyName = friendlyName;

		setStatus( UserStatus.OFFLINE );
	}

	public void setGroupIndex( int index )
	{
		this.groupIndex = new Integer(index);
	}

	public void setGroupIndex( Integer index )
	{
		this.groupIndex = index;
	}

	public Integer getGroupIndex()
	{
		return this.groupIndex;
	}

	public void setLoginName( String loginName )
	{
		this.loginName = loginName;
	}

	public String getLoginName()
	{
		return this.loginName;
	}

	public void setFriendlyName( String frName )
	{
		this.friendlyName = frName;
		this.formatFriendlyName = null;
	}

	public String getFriendlyName()
	{
		return this.friendlyName;
	}

	/**
	 * 捞 荤侩磊狼 URLDecoded 等 沥屈拳等 FriendlyName阑 馆券茄促.
	 * 父距 FriendlyName捞 null捞扼搁 弊措肺 null阑 馆券且 巴捞促.
	 */
	public String getFormattedFriendlyName()
	{
		if( formatFriendlyName!=null )
			return formatFriendlyName;
		if( this.friendlyName==null )
			return null;

		try
		{
			this.formatFriendlyName = MimeUtility.getURLDecodedString(
				this.friendlyName, "UTF-8" );
		}
		catch( UnsupportedEncodingException e )
		{
		    this.formatFriendlyName = formatFriendlyName;
		}
		return formatFriendlyName;
	}

	public void setStatus( String st )
	{
		if( st==null )
			st = UserStatus.OFFLINE;

		oldStatus = this.status;
		this.status = st;
	}

	/**
	 * 官肺 捞傈狼 惑怕内靛 蔼阑 掘绢柯促.
	 */
	public String getOldStatus()
	{
		return this.oldStatus;
	}

	public String getStatus()
	{
		return this.status;
	}

	/**
	 * @deprecated This method is deprecated for internationalization problem.
	 */
	public String getFormattedStatus() throws IllegalAccessException
	{
		throw new IllegalAccessException("Deprecated");
	}

	public String toString()
	{
		return loginName + ":" + friendlyName + " (" + status + ")";
	}

	public boolean equals( Object o )
	{
		if( this==o )
			return true;
		if( o!=null && o instanceof MsnFriend )
			return loginName.equals( ((MsnFriend)o).loginName );
		return false;
	}

	public int hashCode()
	{
		return loginName.hashCode();
	}

	public String toFormattedString()
	{
		return loginName + ": " + getFormattedFriendlyName() + " (" + getStatus() + ")";
	}
};

⌨️ 快捷键说明

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