クラス 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"、"application/*+x-protobuf"、"text/plain" をサポートします。"application/json" 形式も "com.google.protobuf:protobuf-java-util" 依存関係でサポートされています。設定可能なバリアントについては、ProtobufJsonFormatHttpMessageConverter を参照してください。
このコンバーターには Protobuf 3 以上が必要です。
- 導入:
- 4.1
- 作成者:
- Alex Antonov, Brian Clozel, Juergen Hoeller, Sebastien Deleuze, Kamil Doroszkiewicz
- 関連事項:
ネストされたクラスの要約
ネストされたクラス修飾子と型クラス説明protected static interfaceサブクラスが追加の形式のサポートをプラグインできるようにする契約。フィールドのサマリー
フィールド修飾子と型フィールド説明static final CharsetSEコンバーターが使用するデフォルトの文字セット。static final MediaTypeprotobufapplication/*+x-protobufのメディア型。static final MediaTypeprotobufapplication/x-protobufのメディア型。static final StringSEprotobuf メッセージを含む HTTP ヘッダー。static final StringSEprotobuf スキーマを含む HTTP ヘッダー。クラス AbstractHttpMessageConverter から継承されたフィールド
loggerコンストラクターの概要
コンストラクター修飾子コンストラクター説明新しいProtobufHttpMessageConverterを作成します。ProtobufHttpMessageConverter(com.google.protobuf.ExtensionRegistry extensionRegistry) プロトコルメッセージ拡張を指定するレジストリを使用して、新しいProtobufHttpMessageConverterを構築します。protectedProtobufHttpMessageConverter(@Nullable ProtobufHttpMessageConverter.ProtobufFormatDelegate formatDelegate, @Nullable com.google.protobuf.ExtensionRegistry extensionRegistry) 追加の形式をサポートするサブクラスのコンストラクター。方法の概要
修飾子と型メソッド説明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) 実際の本文を書き込む抽象テンプレートメソッド。クラス AbstractHttpMessageConverter から継承されたメソッド
addDefaultHeaders, canRead, canRead, canWrite, getContentLength, getDefaultCharset, getSupportedMediaTypes, read, setDefaultCharset, setSupportedMediaTypes, writeクラス ObjectSE から継承されたメソッド
clone, equalsSE, finalize, getClass, hashCode, notify, notifyAll, toString, wait, waitSE, waitSEインターフェース HttpMessageConverter から継承されたメソッド
getSupportedMediaTypes
フィールドの詳細
DEFAULT_CHARSET
コンバーターが使用するデフォルトの文字セット。PROTOBUF
protobufapplication/x-protobufのメディア型。PLUS_PROTOBUF
protobufapplication/*+x-protobufのメディア型。X_PROTOBUF_SCHEMA_HEADER
X_PROTOBUF_MESSAGE_HEADER
コンストラクターの詳細
ProtobufHttpMessageConverter
public ProtobufHttpMessageConverter()新しいProtobufHttpMessageConverterを作成します。ProtobufHttpMessageConverter
public ProtobufHttpMessageConverter(com.google.protobuf.ExtensionRegistry extensionRegistry) プロトコルメッセージ拡張を指定するレジストリを使用して、新しいProtobufHttpMessageConverterを構築します。- パラメーター:
extensionRegistry- 移入するレジストリ
ProtobufHttpMessageConverter
protected ProtobufHttpMessageConverter(@Nullable ProtobufHttpMessageConverter.ProtobufFormatDelegate formatDelegate, @Nullable com.google.protobuf.ExtensionRegistry extensionRegistry) 追加の形式をサポートするサブクラスのコンストラクター。- パラメーター:
formatDelegate- 追加の形式の読み取りと書き込みを委譲するextensionRegistry- 移入するレジストリ
メソッドの詳細
supports
クラスからコピーされた説明:AbstractHttpMessageConverter指定されたクラスがこのコンバーターでサポートされているかどうかを示します。- 次で指定:
- クラス
AbstractHttpMessageConverter<com.google.protobuf.Message>のsupports - パラメーター:
clazz- サポートをテストするクラス- 戻り値:
- サポートされている場合は
true。それ以外の場合はfalse
getDefaultContentType
クラスからコピーされた説明:AbstractHttpMessageConverter指定された型のデフォルトのコンテンツ型を返します。指定されたコンテンツ型パラメーターなしでAbstractHttpMessageConverter.write(T, MediaType, 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(Class, 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, MediaType, 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