クラス ProtobufHttpMessageConverter
java.lang.ObjectSE
org.springframework.http.converter.AbstractHttpMessageConverter<com.google.protobuf.Message>
org.springframework.http.converter.protobuf.ProtobufHttpMessageConverter
- 実装されているすべてのインターフェース:
HttpMessageConverter<com.google.protobuf.Message>
- 既知の直属サブクラス
ProtobufJsonFormatHttpMessageConverter
public class ProtobufHttpMessageConverter
extends AbstractHttpMessageConverter<com.google.protobuf.Message>
Google プロトコルバッファを使用して
com.google.protobuf.Messages を読み書きする HttpMessageConverter。Message Java クラスを生成するには、protoc バイナリをインストールする必要があります。
このコンバーターは、公式 "com.google.protobuf:protobuf-java" ライブラリを使用して、デフォルトで "application/x-protobuf" および "text/plain" をサポートします。"application/json" 形式は、"com.google.protobuf:protobuf-java-util" 依存関係でもサポートされます。構成可能なバリアントについては、ProtobufJsonFormatHttpMessageConverter を参照してください。
このコンバーターには、Spring Framework 6.1 以降、Protobuf 3 以降が必要です。
- 導入:
- 4.1
- 作成者:
- Alex Antonov, Brian Clozel, Juergen Hoeller, Sebastien Deleuze
- 関連事項:
JsonFormatProtobufJsonFormatHttpMessageConverter
フィールドのサマリー
フィールド修飾子と型フィールド説明static final CharsetSEコンバーターが使用するデフォルトの文字セット。static final MediaTypeprotobufapplication/x-protobufのメディア型。static final StringSEprotobuf メッセージを含む HTTP ヘッダー。static final StringSEprotobuf スキーマを含む HTTP ヘッダー。クラス org.springframework.http.converter.AbstractHttpMessageConverter から継承されたフィールド
loggerコンストラクターの概要
コンストラクターコンストラクター説明新しいProtobufHttpMessageConverterを作成します。ProtobufHttpMessageConverter(com.google.protobuf.ExtensionRegistry extensionRegistry) プロトコルメッセージ拡張を指定するレジストリを使用して、新しいProtobufHttpMessageConverterを構築します。メソッドのサマリー
修飾子と型メソッド説明protected boolean指定されたメディア型にサポートされているメディア型のいずれかが含まれている場合、trueを返します。protected MediaTypegetDefaultContentType(com.google.protobuf.Message message) 指定された型のデフォルトのコンテンツ型を返します。protected com.google.protobuf.MessagereadInternal(ClassSE<? extends com.google.protobuf.Message> clazz, HttpInputMessage inputMessage) 実際のオブジェクトを読み取る抽象テンプレートメソッド。protected boolean指定されたクラスがこのコンバーターでサポートされているかどうかを示します。protected booleansupportsRepeatableWrites(com.google.protobuf.Message message) このメッセージコンバーターが指定されたオブジェクトを複数回書き込むことができるかどうかを示します。protected voidwriteInternal(com.google.protobuf.Message message, HttpOutputMessage outputMessage) 実際の本文を書き込む抽象テンプレートメソッド。クラス org.springframework.http.converter.AbstractHttpMessageConverter から継承されたメソッド
addDefaultHeaders, canRead, canRead, canWrite, getContentLength, 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
フィールドの詳細
コンストラクターの詳細
ProtobufHttpMessageConverter
public ProtobufHttpMessageConverter()新しいProtobufHttpMessageConverterを作成します。ProtobufHttpMessageConverter
public ProtobufHttpMessageConverter(com.google.protobuf.ExtensionRegistry extensionRegistry) プロトコルメッセージ拡張を指定するレジストリを使用して、新しいProtobufHttpMessageConverterを構築します。- パラメーター:
extensionRegistry- 移入するレジストリ
メソッドの詳細
supports
クラスからコピーされた説明:AbstractHttpMessageConverter指定されたクラスがこのコンバーターでサポートされているかどうかを示します。- 次で指定:
- クラス
AbstractHttpMessageConverter<com.google.protobuf.Message>のsupports - パラメーター:
clazz- サポートをテストするクラス- 戻り値:
- サポートされている場合は
true。それ以外の場合はfalse
getDefaultContentType
クラスからコピーされた説明:AbstractHttpMessageConverter指定された型のデフォルトのコンテンツ型を返します。指定されたコンテンツ型パラメーターなしでAbstractHttpMessageConverter.write(T, org.springframework.http.MediaType, org.springframework.http.HttpOutputMessage)が呼び出されたときに呼び出されます。デフォルトでは、
supportedMediaTypesプロパティの最初の要素があれば、それを返します。サブクラスでオーバーライドできます。- オーバーライド:
- クラス
AbstractHttpMessageConverter<com.google.protobuf.Message>のgetDefaultContentType - パラメーター:
message- コンテンツ型を返す型- 戻り値:
- コンテンツ型、または不明の場合は
null
readInternal
protected com.google.protobuf.Message readInternal(ClassSE<? extends com.google.protobuf.Message> clazz, HttpInputMessage inputMessage) throws IOExceptionSE, HttpMessageNotReadableException クラスからコピーされた説明:AbstractHttpMessageConverter実際のオブジェクトを読み取る抽象テンプレートメソッド。AbstractHttpMessageConverter.read(java.lang.Class<? extends T>, org.springframework.http.HttpInputMessage)から呼び出されます。- 次で指定:
- クラス
AbstractHttpMessageConverter<com.google.protobuf.Message>のreadInternal - パラメーター:
clazz- 返すオブジェクトの型inputMessage- 読み込む HTTP 入力メッセージ- 戻り値:
- 変換されたオブジェクト
- 例外:
IOExceptionSE- I/O エラーの場合HttpMessageNotReadableException- 変換エラーの場合
canWrite
クラスからコピーされた説明:AbstractHttpMessageConverter指定されたメディア型にサポートされているメディア型のいずれかが含まれている場合、trueを返します。- オーバーライド:
- クラス
AbstractHttpMessageConverter<com.google.protobuf.Message>のcanWrite - パラメーター:
mediaType- 書き込むメディア型は、指定しない場合はnullにできます。通常、Acceptヘッダーの値。- 戻り値:
- サポートされているメディア型がメディア型と互換性がある場合、またはメディア型が
nullである場合は、true
writeInternal
protected void writeInternal(com.google.protobuf.Message message, HttpOutputMessage outputMessage) throws IOExceptionSE, HttpMessageNotWritableException クラスからコピーされた説明:AbstractHttpMessageConverter実際の本文を書き込む抽象テンプレートメソッド。AbstractHttpMessageConverter.write(T, org.springframework.http.MediaType, org.springframework.http.HttpOutputMessage)から呼び出されます。- 次で指定:
- クラス
AbstractHttpMessageConverter<com.google.protobuf.Message>のwriteInternal - パラメーター:
message- 出力メッセージに書き込むオブジェクトoutputMessage- 書き込む HTTP 出力メッセージ- 例外:
IOExceptionSE- I/O エラーの場合HttpMessageNotWritableException- 変換エラーの場合
supportsRepeatableWrites
protected boolean supportsRepeatableWrites(com.google.protobuf.Message message) クラスからコピーされた説明:AbstractHttpMessageConverterこのメッセージコンバーターが指定されたオブジェクトを複数回書き込むことができるかどうかを示します。デフォルトの実装は
falseを返します。- オーバーライド:
- クラス
AbstractHttpMessageConverter<com.google.protobuf.Message>のsupportsRepeatableWrites - パラメーター:
message- オブジェクト t- 戻り値:
-
tを繰り返し書き込める場合はtrue。それ以外の場合はfalse