Package com.neovisionaries.ws.client
Class ByteArray
- java.lang.Object
-
- com.neovisionaries.ws.client.ByteArray
-
class ByteArray extends java.lang.ObjectExpandable byte array with byte-basis and bit-basis operations.
-
-
Field Summary
Fields Modifier and Type Field Description private static intADDITIONAL_BUFFER_SIZEprivate java.nio.ByteBuffermBufferprivate intmLength
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()voidclearBit(int bitIndex)private voidexpandBuffer(int newBufferSize)Expand the size of the internal buffer.byteget(int index)Get a byte at the index.booleangetBit(int bitIndex)intgetBits(int bitIndex, int nBits)intgetHuffmanBits(int bitIndex, int nBits)intlength()The length of the data.voidput(byte[] source)Add data at the current position.voidput(byte[] source, int index, int length)Add data at the current position.voidput(int data)Add a byte at the current position.voidput(ByteArray source, int index, int length)Add data at the current position.booleanreadBit(int[] bitIndex)intreadBits(int[] bitIndex, int nBits)voidsetBit(int bitIndex, boolean bit)voidshrink(int size)byte[]toBytes()Convert to a byte array (byte[]).byte[]toBytes(int beginIndex)byte[]toBytes(int beginIndex, int endIndex)
-
-
-
Field Detail
-
ADDITIONAL_BUFFER_SIZE
private static final int ADDITIONAL_BUFFER_SIZE
- See Also:
- Constant Field Values
-
mBuffer
private java.nio.ByteBuffer mBuffer
-
mLength
private int mLength
-
-
Constructor Detail
-
ByteArray
public ByteArray(int capacity)
Constructor with initial capacity.- Parameters:
capacity- Initial capacity for the internal buffer.
-
ByteArray
public ByteArray(byte[] data)
Constructor with initial data. The length of the data is used as the initial capacity of the internal buffer.- Parameters:
data- Initial data.
-
-
Method Detail
-
length
public int length()
The length of the data.
-
get
public byte get(int index) throws java.lang.IndexOutOfBoundsExceptionGet a byte at the index.- Throws:
java.lang.IndexOutOfBoundsException
-
expandBuffer
private void expandBuffer(int newBufferSize)
Expand the size of the internal buffer.
-
put
public void put(int data)
Add a byte at the current position.
-
put
public void put(byte[] source)
Add data at the current position.- Parameters:
source- Source data.
-
put
public void put(byte[] source, int index, int length)Add data at the current position.- Parameters:
source- Source data.index- The index in the source data. Data from the index is copied.length- The length of data to copy.
-
put
public void put(ByteArray source, int index, int length)
Add data at the current position.- Parameters:
source- Source data.index- The index in the source data. Data from the index is copied.length- The length of data to copy.
-
toBytes
public byte[] toBytes()
Convert to a byte array (byte[]).
-
toBytes
public byte[] toBytes(int beginIndex)
-
toBytes
public byte[] toBytes(int beginIndex, int endIndex)
-
clear
public void clear()
-
shrink
public void shrink(int size)
-
getBit
public boolean getBit(int bitIndex)
-
getBits
public int getBits(int bitIndex, int nBits)
-
getHuffmanBits
public int getHuffmanBits(int bitIndex, int nBits)
-
readBit
public boolean readBit(int[] bitIndex)
-
readBits
public int readBits(int[] bitIndex, int nBits)
-
setBit
public void setBit(int bitIndex, boolean bit)
-
clearBit
public void clearBit(int bitIndex)
-
-