public byte[] toByteArray() throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(512); DataOutputStream dos = new DataOutputStream(baos); dos.write(NameUtil.toByteArray(this.name)); dos.writeShort(type.getValue()); dos.writeShort(clazz.getValue()); dos.flush(); return baos.toByteArray(); }
public void parse(DataInputStream dis, byte[] data) throws IOException { this.name = NameUtil.parse(dis, data); this.type = TYPE.getType(dis.readUnsignedShort()); this.clazz = CLASS.getClass(dis.readUnsignedShort()); }