?? iparser.java
字號:
/*
* 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.qq.packets;
import java.nio.ByteBuffer;
import edu.tsinghua.lumaqq.qq.beans.QQUser;
/**
* 包解析器
*
* @author luma
*/
public interface IParser {
/**
* 判斷此parser是否可以處理這個包,判斷不能影響到buf的指針位置
*
* @param buf
* ByteBuffer
* @return
* true表示這個parser可以處理這個包
*/
public boolean accept(ByteBuffer buf);
/**
* @param buf TODO
* @return
* 包的總長度
*/
public int getLength(ByteBuffer buf);
/**
* 從buf當前位置解析出一個輸入包對象,解析完畢后指針位于length之后
*
* @param buf
* ByteBuffer
* @param length
* 包長度
* @param user
* QQ用戶對象
* @return
* InPacket子類,如果解析不了返回null
* @throws PacketParseException
*/
public InPacket parseIncoming(ByteBuffer buf, int length, QQUser user) throws PacketParseException;
/**
* 從buf當前位置解析出一個輸出包對象,解析完畢后指針位于length之后
*
* @param buf
* ByteBuffer
* @param length
* 包長度
* @param user
* QQ用戶對象
* @return
* OutPacket子類,如果解析不了,返回null
* @throws PacketParseException
*/
public OutPacket parseOutcoming(ByteBuffer buf, int length, QQUser user) throws PacketParseException;
/**
* 檢查這個輸入包是否重復
*
* @param in
* @return
* true表示重復
*/
public boolean isDuplicate(InPacket in);
/**
* @param in
* 收到的包
* @return
* true表示即使這個包是重復包也要回復
*/
public boolean isDuplicatedNeedReply(InPacket in);
/**
* 假設buf的當前位置處是一個包,返回下一個包的起始位置。這個方法
* 用來重新調整buf指針。如果無法重定位,返回當前位置
*
* @param buf
* ByteBuffer
* @return
* 下一個包的起始位置
*/
public int relocate(ByteBuffer buf);
/**
* @return
* PacketHistory類
*/
public PacketHistory getHistory();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -