public void unmarshal(DataInputStream dis) { super.unmarshal(dis); try { minefieldID.unmarshal(dis); requestingEntityID.unmarshal(dis); requestID = (short) dis.readUnsignedByte(); numberOfPerimeterPoints = (short) dis.readUnsignedByte(); pad2 = (short) dis.readUnsignedByte(); numberOfSensorTypes = (short) dis.readUnsignedByte(); dataFilter = dis.readInt(); requestedMineType.unmarshal(dis); for (int idx = 0; idx < numberOfPerimeterPoints; idx++) { Point anX = new Point(); anX.unmarshal(dis); requestedPerimeterPoints.add(anX); } for (int idx = 0; idx < numberOfSensorTypes; idx++) { TwoByteChunk anX = new TwoByteChunk(); anX.unmarshal(dis); sensorTypes.add(anX); } } // end try catch (Exception e) { System.out.println(e); } } // end of unmarshal method
public void marshal(DataOutputStream dos) { super.marshal(dos); try { minefieldID.marshal(dos); requestingEntityID.marshal(dos); dos.writeByte((byte) requestID); dos.writeByte((byte) requestedPerimeterPoints.size()); dos.writeByte((byte) pad2); dos.writeByte((byte) sensorTypes.size()); dos.writeInt((int) dataFilter); requestedMineType.marshal(dos); for (int idx = 0; idx < requestedPerimeterPoints.size(); idx++) { Point aPoint = requestedPerimeterPoints.get(idx); aPoint.marshal(dos); } // end of list marshalling for (int idx = 0; idx < sensorTypes.size(); idx++) { TwoByteChunk aTwoByteChunk = sensorTypes.get(idx); aTwoByteChunk.marshal(dos); } // end of list marshalling } // end try catch (Exception e) { System.out.println(e); } } // end of marshal method
/** * Packs a Pdu into the ByteBuffer. * * @throws java.nio.BufferOverflowException if buff is too small * @throws java.nio.ReadOnlyBufferException if buff is read only * @see java.nio.ByteBuffer * @param buff The ByteBuffer at the position to begin writing * @since ?? */ public void marshal(java.nio.ByteBuffer buff) { super.marshal(buff); minefieldID.marshal(buff); requestingEntityID.marshal(buff); buff.put((byte) requestID); buff.put((byte) requestedPerimeterPoints.size()); buff.put((byte) pad2); buff.put((byte) sensorTypes.size()); buff.putInt((int) dataFilter); requestedMineType.marshal(buff); for (int idx = 0; idx < requestedPerimeterPoints.size(); idx++) { Point aPoint = (Point) requestedPerimeterPoints.get(idx); aPoint.marshal(buff); } // end of list marshalling for (int idx = 0; idx < sensorTypes.size(); idx++) { TwoByteChunk aTwoByteChunk = (TwoByteChunk) sensorTypes.get(idx); aTwoByteChunk.marshal(buff); } // end of list marshalling } // end of marshal method
public int getMarshalledSize() { int marshalSize = 0; marshalSize = super.getMarshalledSize(); marshalSize = marshalSize + minefieldID.getMarshalledSize(); // minefieldID marshalSize = marshalSize + requestingEntityID.getMarshalledSize(); // requestingEntityID marshalSize = marshalSize + 1; // requestID marshalSize = marshalSize + 1; // numberOfPerimeterPoints marshalSize = marshalSize + 1; // pad2 marshalSize = marshalSize + 1; // numberOfSensorTypes marshalSize = marshalSize + 4; // dataFilter marshalSize = marshalSize + requestedMineType.getMarshalledSize(); // requestedMineType for (int idx = 0; idx < requestedPerimeterPoints.size(); idx++) { Point listElement = requestedPerimeterPoints.get(idx); marshalSize = marshalSize + listElement.getMarshalledSize(); } for (int idx = 0; idx < sensorTypes.size(); idx++) { TwoByteChunk listElement = sensorTypes.get(idx); marshalSize = marshalSize + listElement.getMarshalledSize(); } return marshalSize; }
/** * Unpacks a Pdu from the underlying data. * * @throws java.nio.BufferUnderflowException if buff is too small * @see java.nio.ByteBuffer * @param buff The ByteBuffer at the position to begin reading * @since ?? */ public void unmarshal(java.nio.ByteBuffer buff) { super.unmarshal(buff); minefieldID.unmarshal(buff); requestingEntityID.unmarshal(buff); requestID = (short) (buff.get() & 0xFF); numberOfPerimeterPoints = (short) (buff.get() & 0xFF); pad2 = (short) (buff.get() & 0xFF); numberOfSensorTypes = (short) (buff.get() & 0xFF); dataFilter = buff.getInt(); requestedMineType.unmarshal(buff); for (int idx = 0; idx < numberOfPerimeterPoints; idx++) { Point anX = new Point(); anX.unmarshal(buff); requestedPerimeterPoints.add(anX); } for (int idx = 0; idx < numberOfSensorTypes; idx++) { TwoByteChunk anX = new TwoByteChunk(); anX.unmarshal(buff); sensorTypes.add(anX); } } // end of unmarshal method