クラス ResourceHttpMessageConverter
java.lang.ObjectSE
org.springframework.http.converter.AbstractHttpMessageConverter<Resource>
org.springframework.http.converter.ResourceHttpMessageConverter
- 実装されているすべてのインターフェース:
- HttpMessageConverter<Resource>
Resources の読み取り / 書き込みが可能で、バイト範囲リクエストをサポートする HttpMessageConverter の実装。 デフォルトでは、このコンバーターはすべてのメディア型を読み取ることができます。MediaTypeFactory は、書き込まれたリソースの Content-Type を判別するために使用されます。
- 導入:
- 3.0.2
- 作成者:
- Arjen Poutsma, Juergen Hoeller, Kazuki Shimizu
- フィールドのサマリー- クラス org.springframework.http.converter.AbstractHttpMessageConverter から継承されたフィールド- logger
- コンストラクターの概要コンストラクターコンストラクター説明読み取りストリーミングをサポートする- ResourceHttpMessageConverterの新しいインスタンスを作成します。- ResourceHttpMessageConverter- (boolean supportsReadStreaming) - ResourceHttpMessageConverterの新しいインスタンスを作成します。
- メソッドのサマリー修飾子と型メソッド説明- void- addDefaultHeaders- (HttpOutputMessage message, Resource resource, MediaType contentType) 指定されたリソースのデフォルトヘッダーを指定されたメッセージに追加します。- protected LongSE- getContentLength- (Resource resource, MediaType contentType) 指定された型のコンテンツの長さを返します。- protected MediaType- getDefaultContentType- (Resource resource) 指定された型のデフォルトのコンテンツ型を返します。- protected Resource- readInternal- (ClassSE<? extends Resource> clazz, HttpInputMessage inputMessage) 実際のオブジェクトを読み取る抽象テンプレートメソッド。- protected boolean指定されたクラスがこのコンバーターでサポートされているかどうかを示します。- protected boolean- supportsRepeatableWrites- (Resource resource) このメッセージコンバーターが指定されたオブジェクトを複数回書き込むことができるかどうかを示します。- protected void- writeContent- (Resource resource, HttpOutputMessage outputMessage) - protected void- writeInternal- (Resource resource, HttpOutputMessage outputMessage) 実際の本文を書き込む抽象テンプレートメソッド。- クラス org.springframework.http.converter.AbstractHttpMessageConverter から継承されたメソッド- addDefaultHeaders, canRead, canRead, canWrite, canWrite, getDefaultCharset, getSupportedMediaTypes, read, setDefaultCharset, setSupportedMediaTypes, write- クラス java.lang.ObjectSE から継承されたメソッド- clone, equalsSE, finalize, getClass, hashCode, notify, notifyAll, toString, wait, waitSE, waitSE- インターフェース org.springframework.http.converter.HttpMessageConverter から継承されたメソッド- getSupportedMediaTypes
- コンストラクターの詳細- ResourceHttpMessageConverterpublic ResourceHttpMessageConverter()読み取りストリーミングをサポートする- ResourceHttpMessageConverterの新しいインスタンスを作成します。つまり、- HttpInputMessageを- InputStreamResourceに変換できます。
- ResourceHttpMessageConverterpublic ResourceHttpMessageConverter- (boolean supportsReadStreaming) - ResourceHttpMessageConverterの新しいインスタンスを作成します。- パラメーター:
- supportsReadStreaming- コンバーターが読み取りストリーミングをサポートするかどうか、つまり- InputStreamResourceに変換するかどうか
- 導入:
- 5.0
 
 
- メソッドの詳細- supportsクラスからコピーされた説明:- AbstractHttpMessageConverter指定されたクラスがこのコンバーターでサポートされているかどうかを示します。- 次で指定:
-  クラス AbstractHttpMessageConverter<Resource>のsupports
- パラメーター:
- clazz- サポートをテストするクラス
- 戻り値:
-  サポートされている場合は true。それ以外の場合はfalse
 
