JML

net.sf.jqql.packets
Interface IParser

All Known Implementing Classes:
_03FamilyParser, _05FamilyParser, BasicFamilyParser, DiskFamilyParser

public interface IParser

packet parser 包解析器

Author:
luma

Method Summary
 boolean accept(ByteBuffer buf)
          judge parser whether can deal with this packet, judge can not touch buf pointer position 判断此parser是否可以处理这个包,判断不能影响到buf的指针位置
 PacketHistory getHistory()
           
 int getLength(ByteBuffer buf)
           
 boolean isDuplicate(InPacket in)
          checkout this input packet whether is duplicate 检查这个输入包是否重复
 boolean isDuplicatedNeedReply(InPacket in)
           
 InPacket parseIncoming(ByteBuffer buf, int length, QQUser user)
          parse a input packet object from buf current position, complete pointer is after length 从buf当前位置解析出一个输入包对象,解析完毕后指针位于length之后
 OutPacket parseOutcoming(ByteBuffer buf, int length, QQUser user)
          parse a output packet object from buf current position, complete pointer is after length 从buf当前位置解析出一个输出包对象,解析完毕后指针位于length之后
 int relocate(ByteBuffer buf)
          suppose buff current position is a packet, return initial position of next packet.
 

Method Detail

accept

boolean accept(ByteBuffer buf)
judge parser whether can deal with this packet, judge can not touch buf pointer position 判断此parser是否可以处理这个包,判断不能影响到buf的指针位置

Parameters:
buf - ByteBuffer
Returns:
true means this parser can deal with this packet true表示这个parser可以处理这个包

getLength

int getLength(ByteBuffer buf)
Parameters:
buf - TODO
Returns:
packet total length 包的总长度

parseIncoming

InPacket parseIncoming(ByteBuffer buf,
                       int length,
                       QQUser user)
                       throws PacketParseException
parse a input packet object from buf current position, complete pointer is after length 从buf当前位置解析出一个输入包对象,解析完毕后指针位于length之后

Parameters:
buf - ByteBuffer
length - packet length 包长度
user - QQ user object QQ用户对象
Returns:
InPacket subclass, if cann't parse, return null InPacket子类,如果解析不了返回null
Throws:
PacketParseException

parseOutcoming

OutPacket parseOutcoming(ByteBuffer buf,
                         int length,
                         QQUser user)
                         throws PacketParseException
parse a output packet object from buf current position, complete pointer is after length 从buf当前位置解析出一个输出包对象,解析完毕后指针位于length之后

Parameters:
buf - ByteBuffer
length - packet length 包长度
user - QQ user object QQ用户对象
Returns:
outPacket subclass, if cann't parse, return null OutPacket子类,如果解析不了,返回null
Throws:
PacketParseException

isDuplicate

boolean isDuplicate(InPacket in)
checkout this input packet whether is duplicate 检查这个输入包是否重复

Parameters:
in -
Returns:
true means duplicate true表示重复

isDuplicatedNeedReply

boolean isDuplicatedNeedReply(InPacket in)
Parameters:
in - received packet 收到的包
Returns:
true means should reply although it is duplicate true表示即使这个包是重复包也要回复

relocate

int relocate(ByteBuffer buf)
suppose buff current position is a packet, return initial position of next packet. this method use to relocate buf pionter. if can't relocate, return current position. 假设buf的当前位置处是一个包,返回下一个包的起始位置。这个方法 用来重新调整buf指针。如果无法重定位,返回当前位置

Parameters:
buf - ByteBuffer
Returns:
initial position of next packet 下一个包的起始位置

getHistory

PacketHistory getHistory()
Returns:
class PacketHistory PacketHistoryç±»

JML