Package nablarch.common.web.download
Class FileResponse
java.lang.Object
nablarch.fw.web.HttpResponse
nablarch.common.web.download.FileResponse
- All Implemented Interfaces:
Result
FileオブジェクトからHTTPレスポンスを生成するHttpResponse継承クラス。- Author:
- Naoki Yamamoto
-
Nested Class Summary
Nested classes/interfaces inherited from class nablarch.fw.web.HttpResponse
HttpResponse.StatusNested classes/interfaces inherited from interface nablarch.fw.Result
Result.ClientError, Result.Error, Result.MultiStatus, Result.NotFound, Result.Success -
Field Summary
Fields inherited from class nablarch.fw.web.HttpResponse
CONTENT_DISPOSITION, LS -
Constructor Summary
ConstructorsConstructorDescriptionFileResponse(File file) コンストラクタ。FileResponse(File file, boolean deleteOnCleanup) コンストラクタ。 -
Method Summary
Modifier and TypeMethodDescriptioncleanup()リソースを開放する。HTTPレスポンスボディの内容を保持するストリームを取得する。HTTPレスポンスボディの内容を表す文字列を返す。Content-Lengthの値を取得する。コンテンツパスを取得する。booleanHTTPレスポンスボディの内容が設定されていなければtrueを返す。setBodyStream(InputStream bodyStream) HTTPレスポンスボディの内容を保持するストリームを設定する。setContentPath(String path) コンテンツパスを設定する。setContentPath(ResourceLocator resource) コンテンツパスを設定する。toString()オブジェクトの内容と等価なHTTPレスポンスメッセージを返す。write(byte[] bytes) HTTPレスポンスボディにバイト配列を書き込む。write(CharSequence text) HTTPレスポンスボディに文字列を書き込む。write(ByteBuffer bytes) HTTPレスポンスボディにバイト配列を書き込む。Methods inherited from class nablarch.fw.web.HttpResponse
addCookie, getCharset, getContentDisposition, getContentType, getCookie, getCookieList, getHeader, getHeaderMap, getHttpCookies, getHttpVersion, getLocation, getMessage, getReasonPhrase, getStatusCode, getTransferEncoding, isSuccess, parse, parse, setContentDisposition, setContentDisposition, setContentType, setCookie, setHeader, setHttpVersion, setLocation, setStatusCode, setTransferEncoding
-
Constructor Details
-
FileResponse
コンストラクタ。 本コンストラクタを使用してインスタンスを生成した場合、 リクエスト処理の終了時に自動的にファイルは削除されない。- Parameters:
file- ファイル
-
FileResponse
コンストラクタ。- Parameters:
file- ファイルdeleteOnCleanup- リクエスト処理の終了時に自動的にファイルを削除する場合はtrue
-
-
Method Details
-
getContentLength
Description copied from class:HttpResponseContent-Lengthの値を取得する。 HTTPレスポンスボディの内容がこのオブジェクト自体に保持されている場合に限り、 そのバイト数を返す。
それ以外はnullを返す。- Overrides:
getContentLengthin classHttpResponse- Returns:
- Content-Lengthの値
-
isBodyEmpty
- Overrides:
isBodyEmptyin classHttpResponse- Returns:
- 必ず{@link false}を返す
-
getBodyString
Description copied from class:HttpResponseHTTPレスポンスボディの内容を表す文字列を返す。- Overrides:
getBodyStringin classHttpResponse- Returns:
- ボディの内容を表す文字列を返す
-
getBodyStream
Description copied from class:HttpResponseHTTPレスポンスボディの内容を保持するストリームを取得する。- Overrides:
getBodyStreamin classHttpResponse- Returns:
- HTTPレスポンスボディの内容を保持するストリーム
-
toString
Description copied from class:HttpResponseオブジェクトの内容と等価なHTTPレスポンスメッセージを返す。- Overrides:
toStringin classHttpResponse
-
cleanup
Description copied from class:HttpResponseリソースを開放する。- Overrides:
cleanupin classHttpResponse- Returns:
- 本オブジェクト
-
getContentPath
コンテンツパスを取得する。 HTTPレスポンスボディに書き込むコンテンツパスを取得する。 本クラスではコンテンツパスを設定できないため、 本メソッドは必ずnullを返す。- Overrides:
getContentPathin classHttpResponse- Returns:
- 必ず
nullを返す。
-
setBodyStream
Description copied from class:HttpResponseHTTPレスポンスボディの内容を保持するストリームを設定する。- Overrides:
setBodyStreamin classHttpResponse- Parameters:
bodyStream- HTTPレスポンスボディの内容を保持するストリーム- Returns:
- 本オブジェクト
-
setContentPath
Description copied from class:HttpResponseコンテンツパスを設定する。 本処理はHttpResponse.setContentPath(ResourceLocator)に委譲する。- Overrides:
setContentPathin classHttpResponse- Parameters:
path- コンテンツパス- Returns:
- 本オブジェクト
-
setContentPath
Description copied from class:HttpResponseコンテンツパスを設定する。 指定したResourceLocatorオブジェクトがnullでない場合は、 リソース名からContent-Typeを自動的に設定した後、コンテンツパスを設定する。
ResourceLocatorオブジェクトがnullの場合は、コンテンツパスのみ設定する。- Overrides:
setContentPathin classHttpResponse- Parameters:
resource- コンテンツパス- Returns:
- 本オブジェクト
- See Also:
-
write
Description copied from class:HttpResponseHTTPレスポンスボディに文字列を書き込む。 このメソッドで書き込まれたデータは、本オブジェクトが保持する バッファに保持され、クライアントソケットに対する書き込みは一切発生しない。 (このライタに対するflush()は単に無視される。)
実際にソケットに対するレスポンス処理が行われるのは、HttpResponseHandlerにレスポンスオブジェクトが戻された後である。 また、このオブジェクトにコンテンツパスが設定されている場合、 このライタに書き込まれた内容は単に無視される。- Overrides:
writein classHttpResponse- Parameters:
text- 書き込む文字列- Returns:
- 本オブジェクト
-
write
Description copied from class:HttpResponseHTTPレスポンスボディにバイト配列を書き込む。 このメソッドで書き込まれたデータは、本オブジェクトが保持する バッファに保持され、クライアントソケットに対する書き込みは一切発生しない。 (このライタに対するflush()は単に無視される。)
実際にソケットに対するレスポンス処理が行われるのは、HttpResponseHandlerにレスポンスオブジェクトが戻された後である。 また、このオブジェクトにコンテンツパスが設定されている場合、 このライタに書き込まれた内容は単に無視される。- Overrides:
writein classHttpResponse- Parameters:
bytes- 書き込むバイト配列- Returns:
- 本オブジェクト
-
write
Description copied from class:HttpResponseHTTPレスポンスボディにバイト配列を書き込む。 このメソッドで書き込まれたデータは、本オブジェクトが保持する バッファに保持され、クライアントソケットに対する書き込みは一切発生しない。 (このライタに対するflush()は単に無視される。)
実際にソケットに対するレスポンス処理が行われるのは、HttpResponseHandlerにレスポンスオブジェクトが戻された後である。 また、このオブジェクトにコンテンツパスが設定されている場合、 このライタに書き込まれた内容は単に無視される。- Overrides:
writein classHttpResponse- Parameters:
bytes- 書き込むバイト列を格納したバッファ- Returns:
- 本オブジェクト
-