org.dbforms.util
Class FileHolder

java.lang.Object
  extended by org.dbforms.util.FileHolder
All Implemented Interfaces:
Serializable

public class FileHolder
extends Object
implements Serializable

A FileHolder holds data saved from a com.oreilly.servlet.multipart.FilePart either as byteArray [now] or as reference to temp-file[future versions]

Author:
Joe Peer
See Also:
Serialized Form

Constructor Summary
FileHolder(String fileName, org.apache.commons.fileupload.FileItem fileItem)
          Constructor - takes descriptive data (fileName, contentType) - inputstream, coming from servletinputstream - we must read it out _now_ - toMemory: true->write it to memory (implemented), false->write it to tempfile (not implemented yet)
 
Method Summary
 String getContentType()
          Returns the content type of the file data contained within.
 int getFileLength()
           Returns the length of the file representated by this FileHolder fileLength gets determinated either during "bufferInMemory" or "bufferInFile" (not impl. yet)
 String getFileName()
          Returns the name that the file was stored with on the remote system, or null if the user didn't enter a file to be uploaded.
 InputStream getInputStreamFromBuffer()
          DOCUMENT ME!
 void setFileName(String fileName)
          Set the name of the file.
 void writeBufferToFile(File fileOrDirectory)
          Writes out the the file in memory to disk.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileHolder

public FileHolder(String fileName,
                  org.apache.commons.fileupload.FileItem fileItem)
           throws IOException,
                  IllegalArgumentException
Constructor - takes descriptive data (fileName, contentType) - inputstream, coming from servletinputstream - we must read it out _now_ - toMemory: true->write it to memory (implemented), false->write it to tempfile (not implemented yet)

Parameters:
fileName - DOCUMENT ME!
fileItem - DOCUMENT ME!
Throws:
IOException - DOCUMENT ME!
IllegalArgumentException - DOCUMENT ME!
Method Detail

getContentType

public String getContentType()
Returns the content type of the file data contained within.

Returns:
content type of the file data.

getFileLength

public int getFileLength()

Returns the length of the file representated by this FileHolder

fileLength gets determinated either during "bufferInMemory" or "bufferInFile" (not impl. yet)

Returns:
content type of the file data.

setFileName

public void setFileName(String fileName)
Set the name of the file.

Parameters:
fileName - DOCUMENT ME!

getFileName

public String getFileName()
Returns the name that the file was stored with on the remote system, or null if the user didn't enter a file to be uploaded. Note: this is not the same as the name of the form parameter used to transmit the file; that is available from the getName method.

Returns:
name of file uploaded or null.
See Also:
Part#getName()

getInputStreamFromBuffer

public InputStream getInputStreamFromBuffer()
                                     throws IOException
DOCUMENT ME!

Returns:
DOCUMENT ME!
Throws:
IOException - DOCUMENT ME!

writeBufferToFile

public void writeBufferToFile(File fileOrDirectory)
                       throws IOException
Writes out the the file in memory to disk.

Parameters:
fileOrDirectory - The file, or directory to write the file to. If it is a directory, you must provide a file already.
Throws:
IOException - Thrown if there are rpoblems writing the file.


Copyright © 2002-2006 DbForms. All Rights Reserved.