org.apache.commons.fileupload.ThresholdingOutputStream Class Reference

Inheritance diagram for org.apache.commons.fileupload.ThresholdingOutputStream:

org.apache.commons.fileupload.DeferredFileOutputStream

List of all members.


Detailed Description

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
ThresholdingOutputStream.java,v 1.3 2003/05/31 22:31:08 martinc Exp

Definition at line 87 of file ThresholdingOutputStream.java.


Public Member Functions

 ThresholdingOutputStream (int threshold)
 Constructs an instance of this class which will trigger an event at the specified threshold.
void write (int b) throws IOException
 Writes the specified byte to this output stream.
void write (byte b[]) throws IOException
 Writes b.length bytes from the specified byte array to this output stream.
void write (byte b[], int off, int len) throws IOException
 Writes len bytes from the specified byte array starting at offset off to this output stream.
void flush () throws IOException
 Flushes this output stream and forces any buffered output bytes to be written out.
void close () throws IOException
 Closes this output stream and releases any system resources associated with this stream.
int getThreshold ()
 Returns the threshold, in bytes, at which an event will be triggered.
long getByteCount ()
 Returns the number of bytes that have been written to this output stream.
boolean isThresholdExceeded ()
 Determines whether or not the configured threshold has been exceeded for this output stream.

Protected Member Functions

void checkThreshold (int count) throws IOException
 Checks to see if writing the specified number of bytes would cause the configured threshold to be exceeded.
abstract OutputStream getStream () throws IOException
 Returns the underlying output stream, to which the corresponding OutputStream methods in this class will ultimately delegate.
abstract void thresholdReached () throws IOException
 Indicates that the configured threshold has been reached, and that a subclass should take whatever action necessary on this event.

Constructor & Destructor Documentation

org.apache.commons.fileupload.ThresholdingOutputStream.ThresholdingOutputStream ( int  threshold  ) 

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.

Definition at line 121 of file ThresholdingOutputStream.java.


Member Function Documentation

void org.apache.commons.fileupload.ThresholdingOutputStream.write ( int  b  )  throws IOException

Writes the specified byte to this output stream.

Parameters:
b The byte to be written.
Exceptions:
IOException if an error occurs.

Definition at line 137 of file ThresholdingOutputStream.java.

References org.apache.commons.fileupload.ThresholdingOutputStream.checkThreshold(), and org.apache.commons.fileupload.ThresholdingOutputStream.getStream().

void org.apache.commons.fileupload.ThresholdingOutputStream.write ( byte  b[]  )  throws IOException

Writes b.length bytes from the specified byte array to this output stream.

Parameters:
b The array of bytes to be written.
Exceptions:
IOException if an error occurs.

Definition at line 153 of file ThresholdingOutputStream.java.

References org.apache.commons.fileupload.ThresholdingOutputStream.checkThreshold(), and org.apache.commons.fileupload.ThresholdingOutputStream.getStream().

void org.apache.commons.fileupload.ThresholdingOutputStream.write ( byte  b[],
int  off,
int  len 
) throws IOException

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.
off The start offset in the byte array.
len The number of bytes to write.
Exceptions:
IOException if an error occurs.

Definition at line 171 of file ThresholdingOutputStream.java.

References org.apache.commons.fileupload.ThresholdingOutputStream.checkThreshold(), and org.apache.commons.fileupload.ThresholdingOutputStream.getStream().

void org.apache.commons.fileupload.ThresholdingOutputStream.flush (  )  throws IOException

Flushes this output stream and forces any buffered output bytes to be written out.

Exceptions:
IOException if an error occurs.

Definition at line 185 of file ThresholdingOutputStream.java.

References org.apache.commons.fileupload.ThresholdingOutputStream.getStream().

Referenced by org.apache.commons.fileupload.ThresholdingOutputStream.close().

void org.apache.commons.fileupload.ThresholdingOutputStream.close (  )  throws IOException

Closes this output stream and releases any system resources associated with this stream.

Exceptions:
IOException if an error occurs.

Definition at line 197 of file ThresholdingOutputStream.java.

References org.apache.commons.fileupload.ThresholdingOutputStream.flush(), and org.apache.commons.fileupload.ThresholdingOutputStream.getStream().

int org.apache.commons.fileupload.ThresholdingOutputStream.getThreshold (  ) 

Returns the threshold, in bytes, at which an event will be triggered.

Returns:
The threshold point, in bytes.

Definition at line 219 of file ThresholdingOutputStream.java.

long org.apache.commons.fileupload.ThresholdingOutputStream.getByteCount (  ) 

Returns the number of bytes that have been written to this output stream.

Returns:
The number of bytes written.

Definition at line 230 of file ThresholdingOutputStream.java.

boolean org.apache.commons.fileupload.ThresholdingOutputStream.isThresholdExceeded (  ) 

Determines whether or not the configured threshold has been exceeded for this output stream.

Returns:
true if the threshold has been reached; false otherwise.

Definition at line 243 of file ThresholdingOutputStream.java.

Referenced by org.apache.commons.fileupload.DeferredFileOutputStream.isInMemory().

void org.apache.commons.fileupload.ThresholdingOutputStream.checkThreshold ( int  count  )  throws IOException [protected]

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 output stream.
Exceptions:
IOException if an error occurs.

Definition at line 262 of file ThresholdingOutputStream.java.

References org.apache.commons.fileupload.ThresholdingOutputStream.thresholdReached().

Referenced by org.apache.commons.fileupload.ThresholdingOutputStream.write().

abstract OutputStream org.apache.commons.fileupload.ThresholdingOutputStream.getStream (  )  throws IOException [protected, pure virtual]

Returns the underlying output stream, to which the corresponding OutputStream methods in this class will ultimately delegate.

Returns:
The underlying output stream.
Exceptions:
IOException if an error occurs.

Implemented in org.apache.commons.fileupload.DeferredFileOutputStream.

Referenced by org.apache.commons.fileupload.ThresholdingOutputStream.close(), org.apache.commons.fileupload.ThresholdingOutputStream.flush(), and org.apache.commons.fileupload.ThresholdingOutputStream.write().

abstract void org.apache.commons.fileupload.ThresholdingOutputStream.thresholdReached (  )  throws IOException [protected, pure virtual]

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.

Exceptions:
IOException if an error occurs.

Implemented in org.apache.commons.fileupload.DeferredFileOutputStream.

Referenced by org.apache.commons.fileupload.ThresholdingOutputStream.checkThreshold().


The documentation for this class was generated from the following file:
Generated on Mon Jan 11 21:19:19 2010 for OpenMobileIS by  doxygen 1.5.4