org.apache.struts.upload
Class CommonsMultipartRequestHandler.CommonsFormFile
java.lang.Object
org.apache.struts.upload.CommonsMultipartRequestHandler.CommonsFormFile
- CommonsMultipartRequestHandler
- FormFile, Serializable
(package private) static class CommonsMultipartRequestHandler.CommonsFormFile
extends java.lang.Object
This class implements the Struts FormFile
interface by
wrapping the Commons FileUpload FileItem
interface. This
implementation is read-only; any attempt to modify an instance
of this class will result in an UnsupportedOperationException
.
(package private) FileItem | fileItem - The
FileItem instance wrapped by this object.
|
CommonsFormFile(FileItem fileItem) - Constructs an instance of this class which wraps the supplied
file item.
|
void | destroy() - Destroy all content for this form file.
|
protected String | getBaseFileName(String filePath) - Returns the base file name from the supplied file path.
|
String | getContentType() - Returns the content type for this file.
|
byte[] | getFileData() - Returns the data for this file as a byte array.
|
String | getFileName() - Returns the (client-side) file name for this file.
|
int | getFileSize() - Returns the size, in bytes, of this file.
|
InputStream | getInputStream() - Get an InputStream that represents this file.
|
void | setContentType(String contentType) - Sets the content type for this file.
|
void | setFileName(String fileName) - Sets the (client-side) file name for this file.
|
void | setFileSize(int filesize) - Sets the size, in bytes, for this file.
|
String | toString() - Returns the (client-side) file name for this file.
|
fileItem
(package private) FileItem fileItem
The FileItem
instance wrapped by this object.
CommonsFormFile
public CommonsFormFile(FileItem fileItem)
Constructs an instance of this class which wraps the supplied
file item.
fileItem
- The Commons file item to be wrapped.
destroy
public void destroy()
Destroy all content for this form file.
Implementations should remove any temporary
files or any temporary file data stored somewhere
- destroy in interface FormFile
getBaseFileName
protected String getBaseFileName(String filePath)
Returns the base file name from the supplied file path. On the surface,
this would appear to be a trivial task. Apparently, however, some Linux
JDKs do not implement File.getName()
correctly for Windows
paths, so we attempt to take care of that here.
filePath
- The full path to the file.
- The base file name, from the end of the path.
getContentType
public String getContentType()
Returns the content type for this file.
- getContentType in interface FormFile
- A String representing content type.
getFileData
public byte[] getFileData()
throws FileNotFoundException,
IOException
Returns the data for this file as a byte array. Note that this may
result in excessive memory usage for large uploads. The use of the
getInputStream
method is encouraged
as an alternative.
- getFileData in interface FormFile
- An array of bytes representing the data contained in this
form file.
getFileName
public String getFileName()
Returns the (client-side) file name for this file.
- getFileName in interface FormFile
- The client-size file name.
getFileSize
public int getFileSize()
Returns the size, in bytes, of this file.
- getFileSize in interface FormFile
- The size of the file, in bytes.
getInputStream
public InputStream getInputStream()
throws FileNotFoundException,
IOException
Get an InputStream that represents this file. This is the preferred
method of getting file data.
- getInputStream in interface FormFile
setContentType
public void setContentType(String contentType)
Sets the content type for this file.
NOTE: This method is not supported in this implementation.
- setContentType in interface FormFile
contentType
- A string representing the content type.
setFileName
public void setFileName(String fileName)
Sets the (client-side) file name for this file.
NOTE: This method is not supported in this implementation.
- setFileName in interface FormFile
fileName
- The client-side name for the file.
setFileSize
public void setFileSize(int filesize)
Sets the size, in bytes, for this file.
NOTE: This method is not supported in this implementation.
- setFileSize in interface FormFile
filesize
- The size of the file, in bytes.
toString
public String toString()
Returns the (client-side) file name for this file.
- The client-size file name.
Copyright B) 2000-2007 - The Apache Software Foundation