org.apache.struts.upload
static class CommonsMultipartRequestHandler.CommonsFormFile extends java.lang.Object implements FormFile, java.io.Serializable
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
.Modifier and Type | Field and Description |
---|---|
(package private) org.apache.commons.fileupload.FileItem |
fileItem
The
FileItem instance wrapped by this object. |
Constructor and Description |
---|
CommonsMultipartRequestHandler.CommonsFormFile(org.apache.commons.fileupload.FileItem fileItem)
Constructs an instance of this class which wraps the supplied
file item.
|
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Destroy all content for this form file.
|
protected java.lang.String |
getBaseFileName(java.lang.String filePath)
Returns the base file name from the supplied file path.
|
java.lang.String |
getContentType()
Returns the content type for this file.
|
byte[] |
getFileData()
Returns the data for this file as a byte array.
|
java.lang.String |
getFileName()
Returns the (client-side) file name for this file.
|
int |
getFileSize()
Returns the size, in bytes, of this file.
|
java.io.InputStream |
getInputStream()
Get an InputStream that represents this file.
|
void |
setContentType(java.lang.String contentType)
Sets the content type for this file.
|
void |
setFileName(java.lang.String fileName)
Sets the (client-side) file name for this file.
|
void |
setFileSize(int filesize)
Sets the size, in bytes, for this file.
|
java.lang.String |
toString()
Returns the (client-side) file name for this file.
|
org.apache.commons.fileupload.FileItem fileItem
FileItem
instance wrapped by this object.public CommonsMultipartRequestHandler.CommonsFormFile(org.apache.commons.fileupload.FileItem fileItem)
fileItem
- The Commons file item to be wrapped.public java.lang.String getContentType()
getContentType
in interface FormFile
public void setContentType(java.lang.String contentType)
NOTE: This method is not supported in this implementation.
setContentType
in interface FormFile
contentType
- A string representing the content type.public int getFileSize()
getFileSize
in interface FormFile
public void setFileSize(int filesize)
NOTE: This method is not supported in this implementation.
setFileSize
in interface FormFile
filesize
- The size of the file, in bytes.public java.lang.String getFileName()
getFileName
in interface FormFile
public void setFileName(java.lang.String fileName)
NOTE: This method is not supported in this implementation.
setFileName
in interface FormFile
fileName
- The client-side name for the file.public byte[] getFileData() throws java.io.FileNotFoundException, java.io.IOException
getInputStream
method is encouraged
as an alternative.getFileData
in interface FormFile
java.io.FileNotFoundException
- If some sort of file representation
cannot be found for the FormFilejava.io.IOException
- If there is some sort of IOExceptionpublic java.io.InputStream getInputStream() throws java.io.FileNotFoundException, java.io.IOException
getInputStream
in interface FormFile
java.io.FileNotFoundException
- If some sort of file representation
cannot be found for the FormFilejava.io.IOException
- If there is some sort of IOExceptionpublic void destroy()
protected java.lang.String getBaseFileName(java.lang.String filePath)
File.getName()
correctly for Windows
paths, so we attempt to take care of that here.filePath
- The full path to the file.public java.lang.String toString()
toString
in class java.lang.Object
Copyright ? 2000-2014 - The Apache Software Foundation