org.apache.catalina.tribes.io
public class XByteBuffer extends Object
Version: $Revision: 467173 $, $Date: 2006-10-24 01:12:17 +0200 (Tue, 24 Oct 2006) $
Field Summary | |
---|---|
protected byte[] | buf
Variable to hold the data |
protected int | bufSize
Current length of data in the buffer |
protected boolean | discard
Flag for discarding invalid packages
If this flag is set to true, and append(byte[],...) is called,
the data added will be inspected, and if it doesn't start with
START_DATA it will be thrown away.
|
static byte[] | END_DATA
This is the package footer, 7 bytes (TLF2003) |
static int | invokecount |
static Log | log |
static byte[] | START_DATA
This is a package header, 7 bytes (FLT2002) |
Constructor Summary | |
---|---|
XByteBuffer(int size, boolean discard)
Constructs a new XByteBuffer | |
XByteBuffer(byte[] data, boolean discard) | |
XByteBuffer(byte[] data, int size, boolean discard) |
Method Summary | |
---|---|
boolean | append(ByteBuffer b, int len)
Appends the data to the buffer. |
boolean | append(byte i) |
boolean | append(boolean i) |
boolean | append(long i) |
boolean | append(int i) |
boolean | append(byte[] b, int off, int len) |
void | clear()
Resets the buffer |
int | countPackages()
Internal mechanism to make a check if a complete package exists
within the buffer |
int | countPackages(boolean first) |
static byte[] | createDataPackage(ChannelData cdata)
Creates a complete data package |
static byte[] | createDataPackage(byte[] data, int doff, int dlength, byte[] buffer, int bufoff) |
static byte[] | createDataPackage(byte[] data) |
static Serializable | deserialize(byte[] data) |
static Serializable | deserialize(byte[] data, int offset, int length) |
static Serializable | deserialize(byte[] data, int offset, int length, ClassLoader[] cls) |
boolean | doesPackageExist()
Method to check if a package exists in this byte buffer. |
void | expand(int newcount) |
XByteBuffer | extractDataPackage(boolean clearFromBuffer)
Extracts the message bytes from a package.
|
ChannelData | extractPackage(boolean clearFromBuffer) |
static int | firstIndexOf(byte[] src, int srcOff, byte[] find)
Similar to a String.IndexOf, but uses pure bytes |
byte[] | getBytes()
Returns the bytes in the buffer, in its exact length |
byte[] | getBytesDirect() |
int | getCapacity() |
static int | getDataPackageLength(int datalength) |
boolean | getDiscard() |
int | getLength() |
void | reset() |
static byte[] | serialize(Serializable msg)
Serializes a message into cluster data |
void | setDiscard(boolean discard) |
void | setLength(int size) |
static boolean | toBoolean(byte[] b, int offset) |
static byte[] | toBytes(boolean bool)
Converts an integer to four bytes |
static byte[] | toBytes(boolean bool, byte[] data, int offset) |
static byte[] | toBytes(int n)
Converts an integer to four bytes |
static byte[] | toBytes(int n, byte[] b, int offset) |
static byte[] | toBytes(long n)
Converts an long to eight bytes |
static byte[] | toBytes(long n, byte[] b, int offset) |
static int | toInt(byte[] b, int off)
Convert four bytes to an int |
static long | toLong(byte[] b, int off)
Convert eight bytes to a long |
void | trim(int length) |
START_DATA
it will be thrown away.
Parameters: size - the initial size of the byte buffer
UNKNOWN: use a pool of byte[] for performance
Parameters: b - bytes to be appended off - the offset to extract data from len - the number of bytes to append.
Returns: true if the data was appended correctly. Returns false if the package is incorrect, ie missing header or something, or the length of data is 0
Returns: - true if a complete package (header,compress,size,data,footer) exists within the buffer
Parameters: indata - the message data to be contained within the package compressed - compression flag for the indata buffer
Returns: - a full package (header,size,data,footer)
Returns: - true if a complete package (header,options,size,data,footer) exists within the buffer
Parameters: clearFromBuffer - if true, the package will be removed from the byte buffer
Returns: - returns the actual message bytes (header, compress,size and footer not included).
Parameters: src - the source bytes to be searched srcOff - offset on the source buffer find - the string to be found within src
Returns: - the index of the first matching byte. -1 if the find array is not found
Parameters: msg ClusterMessage compress boolean
Returns:
Throws: IOException
Parameters:
Returns: use
Deprecated: use toBytes(boolean,byte[],int)
Converts an integer to four bytesParameters: n - the integer
Returns: - four bytes in an array
Deprecated: use toBytes(int,byte[],int)
Converts an integer to four bytesParameters: n - the integer
Returns: - four bytes in an array
Deprecated: use toBytes(long,byte[],int)
Converts an long to eight bytesParameters: n - the long
Returns: - eight bytes in an array
Parameters: b - the byte array containing the four bytes off - the offset
Returns: the integer value constructed from the four bytes
Throws: java.lang.ArrayIndexOutOfBoundsException
Parameters: b - the byte array containing the four bytes off - the offset
Returns: the long value constructed from the eight bytes
Throws: java.lang.ArrayIndexOutOfBoundsException