| java.lang.Object java.io.OutputStream org.apache.wicket.util.io.ThresholdingOutputStream
All known Subclasses: org.apache.wicket.util.io.DeferredFileOutputStream,
ThresholdingOutputStream | abstract public class ThresholdingOutputStream extends OutputStream (Code) | | An output stream which triggers an event when a specified number of bytes of data have
been written to it. The event can be used, for example, to throw an exception if a
maximum has been reached, or to switch the underlying stream type when the threshold is
exceeded.
This class overrides all OutputStream methods. However, these overrides
ultimately call the corresponding methods in the underlying output stream
implementation.
NOTE: This implementation may trigger the event before the threshold is
actually reached, since it triggers when a pending write operation would cause the
threshold to be exceeded.
author: Martin Cooper version: $Id$ |
Constructor Summary | |
public | ThresholdingOutputStream(int threshold) Constructs an instance of this class which will trigger an event at the specified
threshold. |
Method Summary | |
protected void | checkThreshold(int count) Checks to see if writing the specified number of bytes would cause the configured
threshold to be exceeded. | public void | close() Closes this output stream and releases any system resources associated with this
stream. | public void | flush() Flushes this output stream and forces any buffered output bytes to be written out. | public long | getByteCount() Returns the number of bytes that have been written to this output stream. | abstract protected OutputStream | getStream() Returns the underlying output stream, to which the corresponding
OutputStream methods in this class will ultimately delegate. | public int | getThreshold() Returns the threshold, in bytes, at which an event will be triggered. | public boolean | isThresholdExceeded() Determines whether or not the configured threshold has been exceeded for this
output stream. | abstract protected void | thresholdReached() Indicates that the configured threshold has been reached, and that a subclass
should take whatever action necessary on this event. | public void | write(int b) Writes the specified byte to this output stream. | public void | write(byte b) Writes b.length bytes from the specified byte array to this output
stream. | public void | write(byte b, int off, int len) Writes len bytes from the specified byte array starting at offset
off to this output stream. |
ThresholdingOutputStream | public ThresholdingOutputStream(int threshold)(Code) | | Constructs an instance of this class which will trigger an event at the specified
threshold.
Parameters: threshold - The number of bytes at which to trigger an event. |
checkThreshold | protected void checkThreshold(int count) throws IOException(Code) | | Checks to see if writing the specified number of bytes would cause the configured
threshold to be exceeded. If so, triggers an event to allow a concrete
implementation to take action on this.
Parameters: count - The number of bytes about to be written to the underlying outputstream. exception: IOException - if an error occurs. |
close | public void close() throws IOException(Code) | | Closes this output stream and releases any system resources associated with this
stream.
exception: IOException - if an error occurs. |
flush | public void flush() throws IOException(Code) | | Flushes this output stream and forces any buffered output bytes to be written out.
exception: IOException - if an error occurs. |
getByteCount | public long getByteCount()(Code) | | Returns the number of bytes that have been written to this output stream.
The number of bytes written. |
getStream | abstract protected OutputStream getStream() throws IOException(Code) | | Returns the underlying output stream, to which the corresponding
OutputStream methods in this class will ultimately delegate.
The underlying output stream. exception: IOException - if an error occurs. |
getThreshold | public int getThreshold()(Code) | | Returns the threshold, in bytes, at which an event will be triggered.
The threshold point, in bytes. |
isThresholdExceeded | public boolean isThresholdExceeded()(Code) | | Determines whether or not the configured threshold has been exceeded for this
output stream.
true if the threshold has been reached; false otherwise. |
thresholdReached | abstract protected void thresholdReached() throws IOException(Code) | | Indicates that the configured threshold has been reached, and that a subclass
should take whatever action necessary on this event. This may include changing the
underlying output stream.
exception: IOException - if an error occurs. |
write | public void write(int b) throws IOException(Code) | | Writes the specified byte to this output stream.
Parameters: b - The byte to be written. exception: IOException - if an error occurs. |
write | public void write(byte b) throws IOException(Code) | | Writes b.length bytes from the specified byte array to this output
stream.
Parameters: b - The array of bytes to be written. exception: IOException - if an error occurs. |
write | public void write(byte b, int off, int len) throws IOException(Code) | | Writes len bytes from the specified byte array starting at offset
off to this output stream.
Parameters: b - The byte array from which the data will be written. Parameters: off - The start offset in the byte array. Parameters: len - The number of bytes to write. exception: IOException - if an error occurs. |
|
|