|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.glassfish.grizzly.http.util.ByteChunk
public final class ByteChunk
This class is used to represent a chunk of bytes, and utilities to manipulate byte[]. The buffer can be modified and used for both input and output.
| Nested Class Summary | |
|---|---|
static interface |
ByteChunk.ByteInputChannel
|
static interface |
ByteChunk.ByteOutputChannel
|
| Field Summary | |
|---|---|
static Charset |
DEFAULT_CHARSET
Default encoding used to convert to strings. |
| Constructor Summary | |
|---|---|
ByteChunk()
Creates a new, uninitialized ByteChunk object. |
|
ByteChunk(int initial)
|
|
| Method Summary | |
|---|---|
void |
allocate(int initial,
int limit)
|
void |
append(byte b)
|
void |
append(byte[] src,
int off,
int len)
Add data to the buffer |
void |
append(ByteChunk src)
|
void |
append(char c)
|
static byte[] |
convertToBytes(String value)
Convert specified String to a byte array. |
void |
delete(int start,
int end)
|
boolean |
equals(byte[] b2,
int off2,
int len2)
|
boolean |
equals(ByteChunk bb)
|
boolean |
equals(char[] c2,
int off2,
int len2)
|
boolean |
equals(CharChunk cc)
|
boolean |
equals(Object o)
|
boolean |
equals(String s)
Compares the message bytes to the specified String object. |
boolean |
equalsIgnoreCase(byte[] b)
|
boolean |
equalsIgnoreCase(String s)
Compares the message bytes to the specified String object. |
boolean |
equalsIgnoreCaseLowerCase(byte[] cmpTo)
|
static boolean |
equalsIgnoreCaseLowerCase(byte[] buffer,
int start,
int end,
byte[] cmpTo)
Compares the buffer chunk to the specified byte array representing lower-case ASCII characters. |
static int |
findChar(byte[] buf,
int start,
int end,
char c)
Find a character, no side effects. |
static int |
findChars(byte[] buf,
int start,
int end,
byte[] c)
Find a character, no side effects. |
static int |
findNotChars(byte[] buf,
int start,
int end,
byte[] c)
Find the first character != c |
void |
flushBuffer()
|
byte[] |
getBuffer()
Returns the message bytes. |
byte[] |
getBytes()
Returns the message bytes. |
Charset |
getCharset()
|
ByteChunk |
getClone()
|
int |
getEnd()
|
int |
getInt()
|
int |
getLength()
Returns the length of the bytes. |
int |
getLimit()
|
long |
getLong()
|
int |
getOffset()
|
int |
getStart()
Returns the start offset of the bytes. |
int |
hash()
|
int |
hashCode()
|
int |
hashIgnoreCase()
|
static int |
indexOf(byte[] bytes,
int off,
int end,
char qq)
|
int |
indexOf(char c,
int starting)
Returns true if the message bytes starts with the specified string. |
int |
indexOf(String s,
int fromIdx)
|
int |
indexOf(String src,
int srcOff,
int srcLen,
int myOff)
|
boolean |
isNull()
|
protected void |
notifyDirectUpdate()
Notify the Chunk that its content is going to be changed directly |
void |
recycle()
Resets the message buff to an uninitialized state. |
void |
recycleAndReset()
|
void |
reset()
|
protected void |
resetStringCache()
|
void |
setByteInputChannel(ByteChunk.ByteInputChannel in)
When the buffer is empty, read the data from the input channel. |
void |
setByteOutputChannel(ByteChunk.ByteOutputChannel out)
When the buffer is full, write the data to the output channel. |
void |
setBytes(byte[] b,
int off,
int len)
Sets the message bytes to the specified sub-array of bytes. |
void |
setCharset(Charset charset)
|
void |
setEnd(int i)
|
void |
setLimit(int limit)
Maximum amount of data in this buffer. |
void |
setOffset(int off)
|
void |
setOptimizedWrite(boolean optimizedWrite)
|
void |
setStart(int start)
|
boolean |
startsWith(byte[] b2)
|
static boolean |
startsWith(byte[] buffer,
int start,
int end,
byte[] cmpTo)
|
boolean |
startsWith(String s)
Returns true if the message bytes starts with the specified string. |
boolean |
startsWith(String s,
int offset)
Returns true if the message bytes starts with the specified string. |
boolean |
startsWithIgnoreCase(String s,
int pos)
Returns true if the message bytes starts with the specified string. |
int |
substract()
|
int |
substract(byte[] src,
int off,
int len)
|
int |
substract(ByteChunk src)
|
String |
toString()
|
String |
toString(Charset charset)
|
String |
toString(int start,
int end)
|
String |
toStringInternal()
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static Charset DEFAULT_CHARSET
| Constructor Detail |
|---|
public ByteChunk()
public ByteChunk(int initial)
| Method Detail |
|---|
public ByteChunk getClone()
public boolean isNull()
public void recycle()
public void recycleAndReset()
public void reset()
protected final void resetStringCache()
public void allocate(int initial,
int limit)
public void setBytes(byte[] b,
int off,
int len)
b - the ascii bytesoff - the start offset of the byteslen - the length of the bytespublic void setOptimizedWrite(boolean optimizedWrite)
public Charset getCharset()
public void setCharset(Charset charset)
public byte[] getBytes()
public byte[] getBuffer()
public int getStart()
getStart in interface Chunkpublic int getOffset()
public void setStart(int start)
setStart in interface Chunkpublic void setOffset(int off)
public int getLength()
getLength in interface Chunkpublic void setLimit(int limit)
public int getLimit()
public void setByteInputChannel(ByteChunk.ByteInputChannel in)
public void setByteOutputChannel(ByteChunk.ByteOutputChannel out)
public int getEnd()
getEnd in interface Chunkpublic void setEnd(int i)
setEnd in interface Chunkprotected void notifyDirectUpdate()
public int indexOf(String s,
int fromIdx)
indexOf in interface Chunk
public void delete(int start,
int end)
delete in interface Chunk
public void append(char c)
throws IOException
IOException
public void append(byte b)
throws IOException
IOException
public void append(ByteChunk src)
throws IOException
IOException
public void append(byte[] src,
int off,
int len)
throws IOException
IOException
public int substract()
throws IOException
IOException
public int substract(ByteChunk src)
throws IOException
IOException
public int substract(byte[] src,
int off,
int len)
throws IOException
IOException
public void flushBuffer()
throws IOException
IOExceptionpublic String toString()
toString in class Object
public String toString(int start,
int end)
toString in interface Chunkpublic String toString(Charset charset)
public String toStringInternal()
public int getInt()
public long getLong()
public int hashCode()
hashCode in class Objectpublic boolean equals(Object o)
equals in class Objectpublic boolean equals(String s)
s - the String to compare
public boolean equalsIgnoreCase(String s)
s - the String to compare
public boolean equalsIgnoreCase(byte[] b)
public boolean equalsIgnoreCaseLowerCase(byte[] cmpTo)
public boolean equals(ByteChunk bb)
public boolean equals(byte[] b2,
int off2,
int len2)
public boolean equals(CharChunk cc)
public boolean equals(char[] c2,
int off2,
int len2)
public boolean startsWith(String s)
s - the string
public boolean startsWith(String s,
int offset)
s - the stringoffset - The positionpublic boolean startsWith(byte[] b2)
public boolean startsWithIgnoreCase(String s,
int pos)
s - the stringpos - The position
public int indexOf(String src,
int srcOff,
int srcLen,
int myOff)
public int hash()
public int hashIgnoreCase()
public static boolean equalsIgnoreCaseLowerCase(byte[] buffer,
int start,
int end,
byte[] cmpTo)
buffer - the byte[] to comparestart - buffer startend - buffer endcmpTo - byte[] to compare against
public static boolean startsWith(byte[] buffer,
int start,
int end,
byte[] cmpTo)
public int indexOf(char c,
int starting)
indexOf in interface Chunkc - the characterstarting - The start position
public static int indexOf(byte[] bytes,
int off,
int end,
char qq)
public static int findChar(byte[] buf,
int start,
int end,
char c)
public static int findChars(byte[] buf,
int start,
int end,
byte[] c)
public static int findNotChars(byte[] buf,
int start,
int end,
byte[] c)
public static byte[] convertToBytes(String value)
value - to convert to byte array
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||