code: public static final byte[] asByteArray(WsByteBuffer buff, int position, int limit) {
          if (null == buff)
              return null;
          int size = limit - position;
          if (0 == size)
              return null;
          byte[] byteBuff = new byte[size];
          int currentPosition = buff.position();
          buff.position(position);
          buff.get(byteBuff, 0, size);
          buff.position(currentPosition);
          return byteBuff;
      }
docs: Convert a buffer into a byte array using the input starting position and
  ending limit. If the buffer is null or empty then a null byte[] is
  returned.
  
  @param buff
  @param position
  @param limit
  @return byte[]