Class ByteArray
java.lang.Object
com.neovisionaries.ws.client.ByteArray
Expandable byte array with byte-basis and bit-basis operations.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()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.voidAdd 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 Details
-
ADDITIONAL_BUFFER_SIZE
private static final int ADDITIONAL_BUFFER_SIZE- See Also:
-
mBuffer
-
mLength
private int mLength
-
-
Constructor Details
-
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 Details
-
length
public int length()The length of the data. -
get
Get a byte at the index.- Throws:
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
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)
-