public final class ByteChunk
extends java.lang.Object
implements java.lang.Cloneable, java.io.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.WritableByteChannel.
|
| Modifier and Type | Field and Description |
|---|---|
static java.nio.charset.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(java.nio.ByteBuffer from)
Add data to the buffer.
|
void |
append(ByteChunk src) |
java.lang.Object |
clone() |
static byte[] |
convertToBytes(java.lang.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(java.lang.Object obj) |
boolean |
equals(java.lang.String s)
Compares the message bytes to the specified String object.
|
boolean |
equalsIgnoreCase(java.lang.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.
|
void |
flushBuffer()
Send the buffer to the sink.
|
byte[] |
getBuffer() |
byte[] |
getBytes() |
java.nio.charset.Charset |
getCharset() |
int |
getEnd() |
int |
getLength() |
int |
getLimit() |
long |
getLong() |
int |
getOffset() |
int |
getStart() |
int |
hash() |
int |
hashCode() |
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(java.lang.String src,
int srcOff,
int srcLen,
int myOff) |
boolean |
isNull() |
void |
makeSpace(int count)
Make space for len bytes.
|
void |
recycle()
Resets the message buff to an uninitialized state.
|
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(java.nio.charset.Charset charset) |
void |
setEnd(int i) |
void |
setLimit(int limit)
Maximum amount of data in this buffer.
|
void |
setOffset(int off) |
boolean |
startsWithIgnoreCase(java.lang.String s,
int pos)
Returns true if the message bytes starts with the specified string.
|
int |
substract() |
int |
substract(byte[] dest,
int off,
int len) |
int |
substract(java.nio.ByteBuffer to)
Transfers bytes from the buffer to the specified ByteBuffer.
|
byte |
substractB() |
java.lang.String |
toString() |
java.lang.String |
toStringInternal() |
public static final java.nio.charset.Charset DEFAULT_CHARSET
public ByteChunk()
public ByteChunk(int initial)
public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
clone in class java.lang.Objectjava.lang.CloneNotSupportedExceptionpublic boolean isNull()
public void recycle()
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 setCharset(java.nio.charset.Charset charset)
public java.nio.charset.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)
limit - The new limitpublic int getLimit()
public void setByteInputChannel(ByteChunk.ByteInputChannel in)
in - The input channelpublic void setByteOutputChannel(ByteChunk.ByteOutputChannel out)
out - The output channelpublic int getEnd()
public void setEnd(int i)
public void append(byte b)
throws java.io.IOException
java.io.IOExceptionpublic void append(ByteChunk src) throws java.io.IOException
java.io.IOExceptionpublic void append(byte[] src,
int off,
int len)
throws java.io.IOException
src - Bytes arrayoff - Offsetlen - Lengthjava.io.IOException - Writing overflow data to the output channel failedpublic void append(java.nio.ByteBuffer from)
throws java.io.IOException
from - the ByteBuffer with the datajava.io.IOException - Writing overflow data to the output channel failedpublic int substract()
throws java.io.IOException
java.io.IOExceptionpublic byte substractB()
throws java.io.IOException
java.io.IOExceptionpublic int substract(byte[] dest,
int off,
int len)
throws java.io.IOException
java.io.IOExceptionpublic int substract(java.nio.ByteBuffer to)
throws java.io.IOException
to - the ByteBuffer into which bytes are to be written.java.io.IOException - if an input or output exception has occurredpublic void flushBuffer()
throws java.io.IOException
java.io.IOException - Writing overflow data to the output channel failedpublic void makeSpace(int count)
count - The sizepublic java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String toStringInternal()
public long getLong()
public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic boolean equals(java.lang.String s)
s - the String to comparepublic boolean equalsIgnoreCase(java.lang.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)
public boolean startsWithIgnoreCase(java.lang.String s,
int pos)
s - the stringpos - The positiontrue if the start matchespublic int indexOf(java.lang.String src,
int srcOff,
int srcLen,
int myOff)
public int hashCode()
hashCode in class java.lang.Objectpublic int hash()
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 forpublic static final byte[] convertToBytes(java.lang.String value)
value - to convert to byte arrayCopyright © 2000-2018 Apache Software Foundation. All Rights Reserved.