org.apache.struts.upload

Class MultipartElement

public class MultipartElement extends Object

Deprecated: Use the Commons FileUpload based multipart handler instead. This class will be removed after Struts 1.2.

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.
Field Summary
protected StringcontentType
The content type of this element.
protected byte[]data
The element data.
protected Filefile
The element's data represented in a (possibly temporary) file.
protected StringfileName
The element's filename, null for text elements.
protected booleanisFile
Whether or not this element is a file.
protected Stringname
The element name.
protected Stringvalue
The element's text value, null for file elements
Constructor Summary
MultipartElement(String name, String fileName, String contentType, File file)
Constructor for a file element.
MultipartElement(String name, String value)
Constructor for a text element.
Method Summary
StringgetContentType()
Retrieve the content type.
FilegetFile()
Get the File that holds the data for this element.
StringgetFileName()
Retrieve the filename, can return null for text elements.
StringgetName()
Retrieve the name.
StringgetValue()
Returns the value of this multipart element.
booleanisFile()
Is this element a file.
voidsetContentType(String contentType)
Set the content type.
voidsetFile(File file)
Set the file that represents this element.
voidsetFileName(String fileName)
Set the file name for this element.
voidsetName(String name)
Set the name for this element.
voidsetValue(String value)

Field Detail

contentType

protected String contentType
The content type of this element.

data

protected byte[] data

Deprecated: This should never be used.

The element data.

file

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

fileName

protected String fileName
The element's filename, null for text elements.

isFile

protected boolean isFile
Whether or not this element is a file.

name

protected String name
The element name.

value

protected String value
The element's text value, null for file elements

Constructor Detail

MultipartElement

public MultipartElement(String name, String fileName, String contentType, 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(String name, String value)
Constructor for a text element.

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

Method Detail

getContentType

public String getContentType()
Retrieve the content type.

getFile

public File getFile()
Get the File that holds the data for this element.

getFileName

public String getFileName()
Retrieve the filename, can return null for text elements.

getName

public String getName()
Retrieve the name.

getValue

public String getValue()
Returns the value of this multipart element.

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

isFile

public boolean isFile()
Is this element a file.

setContentType

public void setContentType(String contentType)
Set the content type.

setFile

public void setFile(File file)
Set the file that represents this element.

setFileName

public void setFileName(String fileName)
Set the file name for this element.

setName

public void setName(String name)
Set the name for this element.

setValue

public void setValue(String value)
Copyright © 2000-2008 - The Apache Software Foundation