JML

net.sf.jqql.beans
Class NormalIM

java.lang.Object
  extended by net.sf.jqql.beans.NormalIM

public class NormalIM
extends Object

 reality of normal message is behind NormalIMHeader.

 normal message may be enbedded with some info of photos, besindes plain text.  Photo info format are:
 one, default face, the leading byte of default font is 0x14, behind 0x14 is index of default face.
 two, custom face. the leading byte of Custom face  is 0x15, behind 0x15 is the format:
    1, existence byte. If  it comes out for the first time, it's 0x33, otherwise, it's 0x34. content behind is:
        i. length of EX name, 1 byte, benchmark with '0', '2' indicates length is 3.
        ii. file name of face photo, name is combined with "md5" and EX name. So the length is 32 + 1 + 3(often is gif)
        iii. length of face shortcut, benchmark with 'A'. If the length is 2, the byte is 'C'.
        iv. face shortcut
    2. if it's 0x34, content behind is:
        i. 1 byte index. if this custom face comes out in the first position, this byte is 'A'
    3. if it's 0x36,custer internal custom face.
        i. decimal form of length of custom face protocol block, 3 bytes. If it's not long enough, use space to fill the front.
           For example, to indicates the custom face is 88 bytes long, it's "88". hehe, Amazing!. Notice, the length is counted from
           0x15 to the end. And this length is byte length.
        ii. face id, 1 byte, indicates  the face is new or not. If it's new, use 'e' to present. If it came out before, use an upper character to
            to present. The first new face use "A", and then "B", and so on.
        iii. byte length of face shortcut , 1 byte, use an upper character to present, for example, use  'A' to indicate length is 0, and so on.
        iv. length of content behind, till to agent key, 2 bytes, use hexadecimal  string to present.
        v. session id in hexadecimal  string form, 8 bytes, not long enough, use space to fill in.
        vi agent ip in hexadecimal string form, notice, ti's little-endian, so ipv4  uses 8 bytes.
        vii. agent port in hexadecimal string form, 8 bytes.
        viii. file agent key, 16 bytes.
        ix. photo's name, its form is combination of "MD5" in string form plus dot and plus suffix, normally 36 bytes. 
             But I think it's better to count it by minus the other fileds length from the length ahead.
        x. shortcut, length is refered before.
        xi. a byte, 'A', may be used for bounding.
    4. if it's 0x3, cluster internal custom face.
        0x37 indicates that  this face came out before, refer to 0x36 format, 0x37 doesn't have iv,v,vii,viii,ix part of
        0x36 but have the remain. 
 普通消息的本体,其在NormalIMHeader之后
 
 普通消息中可能内嵌一些图片信息,除了普通的文本之外,图片的信息格式为:
 一. 缺省表情,缺省表情的前导字节是0x14,0x14之后的一个字节表示缺省表情的索引值
 二. 自定义表情,自定义表情的前导字节是0x15,0x15之后的格式为:
       1. 存在性字节,如果这个表情第一次出现,则为0x33,如果已经出现过,则为0x34,当为0x33时,后面的内容是
          i.   扩展名长度,1字节,以'0'为基准,'2'则表示长度为3
       ii.  表情图片的文件名,其文件名由md5的字符串形式和扩展名构成,因此这个长度应该是32 + 1 + 3(一般是GIF)
       iii. 表情的shortcut长度,以'A'为基准,如果长度是2,则这个字节是'C'
       iv.  表情的shortcut
    2. 如果为0x34时,则后面的内容为:
          i.   1字节索引值,假如这个自定义表情出现在第一个位置,则这个字节为'A'   
    3. 如果为0x36时,群内自定义表情
          i. 自定义表情协议块的长度的10进制字符串形式,3字节,不足者前部填为空格,比如为了表示这个自定义表情用了
          88个字节,那么这个字段就是" 88",呵呵,晕吧,注意这个长度是从0x15开始算起,一直到结束。注意这个长度
          是字节长度
       ii. 表情标识,1字节,标识这个表情是新的,还是已经出现过的,如果是新的,用'e'表示。如果是已经出现过的,
           用一个大写字母表示,第一个新表情代号是A,第二个是B,以此类推
       iii. 表情的快捷键字节长度,1字节,用一个大写字母表示,比如A表示长度为0,依次类推
       iv. 后面的内容开始一直到agent key之前的内容的长度,2字节,用16进制的字符串表示
       v. session id的16进制字符串形式,8字节,不足者前面是空格
       vi. 中转服务器IP的16进制字符串形式,注意是little-endian,那么ipv4的话自然就是8个字节了
       vii. 中转服务器端口号的16进制字符串形式,8个字节
       viii. file agent key,16字节
       ix. 图片的文件名,文件名的形式是MD5的字符串形式加上点加上后缀名而成,所以一般是36个字节,但是
           我想最好还是根据前面的长度减去其他字段的长度来判断好些
       x.  快捷键,长度前面已经说了
       xi. 一个字节,'A',可能是用来分界用的
    4. 如果为0x37时,群内自定义表情
       0x37表示这个表情已经在前面出现过,参见0x36时的格式,0x37缺少0x36的iv, v, vii, viii, ix部分,
       其他部分均相同
 

Author:
luma

Field Summary
 FontStyle fontStyle
           
 int fragmentSequence
           
 boolean hasFontAttribute
           
 String message
           
 byte[] messageBytes
           
 int messageId
           
 byte replyType
           
 int totalFragments
           
 
Constructor Summary
NormalIM()
           
 
Method Summary
 void readBean(ByteBuffer buf)
          given an input stream, parse NormalIM .
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

hasFontAttribute

public boolean hasFontAttribute

totalFragments

public int totalFragments

fragmentSequence

public int fragmentSequence

messageId

public int messageId

replyType

public byte replyType

fontStyle

public FontStyle fontStyle

messageBytes

public byte[] messageBytes

message

public String message
Constructor Detail

NormalIM

public NormalIM()
Method Detail

readBean

public void readBean(ByteBuffer buf)
given an input stream, parse NormalIM . 给定一个输入流,解析NormalIM结构

Parameters:
buf -

JML