|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.OutputStream
java.io.ByteArrayOutputStream
org.jboss.remoting.transport.multiplex.utility.ShrinkableByteArrayOutputStream
public class ShrinkableByteArrayOutputStream
ShrinkableByteArrayOutputStream extends java.io.ByteArrayOutputStream and adds the following features:
toByteArray()
,
it returns a reference to its internal byte array. start()
returns the position of the next available byte and available()
returns the number of bytes of content, starting at start()
, are available.
write()
is called, if there is too little space at the end of the buffer,
and less than half of the capacity is currently in use, it will shift the current
contents of its buffer to position 0.
toByteArray()
is called, if less than a quarter of the
current capacity is in use and the current capacity is greater than MIN_LENGTH
(currently defined as 1024), it will copy the current contents to a byte array
one half the size of the current byte array.
Copyright (c) 2005
Field Summary |
---|
Fields inherited from class java.io.ByteArrayOutputStream |
---|
buf, count |
Constructor Summary | |
---|---|
ShrinkableByteArrayOutputStream()
Create a new ShrinkableByteArrayOutputStream. |
|
ShrinkableByteArrayOutputStream(int size)
Create a new ShrinkableByteArrayOutputStream. |
Method Summary | |
---|---|
int |
available()
Returns number of bytes of content which can be retrieved. |
int |
bytesReturned()
Returns number of bytes of content returned by last call to toByteArray() . |
protected int |
getCount()
|
protected int |
getLength()
|
protected int |
getNextUsed()
|
protected int |
getUsed()
|
int |
start()
Returns position of next available byte of content in byte array returned by toByteArray() . |
byte[] |
toByteArray(int length)
Returns reference to internal byte array. |
void |
write(byte[] b,
int off,
int len)
Writes len bytes from the specified byte array
starting at offset off to this byte array output stream. |
void |
write(int b)
Writes the specified byte to this byte array output stream. |
Methods inherited from class java.io.ByteArrayOutputStream |
---|
close, reset, size, toByteArray, toString, toString, toString, writeTo |
Methods inherited from class java.io.OutputStream |
---|
flush, write |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ShrinkableByteArrayOutputStream()
public ShrinkableByteArrayOutputStream(int size)
Method Detail |
---|
public int available()
public int bytesReturned()
toByteArray()
.
toByteArray()
public int start()
toByteArray()
.
toByteArray()
public byte[] toByteArray(int length)
length
- number of bytes desired
public void write(int b)
write
in class java.io.ByteArrayOutputStream
b
- the byte to be written.public void write(byte[] b, int off, int len)
len
bytes from the specified byte array
starting at offset off
to this byte array output stream.
write
in class java.io.ByteArrayOutputStream
b
- the data.off
- the start offset in the data.len
- the number of bytes to write.protected int getCount()
protected int getLength()
protected int getNextUsed()
protected int getUsed()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |