@Override
  public void readFromBuffer(final ByteBuffer buffer) throws IOException {
    if (headerOffset < MIN_RECV_PACKET) {
      readHeaderFromBuffer(buffer);
      if (headerOffset == MIN_RECV_PACKET) {
        parseHeaderFromBuffer();
      }
    }

    if (headerOffset >= MIN_RECV_PACKET && payload == null) {
      finishedPayload(EMPTY_BYTES);
    } else if (payload != null) {
      readPayloadFromBuffer(buffer);
    } else {
      getLogger().debug("Only read %d of the %d needed to fill a header",
        headerOffset, MIN_RECV_PACKET);
    }

  }
Read from the incoming {@link ByteBuffer}.

Reading from the buffer is done in stages, depending on how much data
can be read at once. First, the header is read and then parsed (24
bytes, indicated by {@link #MIN_RECV_PACKET}). Then, the payload is read
(if one is available for this operation and can be loaded fully).

@param buffer the buffer to read from.
@throws IOException if an error happened during parsing/reading.
src/main/java/net/spy/memcached/protocol/binary/OperationImpl.java