MultipartElement (Apache Struts API Documentation)
Keywords: org.apache.struts.upload.MultipartElement,MultipartElement class

Overview | Package | Class | 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 MultipartElement

    java.lang.Object
      |
      +--org.apache.struts.upload.MultipartElement

public class MultipartElement
extends java.lang.Object

This class represents an element in a multipart request. It has a few methods for determining * whether or not the element is a String or a file, and methods to retrieve the data of the aforementioned element. Text input elements have a `null` content type, files have a non-null content type.

Author:
  Mike Schachter

Field Summary
`protected java.lang.String` | `contentType` The content type of this element.
`protected byte[]` | `data` Deprecated. This should never be used.
`protected java.io.File` | `file` The element's data represented in a (possibly temporary) file.
`protected java.lang.String` | `fileName` The element's filename, null for text elements.
`protected boolean` | `isFile` Whether or not this element is a file.
`protected java.lang.String` | `name` The element name.
`protected java.lang.String` | `value` The element's text value, null for file elements

Constructor Summary
`MultipartElement(java.lang.String name, java.lang.String value)` Constructor for a text element.
`MultipartElement(java.lang.String name, java.lang.String fileName, java.lang.String contentType, byte[] data)` Deprecated. Use the constructor that takes an File as an argument as opposed to a byte array argument, which can cause memory problems.
`MultipartElement(java.lang.String name, java.lang.String fileName, java.lang.String contentType, java.io.File file)` Constructor for a file element.

Method Summary
`java.lang.String` | `getContentType()` Retrieve the content type.
`byte[]` | `getData()` Deprecated. Use the getFile method to get a File representing the data for this element
`java.io.File` | `getFile()` Get the File that holds the data for this element.
`java.lang.String` | `getFileName()` Retrieve the filename, can return `null` for text elements.
`java.lang.String` | `getName()` Retrieve the name.
`java.lang.String` | `getValue()` Returns the value of this multipart element.
`boolean` | `isFile()` Is this element a file.
`void` | `setContentType(java.lang.String contentType)` Set the content type.
`void` | `setData(byte[] data)` Deprecated. Use the setFile method to set the file that represents the data of this element
`void` | `setFile(java.io.File file)` Set the file that represents this element.
`void` | `setFileName(java.lang.String fileName)` Set the file name for this element.
`void` | `setName(java.lang.String name)` Set the name for this element.
`void` | `setValue(java.lang.String value)`

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

Field Detail

### contentType

    protected java.lang.String contentType

  The content type of this element.

### data

    protected byte[] data

  Deprecated. This should never be used.

  The element data.

### file

    protected java.io.File file

  The element's data represented in a (possibly temporary) file.

### name

    protected java.lang.String name

  The element name.

### fileName

    protected java.lang.String fileName

  The element's filename, null for text elements.

### value

    protected java.lang.String value

  The element's text value, null for file elements

### isFile

    protected boolean isFile

  Whether or not this element is a file.

Constructor Detail

### MultipartElement

    public MultipartElement(java.lang.String name,
                            java.lang.String fileName,
                            java.lang.String contentType,
                            byte[] data)

  Deprecated. Use the constructor that takes an File as an argument as opposed to a byte array argument, which can cause memory problems.

### MultipartElement

    public MultipartElement(java.lang.String name,
                            java.lang.String fileName,
                            java.lang.String contentType,
                            java.io.File file)

  Constructor for a file element.

Parameters:
  `name` - The form name of the element
  `fileName` - The file name of the element if this element is a file
  `contentType` - The content type of the element if a file
  `file` - The (possibly temporary) file representing this element if it's a file

### MultipartElement

    public MultipartElement(java.lang.String name,
                            java.lang.String value)

  Constructor for a text element.

Parameters:
  `name` - The name of the element
  `value` - The value of the element

Method Detail

### getContentType

    public java.lang.String getContentType()

  Retrieve the content type.

### getData

    public byte[] getData()

  Deprecated. Use the getFile method to get a File representing the data for this element

  Retrieve the data.

### getFile

    public java.io.File getFile()

  Get the File that holds the data for this element.

### getName

    public java.lang.String getName()

  Retrieve the name.

### getFileName

    public java.lang.String getFileName()

  Retrieve the filename, can return `null` for text elements.

### getValue

    public java.lang.String getValue()

  Returns the value of this multipart element.

  Returns:
    A String if the element is a text element, `null` otherwise

### setFile

    public void setFile(java.io.File file)

  Set the file that represents this element.

### setFileName

    public void setFileName(java.lang.String fileName)

  Set the file name for this element.

### setName

    public void setName(java.lang.String name)

  Set the name for this element.

### setContentType

    public void setContentType(java.lang.String contentType)

  Set the content type.

### isFile

    public boolean isFile()

  Is this element a file.

### setValue

    public void setValue(java.lang.String value)

### setData

    public void setData(byte[] data)

  Deprecated. Use the setFile method to set the file that represents the data of this element

  Set the data.

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

Copyright © 2000-2002 - Apache Software Foundation