Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1480901
  • 博文数量: 108
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 997
  • 用 户 组: 普通用户
  • 注册时间: 2013-06-29 09:58
个人简介

兴趣是坚持一件事永不衰竭的动力

文章分类

全部博文(108)

文章存档

2021年(1)

2020年(10)

2019年(19)

2018年(9)

2016年(23)

2015年(43)

2013年(3)

我的朋友

分类: Java

2016-01-18 00:40:34

package com.dd.model.protocol;


public class CmdLoginDecoder
{
Field version = new Field(new TTL((short)1, DataTypeEnum.INT16), new Value<>((short)1));
Field cmd = new Field(new TTL((short)2, DataTypeEnum.INT32), new Value<>(1));
Field handle = new Field(new TTL((short)3, DataTypeEnum.FLOAT), new Value<>(-1f));
Field userName = new Field(new TTL((short)4, DataTypeEnum.STRING), new Value<>("fang"));
Field password = new Field(new TTL((short)5, DataTypeEnum.STRING), new Value<>("fang"));
CmdLogin cmdLogin = new CmdLogin( version,  cmd,  handle,  userName,  password);


String serialData;
byte  serialByte[];
public CmdLoginDecoder(String serialString)
{
this.serialData = serialString;
serialByte = serialData.getBytes();
getCmdLogin();
}
public CmdLoginDecoder(byte  serialByte[])
{
this.serialByte = serialByte;
serialData = new String(serialByte);

}
public  CmdLogin getCmdLogin()
{
int offset = 0;
int len = 0;
CmdLogin cmdLogin = null;
if(serialData == null) return null;
if(serialByte == null) return null;
String pureString = serialData.replace(" ", "");
FieldDecoder versionFieldDecoder = new FieldDecoder(SerialDataDecoder.toByteArray(pureString.substring(0, 6*2)));
Field version = versionFieldDecoder.doDecoder();

offset += version.getTotalLen();
TTLDecoder ttlDecoder = new TTLDecoder(SerialDataDecoder.toByteArray(serialData.substring(0,6)));
System.out.println(pureString);
return cmdLogin;

}



}

阅读(817) | 评论(0) | 转发(0) |
0

上一篇:CmdLogin.java

下一篇:DataTypeEnum.java

给主人留下些什么吧!~~