}
}
}
public boolean readFromPacket(Packet packet) throws IOException {
Packet dup = packet.duplicate();
if( dup.remaining() < RECORD_HEADER_SIZE )
return false;
DataInputStream is = new DataInputStream(new PacketToInputStream(dup));
readHeader( is );
if( dup.remaining() < payloadLength+RECORD_FOOTER_SIZE ) {
return false;
}
// Set limit to create a slice of the payload.
dup.limit(dup.position()+payloadLength);
this.payload = dup.slice();
if( isChecksumingEnabled() ) {
checksum(new DataInputStream(new PacketToInputStream(payload)));
}
// restore the limit and seek to the footer.
dup.limit(packet.limit());
dup.position(dup.position()+payloadLength);
readFooter(is);
// If every thing went well.. advance the position of the orignal packet.
packet.position(dup.position());
dup.dispose();
return true;
}