public final class ByteChunk extends Object implements Cloneable, Serializable
Modifier and Type | Class and Description |
---|---|
static interface |
ByteChunk.ByteInputChannel
Input interface, used when the buffer is empty
Same as java.nio.channel.ReadableByteChannel
|
static interface |
ByteChunk.ByteOutputChannel
Same as java.nio.channel.WrittableByteChannel.
|
Modifier and Type | Field and Description |
---|---|
static Charset |
DEFAULT_CHARSET
Default encoding used to convert to strings.
|
Constructor and Description |
---|
ByteChunk()
Creates a new, uninitialized ByteChunk object.
|
ByteChunk(int initial) |
Modifier and Type | Method and Description |
---|---|
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)
Deprecated.
Unused. Will be removed in Tomcat 8.0.x onwards.
|
static byte[] |
convertToBytes(String value)
Convert specified String to a byte array.
|
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(String s)
Compares the message bytes to the specified String object.
|
boolean |
equalsIgnoreCase(String s)
Compares the message bytes to the specified String object.
|
static int |
findByte(byte[] bytes,
int start,
int end,
byte b)
Returns the first instance of the given byte in the byte array between
the specified start and end.
|
static int |
findBytes(byte[] bytes,
int start,
int end,
byte[] b)
Returns the first instance of any of the given bytes in the byte array
between the specified start and end.
|
static int |
findNotBytes(byte[] bytes,
int start,
int end,
byte[] b)
Deprecated.
Unused. Will be removed in Tomcat 8.0.x onwards.
|
void |
flushBuffer()
Send the buffer to the sink.
|
byte[] |
getBuffer()
Returns the message bytes.
|
byte[] |
getBytes()
Returns the message bytes.
|
Charset |
getCharset() |
ByteChunk |
getClone()
Deprecated.
Unused. Will be removed in Tomcat 8.0.x onwards.
|
int |
getEnd() |
int |
getInt()
Deprecated.
Unused. Will be removed in Tomcat 8.0.x onwards.
|
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 |
hashIgnoreCase()
Deprecated.
Unused. Will be removed in Tomcat 8.0.x onwards.
|
static int |
indexOf(byte[] bytes,
int start,
int end,
char c)
Returns the first instance of the given character in the given byte array
between the specified start and end.
|
int |
indexOf(char c,
int starting)
Returns the first instance of the given character in this ByteChunk
starting at the specified byte.
|
int |
indexOf(String src,
int srcOff,
int srcLen,
int myOff) |
boolean |
isNull() |
void |
makeSpace(int count)
Make space for len chars.
|
void |
recycle()
Resets the message buff to an uninitialized state.
|
void |
reset() |
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 subarray 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)
Deprecated.
Unused. Will be removed in Tomcat 8.0.x onwards.
|
boolean |
startsWith(byte[] b2)
Deprecated.
Unused. Will be removed in Tomcat 8.0.x onwards.
|
boolean |
startsWith(String s)
Deprecated.
Unused. Will be removed in Tomcat 8.0.x onwards.
|
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)
Deprecated.
Unused. Will be removed in Tomcat 8.0.x onwards.
|
byte |
substractB() |
String |
toString() |
String |
toStringInternal() |
public static final Charset DEFAULT_CHARSET
public ByteChunk()
public ByteChunk(int initial)
@Deprecated public ByteChunk getClone()
public boolean isNull()
public void recycle()
public void reset()
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 bytes@Deprecated public void setOptimizedWrite(boolean optimizedWrite)
public void setCharset(Charset charset)
public Charset getCharset()
public byte[] getBytes()
public byte[] getBuffer()
public int getStart()
public int getOffset()
public void setOffset(int off)
public int getLength()
public void setLimit(int limit)
public int getLimit()
public void setByteInputChannel(ByteChunk.ByteInputChannel in)
public void setByteOutputChannel(ByteChunk.ByteOutputChannel out)
public int getEnd()
public void setEnd(int i)
@Deprecated public void append(char c) throws IOException
c
- 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
@Deprecated public int substract(ByteChunk src) throws IOException
IOException
public byte substractB() throws IOException
IOException
public int substract(byte[] src, int off, int len) throws IOException
IOException
public void flushBuffer() throws IOException
IOException
public void makeSpace(int count)
public String toStringInternal()
@Deprecated public int getInt()
public long getLong()
public boolean equals(String s)
s
- the String to comparepublic boolean equalsIgnoreCase(String s)
s
- the String to comparepublic 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)
@Deprecated public boolean startsWith(String s)
s
- the string@Deprecated public boolean startsWith(byte[] b2)
public boolean startsWithIgnoreCase(String s, int pos)
s
- the stringpos
- The positionpublic int indexOf(String src, int srcOff, int srcLen, int myOff)
public int hash()
@Deprecated public int hashIgnoreCase()
public int indexOf(char c, int starting)
c
- The characterstarting
- The start positionpublic static int indexOf(byte[] bytes, int start, int end, char c)
bytes
- The byte array to searchstart
- The point to start searching from in the byte arrayend
- The point to stop searching in the byte arrayc
- The character to search forpublic static int findByte(byte[] bytes, int start, int end, byte b)
bytes
- The byte array to searchstart
- The point to start searching from in the byte arrayend
- The point to stop searching in the byte arrayb
- The byte to search forpublic static int findBytes(byte[] bytes, int start, int end, byte[] b)
bytes
- The byte array to searchstart
- The point to start searching from in the byte arrayend
- The point to stop searching in the byte arrayb
- The array of bytes to search for@Deprecated public static int findNotBytes(byte[] bytes, int start, int end, byte[] b)
bytes
- The byte array to searchstart
- The point to start searching from in the byte arrayend
- The point to stop searching in the byte arrayb
- The list of bytes to search forpublic static final byte[] convertToBytes(String value)
value
- to convert to byte arrayCopyright © 2000–2020 Apache Software Foundation. All rights reserved.