Package org.apache.tomcat.util.buf
Class AbstractChunk
java.lang.Object
org.apache.tomcat.util.buf.AbstractChunk
- All Implemented Interfaces:
Serializable
,Cloneable
Base class for the *Chunk implementation to reduce duplication.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
protected int
protected boolean
protected boolean
protected static final StringManager
protected int
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract int
getBufferElement
(int index) int
getEnd()
int
int
getLimit()
protected int
int
Deprecated.Unused.int
getStart()
int
hash()
int
hashCode()
int
Return the index of the first occurrence of the subsequence of the given String, or -1 if it is not found.boolean
isNull()
void
recycle()
Resets the chunk to an uninitialized state.void
setEnd
(int end) Set the end position of the data in the buffer.void
setLimit
(int limit) Maximum amount of data in this buffer.void
setOffset
(int off) Deprecated.Unused.void
setStart
(int start) Set the start position of the data in the buffer.
-
Field Details
-
sm
-
ARRAY_MAX_SIZE
public static final int ARRAY_MAX_SIZE- See Also:
-
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()- Returns:
- the maximum amount of data in the buffer, and -1 if it has not been set
-
getLimitInternal
protected int getLimitInternal() -
getStart
public int getStart()- Returns:
- the start position of the data in the buffer
-
setStart
public void setStart(int start) Set the start position of the data in the buffer.- Parameters:
start
- the new start position
-
getEnd
public int getEnd()- Returns:
- the end position of the data in the buffer
-
setEnd
public void setEnd(int end) Set the end position of the data in the buffer.- Parameters:
end
- the new end position
-
getOffset
Deprecated.Unused. This method will be removed in Tomcat 12.- Returns:
- start
-
setOffset
Deprecated.Unused. This method will be removed in Tomcat 12.Set start.- Parameters:
off
- the new start
-
getLength
public int getLength()- Returns:
- the length of the data in the buffer
-
isNull
public boolean isNull()- Returns:
true
if the buffer contains no data
-
indexOf
Return the index of the first occurrence of the subsequence of the given String, or -1 if it is not found.- Parameters:
src
- the String to look forsrcStart
- the subsequence start in the StringsrcLen
- the subsequence length in the StringmyOffset
- the index on which to start the search in the buffer- Returns:
- the position of the first character of the first occurrence of the subsequence in the buffer, or -1 if not found
-
recycle
public void recycle()Resets the chunk to an uninitialized state. -
hashCode
public int hashCode() -
hash
public int hash()- Returns:
- the hash code for this buffer
-
getBufferElement
protected abstract int getBufferElement(int index) - Parameters:
index
- the element location in the buffer- Returns:
- the element
-