📄 phaseentity.java
字号:
package com.pub.backserver.phase;
import org.apache.log4j.Logger;
import org.apache.mina.common.ByteBuffer;
import com.pub.backserver.EntityHead;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2005</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class PhaseEntity extends EntityHead {
private static Logger log = Logger.getLogger(PhaseEntity.class);
public static final int PackageLength = 25;
public static final int phaseLength = 11;
private byte[] _phase = new byte[phaseLength];
private short _provID;
private short _cityID;
private short _gwID;
private int _opID;
public PhaseEntity(){
super(PackageLength);
}
public void reset() {
_provID = _cityID = _gwID = 0;
}
public short getCityID() {
return _cityID;
}
public void setCityID(short cityID) {
this._cityID = cityID;
}
public short getGwID() {
return _gwID;
}
public void setGwID(short gwID) {
this._gwID = gwID;
}
public short getProvID() {
return _provID;
}
public void setProvID(short provID) {
this._provID = provID;
}
public int getPhaseLength() {
int len = phaseLength;
while (len > 0 && _phase[len - 1] == 0) {
len--;
}
return len;
}
public String getStrPhase() {
return new String(_phase, 0, getPhaseLength());
}
public byte[] bytesPhase() {
return _phase;
}
public void setStrPhase(String phase) {
int i = 0;
while (i < phaseLength && i < phase.length()) {
_phase[i] = new Integer(phase.charAt(i++)).byteValue();
}
while (i < phaseLength) {
_phase[i++] = 0;
}
}
public void bytesPhase(byte[] phase, int index) {
int i = 0;
while (i < phaseLength && i < phase.length) {
_phase[i] = phase[index + i++];
}
while (i < phaseLength) {
_phase[i++] = 0;
}
}
public void bytesPhase(byte[] phase) {
bytesPhase(phase, 0);
}
public String toString() {
StringBuilder sb = new StringBuilder(50);
sb.append("phase=").append(this.getStrPhase()).append(' ');
sb.append("provID=").append(this.getProvID()).append(' ');
sb.append("cityID=").append(this.getCityID()).append(' ');
sb.append("gwID=").append(this.getGwID()).append(' ');
sb.append("opID=").append(this.getOpID());
return sb.toString();
}
// public void toByteBuffer(ByteBuffer out) {
// for (int i = 0; i < phaseLength; i++) {
// out.put(_phase[i]);
// }
// out.putShort(_provID);
// out.putShort(_cityID);
// out.putShort(_gwID);
// }
//
// public void fromByteBuffer(ByteBuffer in) {
// for (int i = 0; i < phaseLength; i++) {
// _phase[i] = in.get();
// }
// _provID = in.getShort();
// _cityID = in.getShort();
// _gwID = in.getShort();
// }
public int writePackage(ByteBuffer out) throws Exception {
super.writePackage(out);
for (int i = 0; i < phaseLength; i++) {
out.put(_phase[i]);
}
out.putShort(_provID);
out.putShort(_cityID);
out.putShort(_gwID);
out.putInt(_opID);
return 0;
}
public int readPackage(ByteBuffer in) throws Exception {
super.readPackage(in);
for (int i = 0; i < phaseLength; i++) {
_phase[i] = in.get();
}
_provID = in.getShort();
_cityID = in.getShort();
_gwID = in.getShort();
_opID = in.getInt();
return 0;
}
public int writePackage(java.nio.ByteBuffer out) throws Exception {
super.writePackage(out);
for (int i = 0; i < phaseLength; i++) {
out.put(_phase[i]);
}
out.putShort(_provID);
out.putShort(_cityID);
out.putShort(_gwID);
out.putInt(_opID);
return 0;
}
public int readPackage(java.nio.ByteBuffer in) throws Exception {
super.readPackage(in);
for (int i = 0; i < phaseLength; i++) {
_phase[i] = in.get();
}
_provID = in.getShort();
_cityID = in.getShort();
_gwID = in.getShort();
_opID = in.getInt();
return 0;
}
public int getHeaderLength() {
return HeaderLength;
}
public int getPackageLength() {
return PackageLength;
}
public int getOpID() {
return _opID;
}
public void setOpID(int opid) {
_opID = opid;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -