📄 mtpacket.java
字号:
/*
* 创建日期 2005-4-30
*
* TODO 要更改此生成的文件的模板,请转至
* 窗口 - 首选项 - Java - 代码样式 - 代码模板
*/
package com.dog3.prettyBoy;
import java.nio.ByteBuffer;
/**
* @author Administrator
*
* TODO 要更改此生成的类型注释的模板,请转至
* 窗口 - 首选项 - Java - 代码样式 - 代码模板
*/
public class MtPacket {
private ByteBuffer buffer = null;
//初始函数1
public MtPacket() {
buffer = ByteBuffer.allocate(Define2.MT_Packet_length);
buffer.order(Define2.Int_Order);
}
//初始函数2
public MtPacket(ByteBuffer byteBuffer1) {
buffer = byteBuffer1;
buffer.order(Define2.Int_Order);
}
//SET Id 参数
public void setID(int protocol) {
int length = 4;
buffer.position(Define2.MT_Id_index);
buffer.putInt(protocol);
}
// SET TYPE 参数
public void setType(byte[] protocol) {
buffer.position(Define2.MT_Type_index);
if (protocol.length >= Define2.MT_Type_length) {
buffer.put(protocol, 0, Define2.MT_Type_length);
} else {
buffer.put(protocol, 0, protocol.length);
}
}
// SET MT_ThirdPartyID 参数
public void setThirdPartyID(byte[] protocol) {
buffer.position(Define2.MT_ThirdPartyID_index);
if (protocol.length >= Define2.MT_ThirdPartyID_length) {
buffer.put(protocol, 0, Define2.MT_ThirdPartyID_length);
} else {
buffer.put(protocol, 0, protocol.length);
}
}
// SET MT_FromTel 参数
public void setFromTel(byte[] protocol) {
buffer.position(Define2.MT_FromTel_index);
if (protocol.length >= Define2.MT_FromTel_length) {
buffer.put(protocol, 0, Define2.MT_FromTel_length);
} else {
buffer.put(protocol, 0, protocol.length);
}
}
// SET ToTel 参数
public void setToTel(byte[] protocol) {
buffer.position(Define2.MT_ToTel_index);
if (protocol.length >= Define2.MT_ToTel_length) {
buffer.put(protocol, 0, Define2.MT_ToTel_length);
} else {
buffer.put(protocol, 0, protocol.length);
}
}
// SET SMSContent 参数
public void setSMSContent(byte[] protocol) {
buffer.position(Define2.MT_SMSContent_index);
if (protocol.length >= Define2.MT_SMSContent_length) {
buffer.put(protocol, 0, Define2.MT_SMSContent_length);
} else {
buffer.put(protocol, 0, protocol.length);
}
}
// SET Worker 参数
public void setWorker(byte[] protocol) {
buffer.position(Define2.MT_Worker_index);
if (protocol.length >= Define2.MT_Worker_length) {
buffer.put(protocol, 0, Define2.MT_Worker_length);
} else {
buffer.put(protocol, 0, protocol.length);
}
}
public ByteBuffer getByteBuffer() {
return buffer;
}
/**
*
*/
public void reuse() {
buffer.clear();
buffer.position(0);
for (int i = 0; i < Define2.MT_Packet_length; i++) {
buffer.put((byte) 0);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -