📄 sotest.java
字号:
/*
* 创建日期 2005-4-30
*
* TODO 要更改此生成的文件的模板,请转至
* 窗口 - 首选项 - Java - 代码样式 - 代码模板
*/
package com.dog3.prettyBoy;
import java.nio.ByteBuffer;
/**
* @author Administrator
*
* TODO 要更改此生成的类型注释的模板,请转至
* 窗口 - 首选项 - Java - 代码样式 - 代码模板
*/
public class SoTest {
private ByteBuffer buffer = null;
//初始函数1
public SoTest() {
buffer = ByteBuffer.allocate(Define2.MT_Packet_length);
buffer.order(Define2.Int_Order);
}
//初始函数2
public SoTest(ByteBuffer byteBuffer1) {
buffer = byteBuffer1;
buffer.order(Define2.Int_Order);
}
//SET Id 参数
public void setID(byte[] protocol) {
buffer.position(Define2.SoTest_Id_index);
if (protocol.length >= Define2.SoTest_Id_length) {
buffer.put(protocol, 0, Define2.SoTest_Id_length);
} else {
buffer.put(protocol, 0, protocol.length);
}
}
// SET TYPE 参数
public void setType(byte[] protocol) {
buffer.position(Define2.SoTest_Type_index);
if (protocol.length >= Define2.SoTest_Type_length) {
buffer.put(protocol, 0, Define2.SoTest_Type_length);
} else {
buffer.put(protocol, 0, protocol.length);
}
}
// SET MT_ThirdPartyID 参数
public void setResult(byte[] protocol) {
buffer.position(Define2.SoTest_Result_index);
if (protocol.length >= Define2.SoTest_Result_length) {
buffer.put(protocol, 0, Define2.SoTest_Result_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);
}
buffer.clear();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -