クラス 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の新しいインスタンスを作成します。メソッドのサマリー
修飾子と型メソッド説明voidaddDefaultHeaders(HttpOutputMessage message, Resource resource, MediaType contentType) 指定されたリソースのデフォルトヘッダーを指定されたメッセージに追加します。protected LongSEgetContentLength(Resource resource, MediaType contentType) 指定された型のコンテンツの長さを返します。protected MediaTypegetDefaultContentType(Resource resource) 指定された型のデフォルトのコンテンツ型を返します。protected ResourcereadInternal(ClassSE<? extends Resource> clazz, HttpInputMessage inputMessage) 実際のオブジェクトを読み取る抽象テンプレートメソッド。protected boolean指定されたクラスがこのコンバーターでサポートされているかどうかを示します。protected booleansupportsRepeatableWrites(Resource resource) このメッセージコンバーターが指定されたオブジェクトを複数回書き込むことができるかどうかを示します。protected voidwriteContent(Resource resource, HttpOutputMessage outputMessage) protected voidwriteInternal(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
コンストラクターの詳細
ResourceHttpMessageConverter
public ResourceHttpMessageConverter()読み取りストリーミングをサポートするResourceHttpMessageConverterの新しいインスタンスを作成します。つまり、HttpInputMessageをInputStreamResourceに変換できます。ResourceHttpMessageConverter
public ResourceHttpMessageConverter(boolean supportsReadStreaming) ResourceHttpMessageConverterの新しいインスタンスを作成します。- パラメーター:
supportsReadStreaming- コンバーターが読み取りストリーミングをサポートするかどうか、つまりInputStreamResourceに変換するかどうか- 導入:
- 5.0
メソッドの詳細
supports
クラスからコピーされた説明:AbstractHttpMessageConverter指定されたクラスがこのコンバーターでサポートされているかどうかを示します。- 次で指定:
- クラス
AbstractHttpMessageConverter<Resource>のsupports - パラメーター:
clazz- サポートをテストするクラス- 戻り値:
- サポートされている場合は
true。それ以外の場合はfalse
readInternal
protected 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- 変換エラーの場合
writeInternal
protected 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- 変換エラーの場合
addDefaultHeaders
public void addDefaultHeaders(HttpOutputMessage message, Resource resource, @Nullable MediaType contentType) throws IOExceptionSE 指定されたリソースのデフォルトヘッダーを指定されたメッセージに追加します。- 例外:
IOExceptionSE- 導入:
- 6.0
getDefaultContentType
クラスからコピーされた説明:AbstractHttpMessageConverter指定された型のデフォルトのコンテンツ型を返します。指定されたコンテンツ型パラメーターなしでAbstractHttpMessageConverter.write(T, org.springframework.http.MediaType, org.springframework.http.HttpOutputMessage)が呼び出されたときに呼び出されます。デフォルトでは、
supportedMediaTypesプロパティの最初の要素があれば、それを返します。サブクラスでオーバーライドできます。- オーバーライド:
- クラス
AbstractHttpMessageConverter<Resource>のgetDefaultContentType - パラメーター:
resource- コンテンツ型を返す型- 戻り値:
- コンテンツ型、または不明の場合は
null
getContentLength
@Nullable protected LongSE getContentLength(Resource resource, @Nullable MediaType contentType) throws IOExceptionSE クラスからコピーされた説明:AbstractHttpMessageConverter指定された型のコンテンツの長さを返します。デフォルトでは、これは
nullを返します。これは、コンテンツの長さが不明であることを意味します。サブクラスでオーバーライドできます。- オーバーライド:
- クラス
AbstractHttpMessageConverter<Resource>のgetContentLength - パラメーター:
resource- コンテンツの長さを返す型- 戻り値:
- コンテンツの長さ、または不明の場合は
null - 例外:
IOExceptionSE
supportsRepeatableWrites
クラスからコピーされた説明:AbstractHttpMessageConverterこのメッセージコンバーターが指定されたオブジェクトを複数回書き込むことができるかどうかを示します。デフォルトの実装は
falseを返します。- オーバーライド:
- クラス
AbstractHttpMessageConverter<Resource>のsupportsRepeatableWrites - パラメーター:
resource- オブジェクト t- 戻り値:
-
tを繰り返し書き込める場合はtrue。それ以外の場合はfalse
writeContent
protected void writeContent(Resource resource, HttpOutputMessage outputMessage) throws IOExceptionSE, HttpMessageNotWritableException