org.apache.commons.fileupload.DeferredFileOutputStream Class Reference

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

org.apache.commons.fileupload.ThresholdingOutputStream

List of all members.


Detailed Description

An output stream which will retain data in memory until a specified threshold is reached, and only then commit it to disk. If the stream is closed before the threshold is reached, the data will not be written to disk at all.

Author:
Martin Cooper
Version:
Id
DeferredFileOutputStream.java,v 1.2 2003/05/31 22:31:08 martinc Exp

Definition at line 81 of file DeferredFileOutputStream.java.


Public Member Functions

 DeferredFileOutputStream (int threshold, File outputFile)
 Constructs an instance of this class which will trigger an event at the specified threshold, and save data to a file beyond that point.
boolean isInMemory ()
 Determines whether or not the data for this output stream has been retained in memory.
byte[] getData ()
 Returns the data for this output stream as an array of bytes, assuming that the data has been retained in memory.
File getFile ()
 Returns the data for this output stream as a File, assuming that the data was written to disk.

Protected Member Functions

OutputStream getStream () throws IOException
 Returns the current output stream.
void thresholdReached () throws IOException
 Switches the underlying output stream from a memory based stream to one that is backed by disk.

Constructor & Destructor Documentation

org.apache.commons.fileupload.DeferredFileOutputStream.DeferredFileOutputStream ( int  threshold,
File  outputFile 
)

Constructs an instance of this class which will trigger an event at the specified threshold, and save data to a file beyond that point.

Parameters:
threshold The number of bytes at which to trigger an event.
outputFile The file to which data is saved beyond the threshold.

Definition at line 126 of file DeferredFileOutputStream.java.


Member Function Documentation

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

Returns the current output stream.

This may be memory based or disk based, depending on the current state with respect to the threshold.

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

Implements org.apache.commons.fileupload.ThresholdingOutputStream.

Definition at line 147 of file DeferredFileOutputStream.java.

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

Switches the underlying output stream from a memory based stream to one that is backed by disk.

This is the point at which we realise that too much data is being written to keep in memory, so we elect to switch to disk-based storage.

Exceptions:
IOException if an error occurs.

Implements org.apache.commons.fileupload.ThresholdingOutputStream.

Definition at line 161 of file DeferredFileOutputStream.java.

boolean org.apache.commons.fileupload.DeferredFileOutputStream.isInMemory (  ) 

Determines whether or not the data for this output stream has been retained in memory.

Returns:
true if the data is available in memory; false otherwise.

Definition at line 182 of file DeferredFileOutputStream.java.

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

Referenced by org.apache.commons.fileupload.DefaultFileItem.get(), org.apache.commons.fileupload.DefaultFileItem.getInputStream(), org.apache.commons.fileupload.DefaultFileItem.getSize(), and org.apache.commons.fileupload.DefaultFileItem.isInMemory().

byte [] org.apache.commons.fileupload.DeferredFileOutputStream.getData (  ) 

Returns the data for this output stream as an array of bytes, assuming that the data has been retained in memory.

If the data was written to disk, this method returns null.

Returns:
The data for this output stream, or null if no such data is available.

Definition at line 196 of file DeferredFileOutputStream.java.

Referenced by org.apache.commons.fileupload.DefaultFileItem.get(), org.apache.commons.fileupload.DefaultFileItem.getInputStream(), and org.apache.commons.fileupload.DefaultFileItem.getSize().

File org.apache.commons.fileupload.DeferredFileOutputStream.getFile (  ) 

Returns the data for this output stream as a File, assuming that the data was written to disk.

If the data was retained in memory, this method returns null.

Returns:
The file for this output stream, or null if no such file exists.

Definition at line 214 of file DeferredFileOutputStream.java.

Referenced by org.apache.commons.fileupload.DefaultFileItem.finalize(), org.apache.commons.fileupload.DefaultFileItem.get(), org.apache.commons.fileupload.DefaultFileItem.getInputStream(), org.apache.commons.fileupload.DefaultFileItem.getSize(), and org.apache.commons.fileupload.DefaultFileItem.getStoreLocation().


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