Is there a clean sure fire way to detect if a ByteBuffer needs flipping?
I have a ByteBuffer that is used for packing and unpacking a data stucture and also for storage of bytes to be packed / unpacked.
However, if a write operation has just been performed or a read operation has been performed or if a ByteBuffer was passed to my code I cannot guarantee that the buffer is in write mode or read mode with out manually manipulating position and limit.
Partial reads and writes also present add to this problem. I have been adopting the convention that the buffer is left in write mode and a duplicate is created and flip'ed for read purposes. When a buffer is passed in to my code is is manually inspected and position and limit are set as they would be in write mode. Surely there is a better way.