📄 msghead.java
字号:
package com.gctech.cmpp3.msg;
import java.io.*;
/**
* <p>Title: CNGP API</p>
* <p>Description: 固网短信SP API</p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: GCTECH</p>
* @author 王红宝
* @version $Id: MsgHead.java,v 1.1 2004/05/21 07:50:10 wanghb Exp $
*/
public class MsgHead{
//消息总长度
private int totalLength;
//命令ID
private int commandId;
//序列号
private int sequenceId;
public MsgHead() {
}
public MsgHead(int totalLength,int commandId,int sequenceId) {
this.totalLength=totalLength;
this.commandId=commandId;
this.sequenceId=sequenceId;
}
public int getTotalLength() {
return totalLength;
}
public void setTotalLength(int totalLength) {
this.totalLength = totalLength;
}
public int getCommandId() {
return commandId;
}
public void setCommandId(int commandId) {
this.commandId = commandId;
}
public int getSequenceId() {
return sequenceId;
}
public void setSequenceId(int sequenceId) {
this.sequenceId = sequenceId;
}
//add by liya
public byte Head[];
public int read(InputStream inputstream){
byte abyte0[] = new byte[4];
try {
inputstream.read(abyte0);
CmppMsg.BytesCopy(abyte0, Head, 0, 3, 0);
totalLength = CmppMsg.Bytes4ToInt(abyte0);
inputstream.read(abyte0);
CmppMsg.BytesCopy(abyte0, Head, 0, 3, 4);
commandId = CmppMsg.Bytes4ToInt(abyte0);
inputstream.read(abyte0);
CmppMsg.BytesCopy(abyte0, Head, 0, 3, 8);
sequenceId = CmppMsg.Bytes4ToInt(abyte0);
} catch(Exception exception){
System.out.println(exception.toString());
return -1;
}
return 0;
}
public byte[] toByteArray(){
byte[] data=new byte[12];
CmppMsg.BytesCopy(CmppMsg.IntToBytes4(totalLength),data,0,3,0);
CmppMsg.BytesCopy(CmppMsg.IntToBytes4(commandId),data,0,3,4);
CmppMsg.BytesCopy(CmppMsg.IntToBytes4(sequenceId),data,0,3,8);
return data;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -