62,614
社区成员
发帖
与我相关
我的任务
分享
Application header, Version,...(后面还有其他的,不一一列举了)
public class ApplicationHeader {
private byte ACPProtocol;
private byte privateFlag;
private byte testFlag;
private byte messageType;
private byte versionFlag;
private byte version;
private byte messageControlFlag;
private int messageLength;
public ApplicationHeader() {
}
public String getApplicationHeader(){
return "";
}
}
public class ApplicationHeader {
private int _apc_protocol;
private int _private_Flag;
private int _test_Flag;
private int _message_Type;
public void read(byte[] bytes){
_apc_protocol = bytes[0] & 1;
_private_Flag = (bytes[0] & 2) >> 1;
_test_Flag = (bytes[0] & 4) >> 2;
_message_Type = bytes[0] >> 3;
}
public byte[] write(){
byte[] bytes = new byte[4];
int tmp = (_apc_protocol & 1) | ((_private_Flag & 1) << 1) | ((_test_Flag & 1) << 2) | _message_Type << 3;
bytes[0] = (byte)tmp;
return bytes;
}
}
什么封装属性字段的get set的方法,我就懒得贴了,累