- readInternalprotected Resource readInternal- (ClassSE<? extends Resource> clazz, HttpInputMessage inputMessage) throws IOExceptionSE, HttpMessageNotReadableException クラスからコピーされた説明:- AbstractHttpMessageConverter実際のオブジェクトを読み取る抽象テンプレートメソッド。- AbstractHttpMessageConverter.read(java.lang.Class<? extends T>, org.springframework.http.HttpInputMessage)から呼び出されます。- 次で指定:
-  クラス AbstractHttpMessageConverter<Resource>のreadInternal
- パラメーター:
- clazz- 返すオブジェクトの型
- inputMessage- 読み込む HTTP 入力メッセージ
- 戻り値:
- 変換されたオブジェクト
- 例外:
- IOExceptionSE- I/O エラーの場合
- HttpMessageNotReadableException- 変換エラーの場合
 
- getDefaultContentTypeクラスからコピーされた説明:- AbstractHttpMessageConverter指定された型のデフォルトのコンテンツ型を返します。指定されたコンテンツ型パラメーターなしで- AbstractHttpMessageConverter.write(T, org.springframework.http.MediaType, org.springframework.http.HttpOutputMessage)が呼び出されたときに呼び出されます。- デフォルトでは、 - supportedMediaTypesプロパティの最初の要素があれば、それを返します。サブクラスでオーバーライドできます。- オーバーライド:
-  クラス AbstractHttpMessageConverter<Resource>のgetDefaultContentType
- パラメーター:
- resource- コンテンツ型を返す型
- 戻り値:
-  コンテンツ型、または不明の場合は null
 
- getContentLengthprotected LongSE getContentLength- (Resource resource, @Nullable MediaType contentType) throws IOExceptionSE クラスからコピーされた説明:- AbstractHttpMessageConverter指定された型のコンテンツの長さを返します。- デフォルトでは、これは - nullを返します。これは、コンテンツの長さが不明であることを意味します。サブクラスでオーバーライドできます。- オーバーライド:
-  クラス AbstractHttpMessageConverter<Resource>のgetContentLength
- パラメーター:
- resource- コンテンツの長さを返す型
- 戻り値:
-  コンテンツの長さ、または不明の場合は null
- 例外:
- IOExceptionSE
 
- addDefaultHeaderspublic void addDefaultHeaders- (HttpOutputMessage message, Resource resource, @Nullable MediaType contentType) throws IOExceptionSE 指定されたリソースのデフォルトヘッダーを指定されたメッセージに追加します。- 例外:
- IOExceptionSE
- 導入:
- 6.0
 
- writeInternalprotected void writeInternal- (Resource resource, HttpOutputMessage outputMessage) throws IOExceptionSE, HttpMessageNotWritableException クラスからコピーされた説明:- AbstractHttpMessageConverter実際の本文を書き込む抽象テンプレートメソッド。- AbstractHttpMessageConverter.write(T, org.springframework.http.MediaType, org.springframework.http.HttpOutputMessage)から呼び出されます。- 次で指定:
-  クラス AbstractHttpMessageConverter<Resource>のwriteInternal
- パラメーター:
- resource- 出力メッセージに書き込むオブジェクト
- outputMessage- 書き込む HTTP 出力メッセージ
- 例外:
- IOExceptionSE- I/O エラーの場合
- HttpMessageNotWritableException- 変換エラーの場合
 
- writeContentprotected void writeContent- (Resource resource, HttpOutputMessage outputMessage) throws IOExceptionSE, HttpMessageNotWritableException 
- supportsRepeatableWritesクラスからコピーされた説明:- AbstractHttpMessageConverterこのメッセージコンバーターが指定されたオブジェクトを複数回書き込むことができるかどうかを示します。- デフォルトの実装は - falseを返します。- オーバーライド:
-  クラス AbstractHttpMessageConverter<Resource>のsupportsRepeatableWrites
- パラメーター:
- resource- オブジェクト t
- 戻り値:
-  tを繰り返し書き込める場合はtrue。それ以外の場合はfalse