クラス 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 MediaType
protobufapplication/x-protobuf
のメディア型。static final StringSE
protobuf メッセージを含む HTTP ヘッダー。static final StringSE
protobuf スキーマを含む 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
フィールドの詳細
コンストラクターの詳細
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