| | |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * Tcp协议报文基类 |
| | | * @author vincent |
| | | */ |
| | | public class Struct implements java.io.Serializable { |
| | | |
| | | private transient Map<String,byte[]> decodeByteMapping = new HashMap<>(); |
| | |
| | | public Class getClassType(String name){ |
| | | return null; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 判断大小端 |
| | | * @return true: 小端 / false: 大端 |
| | | */ |
| | | public boolean isReverse() { |
| | | return this.getClass().getAnnotation(little.class)!=null; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取字节数组 |
| | | */ |
| | | public byte[] toBytes() throws Exception { |
| | | return encode(this); |
| | | } |
| | |
| | | * |
| | | * @param dos |
| | | * @param entity |
| | | * @throws Exception |
| | | */ |
| | | public void write(DataOutputStream dos, Struct entity) throws Exception { |
| | | if(entity==null)return; |