blackboard.platform.filesystem
Class MultipartRequest

java.lang.Object
  extended by blackboard.platform.filesystem.MultipartRequest

public class MultipartRequest
extends java.lang.Object

Utility object to provide an encapsulation of all the data received in a file upload.


Field Summary
protected  java.util.Hashtable _hashFiles
           
protected  java.util.Hashtable _hashParams
           
static java.lang.String MULTIPART_TKN
           
 
Constructor Summary
protected MultipartRequest()
          Default constructor.
 
Method Summary
protected  void addFile(java.lang.String name, java.io.File file)
          adds a File to the list of files provided with the upload.
protected  void addParameter(java.lang.String name, java.lang.String value)
          Adds a parameter identified by name.
 java.io.File getFile(java.lang.String name)
          Returns a File associated with the given name.
 java.io.File getFileFromParameterName(java.lang.String name)
          Returns a File associated with the given parameter name.
 java.io.File[] getFiles(java.lang.String name)
          Returns an array of all the files uploaded with this request.
 java.lang.String getParameter(java.lang.String name)
          Returns a scalar string value.
 java.lang.String[] getParameterValues(java.lang.String name)
          Returns an array of values associated with a given form field.
static MultipartRequest getRequestInstance(javax.servlet.http.HttpServletRequest req)
          Gets the MultipartRequest instance out of the given request object.
static void setRequestInstance(javax.servlet.http.HttpServletRequest req, MultipartRequest mr)
          Associates a MultipartRequest object with the given request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MULTIPART_TKN

public static java.lang.String MULTIPART_TKN

_hashParams

protected java.util.Hashtable _hashParams

_hashFiles

protected java.util.Hashtable _hashFiles
Constructor Detail

MultipartRequest

protected MultipartRequest()
Default constructor. Initializes parameter and file tables.

Method Detail

getParameter

public java.lang.String getParameter(java.lang.String name)
Returns a scalar string value. If multiple parameters with this name were uploaded, only the first element is returned.

Parameters:
name - the name of the parameter to retrieve
Returns:
scalar string. empty string if no parameter of that name was in the upload

getFile

public java.io.File getFile(java.lang.String name)
Returns a File associated with the given name.

Parameters:
name - name of the file. this value will usually come from another parameter.
Returns:
File. Null if no files of that name were uploaded.

getFileFromParameterName

public java.io.File getFileFromParameterName(java.lang.String name)
Returns a File associated with the given parameter name.

Parameters:
name - name of the parameter. this value will usually come from the form element name.
Returns:
File. Null if no files of that name were uploaded.

getParameterValues

public java.lang.String[] getParameterValues(java.lang.String name)
Returns an array of values associated with a given form field.

Parameters:
name - name of the form field
Returns:
array of strings. Null if not found.

getFiles

public java.io.File[] getFiles(java.lang.String name)
Returns an array of all the files uploaded with this request. This is used infrequently since only one file can be associated with a field.

Parameters:
name - Name of the field.
Returns:
Array of files.

addFile

protected void addFile(java.lang.String name,
                       java.io.File file)
adds a File to the list of files provided with the upload.

Parameters:
name - name of the file to add
file - File

addParameter

protected void addParameter(java.lang.String name,
                            java.lang.String value)
Adds a parameter identified by name.

Parameters:
name - name of the form field
value - value to insert

setRequestInstance

public static void setRequestInstance(javax.servlet.http.HttpServletRequest req,
                                      MultipartRequest mr)
Associates a MultipartRequest object with the given request.

Parameters:
req - the HttpServletRequest that will hold the MultipartRequest
mr - the MultipartRequest.

getRequestInstance

public static MultipartRequest getRequestInstance(javax.servlet.http.HttpServletRequest req)
Gets the MultipartRequest instance out of the given request object.

Parameters:
req - the request object


Copyright © 2003 Blackboard, Inc. All Rights Reserved.