Package org.apache.tomcat.util.buf

# Class AbstractChunk

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

All Implemented Interfaces:
  `Serializable`, `Cloneable`

Direct Known Subclasses:
  `ByteChunk`, `CharChunk`

public abstract class AbstractChunk extends Object implements Cloneable, Serializable
Base class for the *Chunk implementation to reduce duplication.

See Also:
  - Serialized Form

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `ARRAY_MAX_SIZE`
  `protected int`
  `end`
  `protected boolean`
  `hasHashCode`
  `protected boolean`
  `isSet`
  `protected static final StringManager`
  `sm`
  `protected int`
  `start`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `AbstractChunk()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected abstract int`
  `getBufferElement(int index)`
  `int`
  `getEnd()`
  `int`
  `getLength()`
  `int`
  `getLimit()`
  `protected int`
  `getLimitInternal()`
  `int`
  `getOffset()`
  `int`
  `getStart()`
  `int`
  `hash()`
  `int`
  `hashCode()`
  `int`
  `indexOf(String src, int srcOff, int srcLen, int myOff)`
  `boolean`
  `isNull()`
  `void`
  `recycle()`
  Resets the chunk to an uninitialized state.
  `void`
  `setEnd(int i)`
  `void`
  `setLimit(int limit)`
  Maximum amount of data in this buffer.
  `void`
  `setOffset(int off)`

  ### Methods inherited from class java.lang.Object

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

- ## Field Details

  - ### sm

    protected static final StringManager sm

  - ### ARRAY_MAX_SIZE

    public static final int ARRAY_MAX_SIZE
    See Also:
      - Constant Field Values

  - ### hasHashCode

    protected boolean hasHashCode

  - ### isSet

    protected boolean isSet

  - ### start

    protected int start

  - ### end

    protected int end

- ## Constructor Details

  - ### AbstractChunk

    public AbstractChunk()

- ## Method Details

  - ### setLimit

    public void setLimit(int limit)
    Maximum amount of data in this buffer. If -1 or not set, the buffer will grow to {`ARRAY_MAX_SIZE`. Can be smaller than the current buffer size ( which will not shrink ). When the limit is reached, the buffer will be flushed (if out is set) or throw exception.
    Parameters:
      `limit` - The new limit

  - ### getLimit

    public int getLimit()

  - ### getLimitInternal

    protected int getLimitInternal()

  - ### getStart

    public int getStart()
    Returns:
      the start position of the data in the buffer

  - ### getEnd

    public int getEnd()

  - ### setEnd

    public void setEnd(int i)

  - ### getOffset

    public int getOffset()

  - ### setOffset

    public void setOffset(int off)

  - ### getLength

    public int getLength()
    Returns:
      the length of the data in the buffer

  - ### isNull

    public boolean isNull()

  - ### indexOf

    public int indexOf(String src, int srcOff, int srcLen, int myOff)

  - ### recycle

    public void recycle()
    Resets the chunk to an uninitialized state.

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`

  - ### hash

    public int hash()

  - ### getBufferElement

    protected abstract int getBufferElement(int index)