org.apache.commons.fileupload
クラス FileUploadBase

java.lang.Object
  拡張org.apache.commons.fileupload.FileUploadBase
直系の既知のサブクラス:
DiskFileUpload, FileUpload

public abstract class FileUploadBase
extends Object

ファイルアップロードを処理するための高レベルAPIです。

High level API for processing file uploads.

このクラスは RFC 1867 によって規定された multipart/mixed エンコーディングタイプを使用して HTMLウィジェットから送信された複数のファイルを処理します。 parseRequest(HttpServletRequest) を使用して、HTMLウィジェットから送られるデータを示す FileItem のリストを取得します。

This class handles multiple files per single HTML widget, sent using multipart/mixed encoding type, as specified by RFC 1867. Use {@link #parseRequest(HttpServletRequest)} to acquire a list of {@link org.apache.commons.fileupload.FileItem}s associated with a given HTML widget.

個々のパーツが持つデータを保持する方法は、使用されるファクトリによって、 メモリ上やディスク上などになります。

How the data for individual parts is stored is determined by the factory used to create them; a given part may be in memory, on disk, or somewhere else.

バージョン:
$Id: FileUploadBase.java,v 1.5 2004/04/20 15:10:02 hioki Exp $
作成者:
Rafal Krzewski, Daniel Rall, Jason van Zyl, John McNally, Martin Cooper, Sean C. Sullivan
翻訳者:
日置 聡
校正者:
入江 弘憲
翻訳状況:
校了

入れ子クラスの概要
static class FileUploadBase.InvalidContentTypeException
          リクエストが multipart リクエストでない場合に投げられます。
static class FileUploadBase.SizeLimitExceededException
          リクエストのサイズが設定された最大サイズを超えた場合に投げられます。
static class FileUploadBase.UnknownSizeException
          リクエストのサイズが明示されていない場合に投げられます。
 
フィールドの概要
static String ATTACHMENT
          ファイルアタッチメントの場合の Content-disposition の値。
static String CONTENT_DISPOSITION
          HTTP content disposition のヘッダ名。
static String CONTENT_TYPE
          HTTP content type のヘッダ名。
static String FORM_DATA
          フォームデータの場合の Content-disposition の値。
private  String headerEncoding
          パーツのヘッダを読み込む際に使用されるエンコーディング。
static int MAX_HEADER_SIZE
          ヘッダのパースの際に読み込む最大長(1024バイト)。
static String MULTIPART
          HTTP content type ヘッダの一部。
static String MULTIPART_FORM_DATA
          multipart forms の場合の HTTP content type ヘッダ(の値)。
static String MULTIPART_MIXED
          複数アップロードの場合の HTTP content type ヘッダ(の値)。
private  long sizeMax
          アップロードされるファイルに許可する最大サイズ。
 
コンストラクタの概要
FileUploadBase()
           
 
メソッドの概要
protected  FileItem createItem(Map headers, boolean isFormField)
          新規 FileItem インスタンスを生成します。
protected  String getFieldName(Map headers)
          Content-disposition ヘッダからフィールド名を取得します。
abstract  FileItemFactory getFileItemFactory()
          ファイルアイテムを生成する際に使用するファクトリクラスを返します。
protected  String getFileName(Map headers)
          Content-disposition ヘッダからファイル名を取得します。
protected  String getHeader(Map headers, String name)
          渡されたマップの中から指定された名称のヘッダの値を取得します。
 String getHeaderEncoding()
          個々のパーツのヘッダを読み込む際に使用されるキャラクタエンコーディングを取得します。
 long getSizeMax()
          アップロードが許可される最大サイズを返します。
static boolean isMultipartContent(javax.servlet.http.HttpServletRequest req)
          リクエストが multipart content を含むかどうかを判断するユーティリティメソッドです。
protected  Map parseHeaders(String headerPart)
           header-part をパースし、キー/値 のペアを返します。
 List parseRequest(javax.servlet.http.HttpServletRequest req)
          RFC 1867 の仕様に従って multipart/form-data のストリームを処理します。
abstract  void setFileItemFactory(FileItemFactory factory)
          ファイルアイテムを生成する際に使用するファクトリクラスを設定します。
 void setHeaderEncoding(String encoding)
          個々のパーツのヘッダを読み込む際に使用されるキャラクタエンコーディングを設定します。
 void setSizeMax(long sizeMax)
          アップロードが許可される最大サイズを設定します。
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

CONTENT_TYPE

public static final String CONTENT_TYPE
HTTP content type のヘッダ名。
HTTP content type header name.

関連項目:
定数フィールド値

CONTENT_DISPOSITION

public static final String CONTENT_DISPOSITION
HTTP content disposition のヘッダ名。
HTTP content disposition header name.

関連項目:
定数フィールド値

FORM_DATA

public static final String FORM_DATA
フォームデータの場合の Content-disposition の値。
Content-disposition value for form data.

関連項目:
定数フィールド値

ATTACHMENT

public static final String ATTACHMENT
ファイルアタッチメントの場合の Content-disposition の値。
Content-disposition value for file attachment.

関連項目:
定数フィールド値

MULTIPART

public static final String MULTIPART
HTTP content type ヘッダの一部。
Part of HTTP content type header.

関連項目:
定数フィールド値

MULTIPART_FORM_DATA

public static final String MULTIPART_FORM_DATA
multipart forms の場合の HTTP content type ヘッダ(の値)。
HTTP content type header for multipart forms.

関連項目:
定数フィールド値

MULTIPART_MIXED

public static final String MULTIPART_MIXED
複数アップロードの場合の HTTP content type ヘッダ(の値)。
HTTP content type header for multiple uploads.

関連項目:
定数フィールド値

MAX_HEADER_SIZE

public static final int MAX_HEADER_SIZE
ヘッダのパースの際に読み込む最大長(1024バイト)。
The maximum length of a single header line that will be parsed (1024 bytes).

関連項目:
定数フィールド値

sizeMax

private long sizeMax
アップロードされるファイルに許可する最大サイズ。 -1 は上限が無いことを示します。
The maximum size permitted for an uploaded file. A value of -1 indicates no maximum.


headerEncoding

private String headerEncoding
パーツのヘッダを読み込む際に使用されるエンコーディング。
The content encoding to use when reading part headers.

コンストラクタの詳細

FileUploadBase

public FileUploadBase()
メソッドの詳細

isMultipartContent

public static final boolean isMultipartContent(javax.servlet.http.HttpServletRequest req)
リクエストが multipart content を含むかどうかを判断するユーティリティメソッドです。
Utility method that determines whether the request contains multipart content.

パラメータ:
req - 評価対象となるサーブレットリクエスト。null は受け付けません。
req The servlet request to be evaluated. Must be non-null.
戻り値:
true リクエストが multipart だった場合; false それ以外の場合。
true if the request is multipart; false otherwise.

getFileItemFactory

public abstract FileItemFactory getFileItemFactory()
ファイルアイテムを生成する際に使用するファクトリクラスを返します。
Returns the factory class used when creating file items.

戻り値:
ファイルアイテムを生成するファクトリクラス。
The factory class for new file items.

setFileItemFactory

public abstract void setFileItemFactory(FileItemFactory factory)
ファイルアイテムを生成する際に使用するファクトリクラスを設定します。
Sets the factory class to use when creating file items.

パラメータ:
factory - ファイルアイテムを生成するファクトリクラス。
factory The factory class for new file items.

getSizeMax

public long getSizeMax()
アップロードが許可される最大サイズを返します。
Returns the maximum allowed upload size.

戻り値:
許可されるバイト単位の最大サイズ。
The maximum allowed size, in bytes.
関連項目:
setSizeMax(long)

setSizeMax

public void setSizeMax(long sizeMax)
アップロードが許可される最大サイズを設定します。 負の数の場合、アップロードサイズの上限はありません。
Sets the maximum allowed upload size. If negative, there is no maximum.

パラメータ:
sizeMax - 許可されるバイト単位の最大サイズ。-1 の場合には上限なし。
sizeMax The maximum allowed size, in bytes, or -1 for no maximum.
関連項目:
getSizeMax()

getHeaderEncoding

public String getHeaderEncoding()
個々のパーツのヘッダを読み込む際に使用されるキャラクタエンコーディングを取得します。 設定されていない、もしくは null の場合、プラットフォームの デフォルトエンコーディングを使用します。
Retrieves the character encoding used when reading the headers of an individual part. When not specified, or null, the platform default encoding is used.

戻り値:
パーツのヘッダを読み込む際に使用されるエンコーディング。
The encoding used to read part headers.

setHeaderEncoding

public void setHeaderEncoding(String encoding)
個々のパーツのヘッダを読み込む際に使用されるキャラクタエンコーディングを設定します。 設定されていない、もしくは null の場合、プラットフォームの デフォルトエンコーディングを使用します。
Specifies the character encoding to be used when reading the headers of individual parts. When not specified, or null, the platform default encoding is used.

パラメータ:
encoding - パーツのヘッダを読み込む際に使用されるエンコーディング。
encoding The encoding used to read part headers.

parseRequest

public List parseRequest(javax.servlet.http.HttpServletRequest req)
                  throws FileUploadException
RFC 1867 の仕様に従って multipart/form-data のストリームを処理します。 ファイルがディスク上に保持される場合には getRepository() によってそのパスを取得することができます。
Processes an RFC 1867 compliant multipart/form-data stream. If files are stored on disk, the path is given by getRepository().

パラメータ:
req - 処理対象となるサーブレットリクエスト。
The servlet request to be parsed.
戻り値:
このリクエストを処理して生成された FileItem インスタンスのリスト。 送信された順番に並びます。
A list of FileItem instances parsed from the request, in the order that they were transmitted.
例外:
FileUploadException - リクエストの読み込み、処理またはファイルの保持にて 問題が発生した場合。
if there are problems reading/parsing the request or storing files.

getFileName

protected String getFileName(Map headers)
Content-disposition ヘッダからファイル名を取得します。
Retrieves the file name from the Content-disposition header.

パラメータ:
headers - HTTPリクエストヘッダの情報を内部に持つ Map
A Map containing the HTTP request headers.
戻り値:
現在の encapsulation のファイル名。
The file name for the current encapsulation.

getFieldName

protected String getFieldName(Map headers)
Content-disposition ヘッダからフィールド名を取得します。
Retrieves the field name from the Content-disposition header.

パラメータ:
headers - HTTPリクエストヘッダの情報を内部に持つ Map
A Map containing the HTTP request headers.
戻り値:
現在の encapsulation のフィールド名。
The field name for the current encapsulation.

createItem

protected FileItem createItem(Map headers,
                              boolean isFormField)
                       throws FileUploadException
新規 FileItem インスタンスを生成します。
Creates a new {@link FileItem} instance.

パラメータ:
headers - HTTPリクエストヘッダの情報を内部に持つ Map
A Map containing the HTTP request headers.
isFormField - このアイテムがファイルではなくフォームフィールドかどうか。
Whether or not this item is a form field, as opposed to a file.
戻り値:
新規に作成された FileItem インスタンス。
A newly created FileItem instance.
例外:
FileUploadException - エラーが発生した場合。
if an error occurs.

parseHeaders

protected Map parseHeaders(String headerPart)

header-part をパースし、キー/値 のペアを返します。

Parses the header-part and returns as key/value pairs.

同名のヘッダが複数あった場合、 その値はカンマで区切られたリストで格納されます。

If there are multiple headers of the same names, the name will map to a comma-separated list containing the values.

パラメータ:
headerPart - 現在の encapsulationheader-part
The header-part of the current encapsulation.
戻り値:
HTTPリクエストヘッダの情報を内部に持つ Map
A Map containing the parsed HTTP request headers.

getHeader

protected final String getHeader(Map headers,
                                 String name)
渡されたマップの中から指定された名称のヘッダの値を取得します。 ヘッダの参照時に大文字小文字は区別されません(case-insensitive)。
Returns the header with the specified name from the supplied map. The header lookup is case-insensitive.

パラメータ:
headers - HTTPリクエストヘッダの情報を内部に持つ Map
A Map containing the HTTP request headers.
name - データの取得対象となるヘッダの名称。
The name of the header to return.
戻り値:
指定されたヘッダの値。 同じ名前のヘッダが複数あった場合にはカンマで区切られたリスト。
The value of specified header, or a comma-separated list if there were multiple headers of that name.


このドキュメントは、Ja-Jakartaにより訳されました。 コメントがある場合は report@jajakarta.orgまでお願いします。
Translated into Japanese by jajakarta.org. The original page is here.
Copyright (c) 2002-2003 - Apache Software Foundation