public final ByteBuffer serialize ( ) throws InternetSCSIException , IOException { basicHeaderSegment . getParser ( ) . checkIntegrity ( ) ; final ByteBuffer pdu = ByteBuffer . allocate ( calcSize ( ) ) ; int offset = 0 ; offset += basicHeaderSegment . serialize ( pdu , offset ) ; if ( LOGGER . isTraceEnabled ( ) ) { LOGGER . trace ( "Serialized Basic Header Segment:\n" + toString ( ) ) ; } offset += serializeAdditionalHeaderSegments ( pdu , offset ) ; // write header digest // TODO: Move CRC calculation in BasicHeaderSegment.serialize? if ( basicHeaderSegment . getParser ( ) . canHaveDigests ( ) ) { offset += serializeDigest ( pdu , headerDigest ) ; } // serialize data segment offset += serializeDataSegment ( pdu , offset ) ; // write data segment digest // TODO: Move CRC calculation in BasicHeaderSegment.serialize? if ( basicHeaderSegment . getParser ( ) . canHaveDigests ( ) ) { offset += serializeDigest ( pdu , dataDigest ) ; } return ( ByteBuffer ) pdu . rewind ( ) ; }
Serialize all informations of this PDU object to its byte representation .