Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.struts.upload
Class CommonsMultipartRequestHandler.CommonsFormFile

    java.lang.Object
      |
      +--org.apache.struts.upload.CommonsMultipartRequestHandler.CommonsFormFile

All Implemented Interfaces:
  FormFile

Enclosing class:
  CommonsMultipartRequestHandler

static class CommonsMultipartRequestHandler.CommonsFormFile
extends java.lang.Object
implements FormFile

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`.

Field Summary
`(package private) org.apache.commons.fileupload.FileItem` | `fileItem` The `FileItem` instance wrapped by this object.

Constructor Summary
`CommonsMultipartRequestHandler.CommonsFormFile(org.apache.commons.fileupload.FileItem fileItem)` Constructs an instance of this class which wraps the supplied file item.

Method Summary
`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.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### fileItem

    org.apache.commons.fileupload.FileItem fileItem

  The `FileItem` instance wrapped by this object.

Constructor Detail

### CommonsMultipartRequestHandler.CommonsFormFile

    public CommonsMultipartRequestHandler.CommonsFormFile(org.apache.commons.fileupload.FileItem fileItem)

  Constructs an instance of this class which wraps the supplied file item.

Parameters:
  `fileItem` - The Commons file item to be wrapped.

Method Detail

### getContentType

    public java.lang.String getContentType()

  Returns the content type for this file.

  Specified by:
    `getContentType` in interface `FormFile`
  Returns:
    A String representing content type.

### setContentType

    public void setContentType(java.lang.String contentType)

  Sets the content type for this file.

  NOTE: This method is not supported in this implementation.

  Specified by:
    `setContentType` in interface `FormFile`
  Parameters:
    `contentType` - A string representing the content type.

### getFileSize

    public int getFileSize()

  Returns the size, in bytes, of this file.

  Specified by:
    `getFileSize` in interface `FormFile`
  Returns:
    The size of the file, in bytes.

### setFileSize

    public void setFileSize(int filesize)

  Sets the size, in bytes, for this file.

  NOTE: This method is not supported in this implementation.

  Specified by:
    `setFileSize` in interface `FormFile`
  Parameters:
    `filesize` - The size of the file, in bytes.

### getFileName

    public java.lang.String getFileName()

  Returns the (client-side) file name for this file.

  Specified by:
    `getFileName` in interface `FormFile`
  Returns:
    The client-size file name.

### setFileName

    public void setFileName(java.lang.String fileName)

  Sets the (client-side) file name for this file.

  NOTE: This method is not supported in this implementation.

  Specified by:
    `setFileName` in interface `FormFile`
  Parameters:
    `fileName` - The client-side name for the file.

### getFileData

    public byte[] getFileData()
                       throws java.io.FileNotFoundException,
                              java.io.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.

  Specified by:
    `getFileData` in interface `FormFile`
  Returns:
    An array of bytes representing the data contained in this form file.
  Throws:
    `java.io.FileNotFoundException` - If some sort of file representation cannot be found for the FormFile
    `java.io.IOException` - If there is some sort of IOException

### getInputStream

    public java.io.InputStream getInputStream()
                                       throws java.io.FileNotFoundException,
                                              java.io.IOException

  Get an InputStream that represents this file. This is the preferred method of getting file data.

  Specified by:
    `getInputStream` in interface `FormFile`
  Throws:
    `java.io.FileNotFoundException` - If some sort of file representation cannot be found for the FormFile
    `java.io.IOException` - If there is some sort of IOException

### destroy

    public void destroy()

  Destroy all content for this form file. Implementations should remove any temporary files or any temporary file data stored somewhere

  Specified by:
    `destroy` in interface `FormFile`

### getBaseFileName

    protected java.lang.String getBaseFileName(java.lang.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.

  Parameters:
    `filePath` - The full path to the file.
  Returns:
    The base file name, from the end of the path.

### toString

    public java.lang.String toString()

  Returns the (client-side) file name for this file.

  Overrides:
    `toString` in class `java.lang.Object`
  Returns:
    The client-size file name.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2003 - Apache Software Foundation