Package org.glassfish.grizzly.http.util
Class DataChunk
- java.lang.Object
-
- org.glassfish.grizzly.http.util.DataChunk
-
- All Implemented Interfaces:
Chunk
- Direct Known Subclasses:
CacheableDataChunk
public class DataChunk extends Object implements Chunk
Bufferchunk representation. Helps HTTP module to avoid redundant String creation.- Author:
- Alexey Stashok
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDataChunk.Type
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddelete(int from, int to)voidduplicate(DataChunk src)Copy the src into this DataChunk, allocating more space if neededbooleanequals(byte[] bytes)Compares the message data to the specified byte[].booleanequals(byte[] bytes, int start, int len)Compares the message data to the specified byte[].booleanequals(Object object)Compares this DataChunk and the passed object.booleanequals(String s)Compares the message bytes to the specified String object.booleanequals(BufferChunk bufferChunkToCheck)Compares the message data to the specified BufferChunk.booleanequals(ByteChunk byteChunkToCheck)Compares the message data to the specified ByteChunk.booleanequals(CharChunk charChunkToCheck)Compares the message data to the specified CharChunk.booleanequalsIgnoreCase(byte[] bytes)Compares the message data to the specified byte[] ignoring case considerations.booleanequalsIgnoreCase(byte[] bytes, int start, int len)Compares the message data to the specified byte[] ignoring case considerations.booleanequalsIgnoreCase(Object object)Compares this DataChunk and the passed object ignoring case considerations.booleanequalsIgnoreCase(String s)Compares the message bytes to the specified String object ignoring case considerations.booleanequalsIgnoreCase(BufferChunk bufferChunkToCheck)Compares the message data to the specified BufferChunk ignoring case considerations.booleanequalsIgnoreCase(ByteChunk byteChunkToCheck)Compares the message data to the specified ByteChunk ignoring case considerations.booleanequalsIgnoreCase(CharChunk charChunkToCheck)Compares the message data to the specified CharChunk ignoring case considerations.booleanequalsIgnoreCaseLowerCase(byte[] b)Compares the data chunk to the specified byte array representing lower-case ASCII characters.BufferChunkgetBufferChunk()ByteChunkgetByteChunk()CharChunkgetCharChunk()intgetEnd()Returns the DataChunk end position.intgetLength()Returns the DataChunk length.intgetStart()Returns the DataChunk start position.DataChunk.TypegetType()inthashCode()Returns DataChunk hash code.intindexOf(char c, int fromIndex)Returns true if the message bytes starts with the specified string.intindexOf(String s, int fromIndex)Returns true if the message bytes starts with the specified string.booleanisNull()static DataChunknewInstance()static DataChunknewInstance(ByteChunk byteChunk, BufferChunk bufferChunk, CharChunk charChunk, String stringValue)voidnotifyDirectUpdate()Notify the Chunk that its content is going to be changed directlyvoidrecycle()protected voidreset()protected voidresetBuffer()protected voidresetByteChunk()protected voidresetCharChunk()protected voidresetString()voidset(DataChunk value)voidset(DataChunk value, int start, int end)voidsetBuffer(org.glassfish.grizzly.Buffer buffer)voidsetBuffer(org.glassfish.grizzly.Buffer buffer, int position, int limit)voidsetBytes(byte[] bytes)voidsetBytes(byte[] bytes, int position, int limit)voidsetChars(char[] chars, int position, int limit)voidsetEnd(int end)Sets the DataChunk end position.voidsetStart(int start)Sets the DataChunk start position.voidsetString(String string)booleanstartsWith(String s, int pos)Returnstrueif theDataChunkstarts with the specified string.booleanstartsWithIgnoreCase(String s, int pos)Returnstrueif theDataChunkstarts with the specified string.voidtoChars(Charset charset)DataChunktoImmutable()StringtoString()StringtoString(int start, int end)StringtoString(Charset charset)voidtrimLeft()
-
-
-
Constructor Detail
-
DataChunk
protected DataChunk()
-
DataChunk
protected DataChunk(ByteChunk byteChunk, BufferChunk bufferChunk, CharChunk charChunk, String stringValue)
-
-
Method Detail
-
newInstance
public static DataChunk newInstance()
-
newInstance
public static DataChunk newInstance(ByteChunk byteChunk, BufferChunk bufferChunk, CharChunk charChunk, String stringValue)
-
toImmutable
public DataChunk toImmutable()
-
getType
public DataChunk.Type getType()
-
set
public void set(DataChunk value)
-
set
public void set(DataChunk value, int start, int end)
-
notifyDirectUpdate
public void notifyDirectUpdate()
Notify the Chunk that its content is going to be changed directly
-
getBufferChunk
public BufferChunk getBufferChunk()
-
setBuffer
public void setBuffer(org.glassfish.grizzly.Buffer buffer, int position, int limit)
-
setBuffer
public void setBuffer(org.glassfish.grizzly.Buffer buffer)
-
getCharChunk
public CharChunk getCharChunk()
-
setChars
public void setChars(char[] chars, int position, int limit)
-
getByteChunk
public ByteChunk getByteChunk()
-
setBytes
public void setBytes(byte[] bytes)
-
setBytes
public void setBytes(byte[] bytes, int position, int limit)
-
setString
public void setString(String string)
-
trimLeft
public void trimLeft()
-
duplicate
public void duplicate(DataChunk src)
Copy the src into this DataChunk, allocating more space if needed
-
toChars
public void toChars(Charset charset) throws CharConversionException
- Throws:
CharConversionException
-
getLength
public int getLength()
Returns the DataChunk length.
-
getStart
public int getStart()
Returns the DataChunk start position.
-
setStart
public void setStart(int start)
Sets the DataChunk start position.
-
getEnd
public int getEnd()
Returns the DataChunk end position.
-
setEnd
public void setEnd(int end)
Sets the DataChunk end position.
-
indexOf
public final int indexOf(char c, int fromIndex)Returns true if the message bytes starts with the specified string.
-
indexOf
public final int indexOf(String s, int fromIndex)
Returns true if the message bytes starts with the specified string.
-
equals
public boolean equals(Object object)
Compares this DataChunk and the passed object.
-
equals
public boolean equals(String s)
Compares the message bytes to the specified String object.- Parameters:
s- the String to compare- Returns:
- true if the comparison succeeded, false otherwise
-
equals
public boolean equals(ByteChunk byteChunkToCheck)
Compares the message data to the specified ByteChunk.- Parameters:
byteChunkToCheck- the ByteChunk to compare- Returns:
- true if the comparison succeeded, false otherwise
-
equals
public boolean equals(BufferChunk bufferChunkToCheck)
Compares the message data to the specified BufferChunk.- Parameters:
bufferChunkToCheck- the BufferChunk to compare- Returns:
- true if the comparison succeeded, false otherwise
-
equals
public boolean equals(CharChunk charChunkToCheck)
Compares the message data to the specified CharChunk.- Parameters:
charChunkToCheck- the CharChunk to compare- Returns:
- true if the comparison succeeded, false otherwise
-
equals
public boolean equals(byte[] bytes)
Compares the message data to the specified byte[].- Parameters:
bytes- the byte[] to compare- Returns:
- true if the comparison succeeded, false otherwise
-
equals
public boolean equals(byte[] bytes, int start, int len)Compares the message data to the specified byte[].- Parameters:
bytes- the byte[] to compare- Returns:
- true if the comparison succeeded, false otherwise
-
equalsIgnoreCase
public boolean equalsIgnoreCase(Object object)
Compares this DataChunk and the passed object ignoring case considerations.- Parameters:
object- the Object to compare- Returns:
- true if the passed object represents another DataChunk and its content is equal to this DataChunk's content ignoring case considerations.
-
equalsIgnoreCase
public boolean equalsIgnoreCase(String s)
Compares the message bytes to the specified String object ignoring case considerations.- Parameters:
s- the String to compare- Returns:
- true if the comparison succeeded, false otherwise
-
equalsIgnoreCase
public boolean equalsIgnoreCase(ByteChunk byteChunkToCheck)
Compares the message data to the specified ByteChunk ignoring case considerations.- Parameters:
byteChunkToCheck- the ByteChunk to compare- Returns:
- true if the comparison succeeded, false otherwise
-
equalsIgnoreCase
public boolean equalsIgnoreCase(BufferChunk bufferChunkToCheck)
Compares the message data to the specified BufferChunk ignoring case considerations.- Parameters:
bufferChunkToCheck- the BufferChunk to compare- Returns:
- true if the comparison succeeded, false otherwise
-
equalsIgnoreCase
public boolean equalsIgnoreCase(CharChunk charChunkToCheck)
Compares the message data to the specified CharChunk ignoring case considerations.- Parameters:
charChunkToCheck- the CharChunk to compare- Returns:
- true if the comparison succeeded, false otherwise
-
equalsIgnoreCase
public boolean equalsIgnoreCase(byte[] bytes)
Compares the message data to the specified byte[] ignoring case considerations.- Parameters:
bytes- the byte[] to compare- Returns:
- true if the comparison succeeded, false otherwise
-
equalsIgnoreCase
public boolean equalsIgnoreCase(byte[] bytes, int start, int len)Compares the message data to the specified byte[] ignoring case considerations.- Parameters:
bytes- the byte[] to compare- Returns:
- true if the comparison succeeded, false otherwise
-
hashCode
public int hashCode()
Returns DataChunk hash code.
-
equalsIgnoreCaseLowerCase
public final boolean equalsIgnoreCaseLowerCase(byte[] b)
Compares the data chunk to the specified byte array representing lower-case ASCII characters.- Parameters:
b- thebyte[]to compare- Returns:
- true if the comparison succeeded, false otherwise
- Since:
- 2.1.2
-
startsWith
public final boolean startsWith(String s, int pos)
Returnstrueif theDataChunkstarts with the specified string.- Parameters:
s- the stringpos- The start position- Returns:
trueif theDataChunkstarts with the specified string.
-
startsWithIgnoreCase
public final boolean startsWithIgnoreCase(String s, int pos)
Returnstrueif theDataChunkstarts with the specified string.- Parameters:
s- the stringpos- The start position- Returns:
trueif the DataChunk starts with the specified string.
-
isNull
public final boolean isNull()
-
resetBuffer
protected void resetBuffer()
-
resetCharChunk
protected void resetCharChunk()
-
resetByteChunk
protected void resetByteChunk()
-
resetString
protected void resetString()
-
reset
protected void reset()
-
recycle
public void recycle()
-
-