cn.tom.protocol.co.Field Maven / Gradle / Ivy
The newest version!
package cn.tom.protocol.co;
import cn.tom.kit.IoBuffer;
/**
* 定义 参数 类型 长度
*
* @author tomsun
*
*/
public class Field {
private byte columnLength;
private String columnName;
private short typeModifier; // field 转换类型
public Field() {
}
public Field(String columnName, int typeModifier) {
this.columnLength = (byte) columnName.getBytes().length;
this.columnName = columnName;
this.typeModifier = (short) typeModifier;
}
public int getFieldLen() {
int size = 1 + getColumnLength() + 2;
return size;
}
public int getColumnLength() {
return columnLength & 0XFF;
}
public String getColumnName() {
return columnName;
}
public int getTypeModifier() {
return typeModifier;
}
public void toBytes(IoBuffer buf) {
buf.writeByte(columnLength).writeString(columnName).writeShort(typeModifier);
}
@Override
public String toString() {
return "Field [columnLength=" + columnLength + ", columnName=" + columnName + ", typeModifier=" + typeModifier + "]";
}
}