クラス 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
- 関連事項:
- JsonFormat
- ProtobufJsonFormatHttpMessageConverter
 
- フィールドのサマリーフィールド修飾子と型フィールド説明- static final CharsetSEコンバーターが使用するデフォルトの文字セット。- static final MediaTypeprotobuf- application/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 MediaType- getDefaultContentType- (com.google.protobuf.Message message) 指定された型のデフォルトのコンテンツ型を返します。- protected com.google.protobuf.Message- readInternal- (ClassSE<? extends com.google.protobuf.Message> clazz, HttpInputMessage inputMessage) 実際のオブジェクトを読み取る抽象テンプレートメソッド。- protected boolean指定されたクラスがこのコンバーターでサポートされているかどうかを示します。- protected boolean- supportsRepeatableWrites- (com.google.protobuf.Message message) このメッセージコンバーターが指定されたオブジェクトを複数回書き込むことができるかどうかを示します。- protected void- writeInternal- (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
- フィールドの詳細
- コンストラクターの詳細- ProtobufHttpMessageConverterpublic ProtobufHttpMessageConverter()新しい- ProtobufHttpMessageConverterを作成します。
- ProtobufHttpMessageConverterpublic 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
 
- readInternalprotected 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
 
- writeInternalprotected 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- 変換エラーの場合
 
- supportsRepeatableWritesprotected boolean supportsRepeatableWrites- (com.google.protobuf.Message message) クラスからコピーされた説明:- AbstractHttpMessageConverterこのメッセージコンバーターが指定されたオブジェクトを複数回書き込むことができるかどうかを示します。- デフォルトの実装は - falseを返します。- オーバーライド:
-  クラス AbstractHttpMessageConverter<com.google.protobuf.Message>のsupportsRepeatableWrites
- パラメーター:
- message- オブジェクト t
- 戻り値:
-  tを繰り返し書き込める場合はtrue。それ以外の場合はfalse