code: public static final byte[] asByteArray(WsByteBuffer buff) {
          if (null == buff)
              return null;
          int size = buff.limit();
          if (0 == size) {
              return null;
          }
          byte[] output = new byte[size];
          int position = buff.position();
          buff.position(0);
          buff.get(output);
          buff.position(position);
          return output;
      }
docs: Convert a buffer into a byte array. A null or empty buffer will return a
  null
  byte[].
  
  @param buff
  @return byte[]