public class XByteBuffer extends Object implements Serializable
| Modifier and Type | Field and Description | 
|---|---|
| protected byte[] | bufVariable to hold the data | 
| protected int | bufSizeCurrent length of data in the buffer | 
| protected boolean | discardFlag 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_DATAit will be thrown away. | 
| Constructor and Description | 
|---|
| XByteBuffer(byte[] data,
           boolean discard) | 
| XByteBuffer(byte[] data,
           int size,
           boolean discard) | 
| XByteBuffer(int size,
           boolean discard)Constructs a new XByteBuffer. | 
| Modifier and Type | Method and Description | 
|---|---|
| boolean | append(boolean i) | 
| boolean | append(byte i) | 
| boolean | append(byte[] b,
      int off,
      int len) | 
| boolean | append(ByteBuffer b,
      int len)Appends the data to the buffer. | 
| boolean | append(int i) | 
| boolean | append(long i) | 
| 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(byte[] data) | 
| static byte[] | createDataPackage(byte[] data,
                 int doff,
                 int dlength,
                 byte[] buffer,
                 int bufoff) | 
| static byte[] | createDataPackage(ChannelData cdata)Creates a complete data package | 
| 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() | 
| 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)Converts a byte array entry to boolean. | 
| static byte[] | toBytes(boolean bool)Deprecated. 
 use toBytes(boolean,byte[],int) | 
| static byte[] | toBytes(boolean bool,
       byte[] data,
       int offset) | 
| static byte[] | toBytes(int n)Deprecated. 
 use toBytes(int,byte[],int) | 
| static byte[] | toBytes(int n,
       byte[] b,
       int offset) | 
| static byte[] | toBytes(long n)Deprecated. 
 use toBytes(long,byte[],int) | 
| 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) | 
protected byte[] buf
protected int bufSize
protected boolean discard
START_DATA it will be thrown away.public XByteBuffer(int size,
           boolean discard)
size - the initial size of the byte bufferdiscard - Flag for discarding invalid packagespublic XByteBuffer(byte[] data,
           boolean discard)
public XByteBuffer(byte[] data,
           int size,
           boolean discard)
public int getLength()
public void setLength(int size)
public void trim(int length)
public void reset()
public byte[] getBytesDirect()
public byte[] getBytes()
public void clear()
public boolean append(ByteBuffer b, int len)
b - - bytes to be appendedlen - - the number of bytes to append.public boolean append(byte i)
public boolean append(boolean i)
public boolean append(long i)
public boolean append(int i)
public boolean append(byte[] b,
             int off,
             int len)
public void expand(int newcount)
public int getCapacity()
public int countPackages()
public int countPackages(boolean first)
public boolean doesPackageExist()
public XByteBuffer extractDataPackage(boolean clearFromBuffer)
clearFromBuffer - - if true, the package will be removed from the byte bufferpublic ChannelData extractPackage(boolean clearFromBuffer) throws IOException
IOExceptionpublic static byte[] createDataPackage(ChannelData cdata)
cdata - - the message data to be contained within the packagepublic static byte[] createDataPackage(byte[] data,
                       int doff,
                       int dlength,
                       byte[] buffer,
                       int bufoff)
public static int getDataPackageLength(int datalength)
public static byte[] createDataPackage(byte[] data)
public static int toInt(byte[] b,
        int off)
b - - the byte array containing the four bytesoff - - the offsetpublic static long toLong(byte[] b,
          int off)
b - - the byte array containing the four bytesoff - - the offset@Deprecated public static byte[] toBytes(boolean bool)
bool - - the integerpublic static byte[] toBytes(boolean bool,
             byte[] data,
             int offset)
public static boolean toBoolean(byte[] b,
                int offset)
b - byte arrayoffset - within byte array@Deprecated public static byte[] toBytes(int n)
n - - the integerpublic static byte[] toBytes(int n,
             byte[] b,
             int offset)
@Deprecated public static byte[] toBytes(long n)
n - - the longpublic static byte[] toBytes(long n,
             byte[] b,
             int offset)
public static int firstIndexOf(byte[] src,
               int srcOff,
               byte[] find)
src - - the source bytes to be searchedsrcOff - - offset on the source bufferfind - - the string to be found within srcpublic static Serializable deserialize(byte[] data) throws IOException, ClassNotFoundException, ClassCastException
public static Serializable deserialize(byte[] data, int offset, int length) throws IOException, ClassNotFoundException, ClassCastException
public static Serializable deserialize(byte[] data, int offset, int length, ClassLoader[] cls) throws IOException, ClassNotFoundException, ClassCastException
public static byte[] serialize(Serializable msg) throws IOException
msg - ClusterMessageIOException - Serialization errorpublic void setDiscard(boolean discard)
public boolean getDiscard()
Copyright © 2000-2020 Apache Software Foundation. All Rights Reserved.