?? cmppsubmitrepmessage.java
字號:
package com.huawei.insa2.comm.cmpp.message;
import com.huawei.insa2.comm.cmpp.CMPPConstant;
import com.huawei.insa2.util.TypeConvert;
public class CMPPSubmitRepMessage extends CMPPMessage {
public CMPPSubmitRepMessage(int seq_id, byte[] msg_id, byte result) {
if (seq_id < 0) {
throw new IllegalArgumentException(CMPPConstant.SMC_MESSAGE_ERROR);
}
if (msg_id == null || msg_id.length != 8) {
throw new IllegalArgumentException(CMPPConstant.SMC_MESSAGE_ERROR);
}
int len = 21;
super.buf = new byte[len];
TypeConvert.int2byte(len, super.buf, 0);
TypeConvert.int2byte(CMPPConstant.Submit_Rep_Command_Id, super.buf, 4);
TypeConvert.int2byte(seq_id, super.buf, 8);
System.arraycopy(msg_id, 0, super.buf, 12, 8);
super.buf[20] = result;
this.sequence_Id = seq_id;
}
public CMPPSubmitRepMessage(byte buf[]) throws IllegalArgumentException {
if (buf.length != 13) {
throw new IllegalArgumentException(CMPPConstant.SMC_MESSAGE_ERROR);
}
int len = 21;
super.buf = new byte[len];
TypeConvert.int2byte(len, super.buf, 0);
TypeConvert.int2byte(CMPPConstant.Submit_Rep_Command_Id, super.buf, 4);
System.arraycopy(buf, 0, super.buf, 8, 13);
super.sequence_Id = TypeConvert.byte2int(buf, 0);
}
/**
* 信息標識,生成算法如下:<br>
*
* 采用64位(8字節)的整數:<br>
* (1)時間(格式為MMDDHHMMSS,即月日時分秒):bit64~bit39,其中<BR>
* <ul>
* <li>bit64~bit61:月份的二進制表示;
* <li>bit60~bit56:日的二進制表示;
* <li>bit55~bit51:小時的二進制表示;
* <li>bit50~bit45:分的二進制表示;
* <li>bit44~bit39:秒的二進制表示;
* </ul>
* (2)短信網關代碼:bit38~bit17,把短信網關的代碼轉換為整數填寫到該字段中。<BR>
* (3)序列號:bit16~bit1,順序增加,步長為1,循環使用。<BR>
* 各部分如不能填滿,左補零,右對齊。<BR>
* (SP根據請求和應答消息的Sequence_Id一致性就可得到CMPP_Submit消息的Msg_Id)<BR>
*
* @return
*/
public byte[] getMsgId() {
byte tmpMsgId[] = new byte[8];
System.arraycopy(super.buf, 12, tmpMsgId, 0, 8);
return tmpMsgId;
}
/**
* 結果
*
* 0:正確<br>
* 1:消息結構錯<br>
* 2:命令字錯<br>
* 3:消息序號重復<br>
* 4:消息長度錯<br>
* 5:資費代碼錯<br>
* 6:超過最大信息長<br>
* 7:業務代碼錯<br>
* 8:流量控制錯<br>
* 9~ :其他錯誤<br>
*/
public int getResult() {
return super.buf[20];
}
public String toString() {
String tmpStr = "CMPP_Submit_REP: ";
tmpStr = tmpStr + "Sequence_Id=" + getSequenceId();
tmpStr = tmpStr + ",MsgId=" + TypeConvert.getLong(getMsgId(), 0);
tmpStr = tmpStr + ",Result=" + getResult();
return tmpStr;
}
public int getCommandId() {
return CMPPConstant.Submit_Rep_Command_Id;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -