code: public MessageBuffer toMessageBuffer()
      {
          if (list.size() == 1) {
              return list.get(0);
          }
          else if (list.isEmpty()) {
              return MessageBuffer.allocate(0);
          }
          else {
              return MessageBuffer.wrap(toByteArray());
          }
      }
docs: Gets the written data as a MessageBuffer.
  <p>
  Unlike {@link #toByteArray()}, this method omits copy of the contents if size of the written data is smaller
  than a single buffer capacity.
  
  @return the MessageBuffer instance