|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.i2p.client.streaming.ByteCollector
class ByteCollector
Like a StringBuffer, but for bytes. This class is not internally synchronized, so care should be taken when using in a multithreaded environment.
Field Summary | |
---|---|
(package private) byte[] |
contents
|
(package private) int |
size
|
Constructor Summary | |
---|---|
ByteCollector()
New collector with the default initial capacity |
|
ByteCollector(byte b)
New collector with the specified byte |
|
ByteCollector(byte[] b)
New collector containing the specified bytes |
|
ByteCollector(int capacity)
New collector with an initial capacity as specified |
Method Summary | |
---|---|
ByteCollector |
append(byte b)
Add a new byte to the collector (extending the buffer if necessary) |
ByteCollector |
append(byte[] b)
Add new bytes to the collector (extending the buffer if necessary) |
ByteCollector |
append(byte[] b,
int len)
Add new bytes to the collector (extending the buffer if necessary) |
ByteCollector |
append(byte[] b,
int off,
int len)
Add new bytes to the collector (extending the buffer if necessary) |
ByteCollector |
append(ByteCollector bc)
Add the contents of the byte collector to the current collector (extending the buffer if necessary) |
void |
clear()
Empty the collector. |
void |
clearAndShorten()
Empty the collector and reduce its capacity. |
boolean |
ensureCapacity(int cap)
Make sure we have sufficient storage space. |
boolean |
equals(java.lang.Object o)
Compare the collectors. |
int |
getCurrentSize()
How many bytes are available for retrieval? |
int |
hashCode()
|
int |
indexOf(byte b)
Search through the collector for the first occurrence of the specified byte |
int |
indexOf(byte[] ba)
Search through the collector for the first occurrence of the sequence of bytes |
int |
indexOf(ByteCollector bc)
Search through the collector for the first occurrence of the sequence of bytes contained within the specified collector |
boolean |
isEmpty()
Does the collector have meaningful data or is it empty? |
byte |
removeFirst()
Remove the first byte from the collector, shifting its contents accordingly. |
byte[] |
startToByteArray(int maxlen)
Pull off the first $maxlen bytes from the collector, shifting the remaining bytes into the beginning of the collector's array. |
byte[] |
toByteArray()
Copy the contents of the collector into a new array and return it |
java.lang.String |
toString()
Render the bytes as a string |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
byte[] contents
int size
Constructor Detail |
---|
public ByteCollector()
public ByteCollector(int capacity)
public ByteCollector(byte[] b)
public ByteCollector(byte b)
Method Detail |
---|
public ByteCollector append(byte b)
b
- byte to add
public ByteCollector append(byte[] b)
b
- bytes to add
public ByteCollector append(byte[] b, int len)
b
- byte array to add fromlen
- number of bytes in the array to add
public ByteCollector append(byte[] b, int off, int len)
b
- byte array to add fromoff
- offset into the array to begin adding fromlen
- number of bytes in the array to add
public ByteCollector append(ByteCollector bc)
bc
- collector to copy
public byte[] toByteArray()
public byte[] startToByteArray(int maxlen)
maxlen
- max number of bytes we want to pull from the collector (we will get
less if the collector doesnt have that many bytes yet)
public int getCurrentSize()
public boolean ensureCapacity(int cap)
cap
- minimum number of bytes that the buffer should contain
public boolean isEmpty()
public int indexOf(ByteCollector bc)
bc
- bytes that will be searched for
public int indexOf(byte b)
b
- byte that will be searched for
public int indexOf(byte[] ba)
ba
- bytes that will be searched for
public void clear()
public void clearAndShorten()
public java.lang.String toString()
toString
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public byte removeFirst() throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- if the collector is empty
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |