qqnumbermatcher.java

来自「java写的qq代码实现qq的部分功能」· Java 代码 · 共 79 行

JAVA
79
字号
/*
* LumaQQ - Java QQ Client
*
* Copyright (C) 2004 luma <stubma@163.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package edu.tsinghua.lumaqq.models;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import edu.tsinghua.swt.models.INode;
import edu.tsinghua.swt.models.IMatcher;

/**
 * 根据qq号查好友
 * 
 * @author 马若劼
 */
public class QQNumberMatcher implements IMatcher {
    // Log对象
    protected static Log log = LogFactory.getLog(QQNumberMatcher.class);
    
    // 要搜索的QQ号
    private int qq;
    // 是否搜索原生model
    private boolean original;
    
	/* (non-Javadoc)
	 * @see edu.tsinghua.swt.models.IMatcher#match(edu.tsinghua.swt.models.INode)
	 */
	public boolean match(INode node) {
		if(node instanceof FriendModel) {
		    FriendModel f = (FriendModel)node;
			return qq == f.getQQ() && f.isOriginal() == original;			
		} else
			return false;
	}
	
	/**
	 * 设置搜索参数
	 * 
	 * @param qqNum
	 * 			QQ号
	 * @param original
	 * 			是否原生
	 */
	public void setQQ(int qqNum, boolean original) {
		this.qq = qqNum;
		this.original = original;
	}
	
	/**
	 * 设置搜索参数
	 * 
	 * @param qqNum
	 * 			QQ号
	 * @param original
	 * 			是否原生
	 */
	public void setQQ(Integer qqNum, boolean original) {
		this.qq = qqNum.intValue();
		this.original = original;
	}
}

⌨️ 快捷键说明

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