📄 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 org.apache.commons.logging.Log;
//import org.apache.commons.logging.LogFactory;
//import edu.tsinghua.lumaqq.qq.beans.QQUser;
/**
* 包解析器
*
* @author luma
*/
public interface IParser {
// Log对象
// static Log log = LogFactory.getLog(IParser.class);
/**
* 判断此parser是否可以处理这个包,判断不能影响到buf的指针位置
*
* @param buf
* ByteBuffer
* @return
* true表示这个parser可以处理这个包
*/
public boolean accept(ByteBuffer buf);
/**
* @return
* 包的总长度
*/
public int getLength();
/**
* 从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;
/**
* 得到buf中下一个包的hash值
*
* @param buf
* ByteBuffer
* @return
* hash值
*/
public int getHash(ByteBuffer buf);
/**
* 判断buf中的包是否是输入包,判断不能改变buf的指针位置
*
* @param buf
* ByteBuffer
* @return
* true表示是输入包
*/
public boolean isIncoming(ByteBuffer buf);
/**
* 判断buf中的包是否是UDP方式包,判断不能改变buf的指针位置
*
* @param buf
* ByteBuffer
* @return
* true表示是UDP方式包
*/
public boolean isUdp(ByteBuffer buf);
/**
* 检查包是否重复
*
* @param buf
* ByteBuffer
* @return
* true表示重复
*/
public boolean isDuplicated(ByteBuffer buf);
/**
* @return
* true表示即使这个包是重复包也要回复
*/
public boolean isDuplicatedNeedReply();
/**
* 假设buf的当前位置处是一个包,返回下一个包的起始位置。这个方法
* 用来重新调整buf指针。如果无法重定位,返回当前位置
*
* @param buf
* ByteBuffer
* @return
* 下一个包的起始位置
*/
public int relocate(ByteBuffer buf);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -