ByteBufferHolder (Apache Tomcat 9.0.120 API Documentation)
Description: declaration: package: org.apache.tomcat.util.buf, class: ByteBufferHolder

# Class ByteBufferHolder

java.lang.Object
org.apache.tomcat.util.buf.ByteBufferHolder

public class ByteBufferHolder extends Object
Simple wrapper for a `ByteBuffer` that remembers if the buffer has been flipped or not.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ByteBufferHolder(ByteBuffer buf, boolean flipped)`
  Constructs a holder for the specified buffer.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `flip()`
  Flips the buffer if not already flipped.
  `ByteBuffer`
  `getBuf()`
  Returns the wrapped buffer.
  `boolean`
  `isFlipped()`
  Returns whether the buffer has been flipped.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### ByteBufferHolder

    public ByteBufferHolder(ByteBuffer buf, boolean flipped)
    Constructs a holder for the specified buffer.
    Parameters:
      `buf` - the buffer
      `flipped` - initial flipped state

- ## Method Details

  - ### getBuf

    public ByteBuffer getBuf()
    Returns the wrapped buffer.
    Returns:
      the buffer

  - ### isFlipped

    public boolean isFlipped()
    Returns whether the buffer has been flipped.
    Returns:
      true if flipped

  - ### flip

    public boolean flip()
    Flips the buffer if not already flipped.
    Returns:
      true if the buffer was flipped by this call