org.apache.struts.upload

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

Field Summary

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

Constructor Summary

MultipartElement(String name, String value)
Constructor for a text element.
MultipartElement(String name, String fileName, String contentType, File file)
Constructor for a file element.

Method Summary

String
getContentType()
Retrieve the content type.
File
getFile()
Get the File that holds the data for this element.
String
getFileName()
Retrieve the filename, can return null for text elements.
String
getName()
Retrieve the name.
String
getValue()
Returns the value of this multipart element.
boolean
isFile()
Is this element a file.
void
setContentType(String contentType)
Set the content type.
void
setFile(File file)
Set the file that represents this element.
void
setFileName(String fileName)
Set the file name for this element.
void
setName(String name)
Set the name for this element.
void
setValue(String value)

Field Details

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 Details

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

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

Method Details

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 B) 2000-2007 - The Apache Software Foundation