|
|||||||||
| Home >> All >> org >> mortbay >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.mortbay.util
Class ByteBufferOutputStream

java.lang.Objectjava.io.OutputStream
org.mortbay.util.ByteBufferOutputStream
- public class ByteBufferOutputStream
- extends java.io.OutputStream
ByteBuffer OutputStream. This stream is similar to the java.io.ByteArrayOutputStream, except that it maintains a reserve of bytes at the start of the buffer and allows efficient prepending of data.
- Version:
- $Revision: 1.14 $
| Field Summary | |
protected byte[] |
_buf
|
private int |
_end
The end of data capacity in the buffer |
private boolean |
_fixed
|
private int |
_pos
The last byte of data written to the buffer _start <= _pos <= _end |
private int |
_postReserve
|
private int |
_preReserve
|
private boolean |
_resized
|
private int |
_start
The start of data capacity in the buffer |
private static org.apache.commons.logging.Log |
log
|
| Constructor Summary | |
ByteBufferOutputStream()
Constructor. |
|
ByteBufferOutputStream(int capacity)
Constructor. |
|
ByteBufferOutputStream(int capacity,
int preReserve)
Constructor. |
|
ByteBufferOutputStream(int bufferSize,
int preReserve,
int postReserve)
Constructor. |
|
| Method Summary | |
int |
bufferSize()
|
int |
capacity()
|
void |
close()
This method closes the stream. |
void |
destroy()
|
void |
ensureCapacity(int n)
|
void |
ensureReserve(int n)
|
void |
ensureSize(int bufSize)
|
void |
ensureSize(int bufSize,
int pre,
int post)
|
void |
ensureSpareCapacity(int n)
|
void |
flush()
This method forces any data that may have been buffered to be written to the underlying output device. |
boolean |
isFixed()
|
int |
postReserve()
|
void |
postwrite(byte[] b,
int offset,
int length)
Write bytes into the postreserve. |
int |
preReserve()
|
void |
prewrite(byte[] b)
Write byte array to start of the buffer. |
void |
prewrite(byte[] b,
int offset,
int length)
Write byte range to start of the buffer. |
void |
prewrite(int b)
Write byte to start of the buffer. |
void |
reset(int reserve)
|
void |
resetStream()
|
void |
setFixed(boolean fixed)
|
int |
size()
|
int |
spareCapacity()
|
void |
write(byte[] b)
This method all the writes bytes from the passed array to the output stream. |
void |
write(byte[] b,
int offset,
int length)
This method writes len bytes from the specified array
b starting at index off into the array. |
void |
write(int b)
This method writes a single byte to the output stream. |
void |
writeTo(java.io.OutputStream out)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
log
private static org.apache.commons.logging.Log log
_buf
protected byte[] _buf
_start
private int _start
- The start of data capacity in the buffer
_end
private int _end
- The end of data capacity in the buffer
_pos
private int _pos
- The last byte of data written to the buffer
_start <= _pos <= _end
_preReserve
private int _preReserve
_postReserve
private int _postReserve
_resized
private boolean _resized
_fixed
private boolean _fixed
| Constructor Detail |
ByteBufferOutputStream
public ByteBufferOutputStream()
- Constructor.
ByteBufferOutputStream
public ByteBufferOutputStream(int capacity)
- Constructor.
ByteBufferOutputStream
public ByteBufferOutputStream(int capacity,
int preReserve)
- Constructor.
ByteBufferOutputStream
public ByteBufferOutputStream(int bufferSize,
int preReserve,
int postReserve)
- Constructor.
| Method Detail |
isFixed
public boolean isFixed()
setFixed
public void setFixed(boolean fixed)
size
public int size()
bufferSize
public int bufferSize()
capacity
public int capacity()
spareCapacity
public int spareCapacity()
preReserve
public int preReserve()
postReserve
public int postReserve()
writeTo
public void writeTo(java.io.OutputStream out) throws java.io.IOException
write
public void write(int b)
throws java.io.IOException
- Description copied from class:
java.io.OutputStream - This method writes a single byte to the output stream. The byte written
is the low eight bits of the
intpassed and a argument.Subclasses must provide an implementation of this abstract method
write
public void write(byte[] b)
throws java.io.IOException
- Description copied from class:
java.io.OutputStream - This method all the writes bytes from the passed array to the
output stream. This method is equivalent to
write(b, 0, buf.length)which is exactly how it is implemented in this class.
write
public void write(byte[] b,
int offset,
int length)
throws java.io.IOException
- Description copied from class:
java.io.OutputStream - This method writes
lenbytes from the specified arraybstarting at indexoffinto the array.This method in this class calls the single byte
write()method in a loop until all bytes have been written. Subclasses should override this method if possible in order to provide a more efficent implementation.
prewrite
public void prewrite(int b)
- Write byte to start of the buffer.
prewrite
public void prewrite(byte[] b)
- Write byte array to start of the buffer.
prewrite
public void prewrite(byte[] b,
int offset,
int length)
- Write byte range to start of the buffer.
postwrite
public void postwrite(byte[] b,
int offset,
int length)
throws java.io.IOException
- Write bytes into the postreserve.
The capacity is not checked.
flush
public void flush()
throws java.io.IOException
- Description copied from class:
java.io.OutputStream - This method forces any data that may have been buffered to be written
to the underlying output device. Please note that the host environment
might perform its own buffering unbeknowst to Java. In that case, a
write made (for example, to a disk drive) might be cached in OS
buffers instead of actually being written to disk.
This method in this class does nothing.
resetStream
public void resetStream()
reset
public void reset(int reserve)
close
public void close()
throws java.io.IOException
- Description copied from class:
java.io.OutputStream - This method closes the stream. Any internal or native resources
associated with this stream are freed. Any subsequent attempt to
access the stream might throw an exception.
This method in this class does nothing.
destroy
public void destroy()
ensureReserve
public void ensureReserve(int n)
ensureSize
public void ensureSize(int bufSize)
throws java.io.IOException
ensureSize
public void ensureSize(int bufSize,
int pre,
int post)
throws java.io.IOException
ensureSpareCapacity
public void ensureSpareCapacity(int n)
throws java.io.IOException
ensureCapacity
public void ensureCapacity(int n)
throws java.io.IOException
|
|||||||||
| Home >> All >> org >> mortbay >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC