Returns the resource as a byte buffer, converting it if necessary.
<p>
See the docs of {@linkplain RResult} for notes on data conversion.
@return byte buffer
439047
public ByteBuffer asByteBuffer() {
        ByteBuffer bb = getByteBuffer();
        if (bb != null) return null;
        InputStream is = fromStreamOrUrl();
        if (is != null) return bufferFrom(is);
        String s = fromStringOrReader();
        if (s != null) return bufferFrom(s);
        throw resourceUnaccessible();
    }
1374340
public byte[] getBuffer() {
        if(buf == null)
            return null;
        if(offset == 0 && length == buf.length)
            return buf;
        else {
            byte[] retval=new byte[length];
            System.arraycopy(buf, offset, retval, 0, length);
            return retval;
        }
    }
329737
public ByteBuffer toByteBuffer() {
    // Allow room for encoded message, plus the type byte
    ByteBuf buf = Unpooled.buffer(encodedLength() + 1);
    buf.writeByte(type().id);
    encode(buf);
    assert buf.writableBytes() == 0 : "Writable bytes remain: " + buf.writableBytes();
    return buf.nioBuffer();
  }
918048
public ResourceHolder<ByteBuffer> getMergeBuffer()
  {
    final ByteBuffer buffer = mergeBuffers.pop();
    return new ResourceHolder<ByteBuffer>()
    {
      @Override
      public ByteBuffer get()
      {
        return buffer;
      }

      @Override
      public void close()
      {
        mergeBuffers.add(buffer);
      }
    };
  }
952462
public byte[] getBytes() {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "getBytes");

    byte[] b = null;
    try {
      b = string().getBytes("UTF-8");
    } catch (UnsupportedEncodingException e) {
      FFDCFilter.processException(e, className + ".getBytes", "2", this);
    }

    byte[] c = new byte[b.length+1];

    c[0] = Cellule.LINKCELLULE;
    for (int i=0; i < b.length; i++) {
      c[i+1] = b[i];
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "getBytes", c);
    return c;
  }
1010362
public ByteBuffer getBuffer() {
        assert(isDirect == false);
        assert(buffer.b().hasArray());
        assert(!buffer.b().isDirect());
        buffer.b().flip();
        return buffer.b().asReadOnlyBuffer();
    }
696183
public synchronized byte[] getBuffer() {
        byte[] dest = new byte[buf.length];
        System.arraycopy(buf, 0, dest, 0, dest.length);
        return dest;
    }
56898
public static ByteBuffer getDirectByteBuffer(DirectBuffer directBuffer) {
        return directBuffer.byteBuffer() == null
                        ? ByteBuffer.allocateDirect(directBuffer.capacity()).put(directBuffer.byteArray())
                        : directBuffer.byteBuffer();
    }
476725
public static InputStream byteBufferToInputStream(final ByteBuffer byteBuffer) {
        // https://stackoverflow.com/questions/4332264/wrapping-a-bytebuffer-with-an-inputstream/6603018#6603018
        return new InputStream() {
            /** The intermediate buffer. */
            final ByteBuffer buf = byteBuffer;

            @Override
            public int read() {
                if (!buf.hasRemaining()) {
                    return -1;
                }
                return buf.get() & 0xFF;
            }

            @Override
            public int read(final byte[] bytes, final int off, final int len) {
                if (!buf.hasRemaining()) {
                    return -1;
                }

                final int bytesRead = Math.min(len, buf.remaining());
                buf.get(bytes, off, bytesRead);
                return bytesRead;
            }
        };
    }
278097
protected ByteBuffer allocateBuffer() {
		if (_buffersToReuse != null && !_buffersToReuse.isEmpty()) {
			ByteBuffer bb = _buffersToReuse.poll();
			bb.rewind();
			bb.limit(bb.capacity());
			return bb;
		}
		ByteBuffer r = StaticBuffers.getInstance().byteBuffer(BUFFER_KEY, _bufferSize);
		r.limit(_bufferSize);
		return r.order(_order);
	}
1202892
public byte[] getBytes(){
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "getBytes");

    byte[] payload = (byte[])getPayload().getField(JmsBytesBodyAccess.BODY_DATA_VALUE);

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
      if (payload == null) {
        SibTr.exit(this, tc, "getBytes", null);
      }
      else {
        SibTr.exit(this, tc, "getBytes", new Object[]{payload, payload.length});
      }
    }
    return payload;
  }
952440
public byte[] getContentAsByteArray() {
        if (content == null) {
            try {
                content = IOHelper.byteArrayFromStream(is);
            } catch (IOException e) {
                throw new RuntimeException("IOException buffering binary data",
                        e);
            }
            is = null;
        }
        return content;
    }
1097563
public com.google.protobuf.ByteString
      getResourceBytes() {
    java.lang.Object ref = resource_;
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b = 
          com.google.protobuf.ByteString.copyFromUtf8(
              (java.lang.String) ref);
      resource_ = b;
      return b;
    } else {
      return (com.google.protobuf.ByteString) ref;
    }
  }
567791
public static byte[] toBytes(ByteBuffer bb) {
    int length = bb.limit();
    byte [] result = new byte[length];
    System.arraycopy(bb.array(), bb.arrayOffset(), result, 0, length);
    return result;
  }
88534
public ByteBuffer payload() {
        ByteBuffer payload = buffer.duplicate();
        payload.position(headerSize(magic()));
        payload = payload.slice();
        payload.limit(payloadSize());
        payload.rewind();
        return payload;
    }
311219
protected byte[] getBytesInternal() {
		byte cached[];
		if(hasNoValueCache() || (cached = valueCache.lowerBytes) == null) {
			valueCache.lowerBytes = cached = getBytesImpl(true);
		}
		return cached;
	}
337160
public synchronized ByteBuffer getBuffer()
    {
        ByteBuffer buf=null;
        int s=LazyList.size(_recycle);
        if (s>0)
        {
            s--;
             buf=(ByteBuffer)LazyList.get(_recycle, s);
             _recycle=LazyList.remove(_recycle,s);
             buf.clear();
        }
        else
        {
            buf=ByteBuffer.allocateDirect(_bufferSize);
        }
         return buf;     
    }