JML

net.sf.jqql.packets
Class BasicFamilyParser

java.lang.Object
  extended by net.sf.jqql.packets.BasicFamilyParser
All Implemented Interfaces:
IParser

public class BasicFamilyParser
extends Object
implements IParser

basic protocol family parser 基本协议族解析器

Author:
luma

Constructor Summary
BasicFamilyParser()
           
 
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 len, QQUser user)
          parse a input packet object from buf current position, complete pointer is after length 从buf当前位置解析出一个输入包对象,解析完毕后指针位于length之后
 OutPacket parseOutcoming(ByteBuffer buf, int len, 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicFamilyParser

public BasicFamilyParser()
Method Detail

accept

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

Specified by:
accept in interface IParser
Parameters:
buf - ByteBuffer
Returns:
true means this parser can deal with this packet true表示这个parser可以处理这个包

getLength

public int getLength(ByteBuffer buf)
Specified by:
getLength in interface IParser
Parameters:
buf - TODO
Returns:
packet total length 包的总长度

isDuplicate

public boolean isDuplicate(InPacket in)
Description copied from interface: IParser
checkout this input packet whether is duplicate 检查这个输入包是否重复

Specified by:
isDuplicate in interface IParser
Returns:
true means duplicate true表示重复

parseIncoming

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

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

parseOutcoming

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

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

isDuplicatedNeedReply

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

relocate

public int relocate(ByteBuffer buf)
Description copied from interface: IParser
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指针。如果无法重定位,返回当前位置

Specified by:
relocate in interface IParser
Parameters:
buf - ByteBuffer
Returns:
initial position of next packet 下一个包的起始位置

getHistory

public PacketHistory getHistory()
Specified by:
getHistory in interface IParser
Returns:
class PacketHistory PacketHistoryç±»

JML