public class MarshallingHttpMessageConverter extends AbstractXmlHttpMessageConverter<ObjectSE>
Marshaller および Unmarshaller 抽象化を使用して XML を読み書きできる HttpMessageConverter の実装。 このコンバーターを使用するには、Marshaller および Unmarshaller が必要です。これらは、コンストラクターまたは Bean プロパティによって注入できます。
デフォルトでは、このコンバーターは text/xml および application/xml をサポートしています。これは、supportedMediaTypes プロパティを設定することでオーバーライドできます。
logger| コンストラクターと説明 |
|---|
MarshallingHttpMessageConverter() |
MarshallingHttpMessageConverter(Marshaller marshaller) 指定された Marshaller セットで新しい MarshallingMessageConverter を構築します。 |
MarshallingHttpMessageConverter(Marshaller marshaller, Unmarshaller unmarshaller) 指定された Marshaller および Unmarshaller を使用して新しい MarshallingMessageConverter を構築します。 |
| 修飾子と型 | メソッドと説明 |
|---|---|
boolean | canRead(ClassSE<?> clazz, MediaType mediaType) この実装は、指定されたクラスがサポートされているかどうか、およびサポートされているメディア型 に指定されたメディア型が 含まれているかどうかをチェックします。 |
boolean | canWrite(ClassSE<?> clazz, MediaType mediaType) |
protected ObjectSE | readFromSource(ClassSE<?> clazz, HttpHeaders headers, SourceSE source)AbstractHttpMessageConverter.read(Class, HttpInputMessage) から呼び出される抽象テンプレートメソッド。 |
void | setMarshaller(Marshaller marshaller) このメッセージコンバーターで使用する Marshaller を設定します。 |
void | setUnmarshaller(Unmarshaller unmarshaller) このメッセージコンバーターで使用する Unmarshaller を設定します。 |
protected boolean | supports(ClassSE<?> clazz) 指定されたクラスがこのコンバーターでサポートされているかどうかを示します。 |
protected void | writeToResult(ObjectSE o, HttpHeaders headers, ResultSE result)AbstractXmlHttpMessageConverter.writeInternal(Object, HttpOutputMessage) から呼び出される抽象テンプレートメソッド。 |
readInternal, transform, writeInternaladdDefaultHeaders, canRead, canWrite, getContentLength, getDefaultCharset, getDefaultContentType, getSupportedMediaTypes, read, setDefaultCharset, setSupportedMediaTypes, writecloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSEgetSupportedMediaTypespublic MarshallingHttpMessageConverter()
Marshaller または Unmarshaller が設定されていない新しい MarshallingHttpMessageConverter を構築します。マーシャラーとアンマーシャラーは、構築後に setMarshaller(Marshaller) および setUnmarshaller(Unmarshaller) を呼び出して設定する必要があります。public MarshallingHttpMessageConverter(Marshaller marshaller)
Marshaller セットで新しい MarshallingMessageConverter を構築します。 指定された Marshaller が Unmarshaller インターフェースも実装している場合、マーシャリングとアンマーシャリングの両方に使用されます。そうでない場合、例外がスローされます。
Spring のすべての Marshaller 実装も Unmarshaller インターフェースを実装するため、このコンストラクターを安全に使用できることに注意してください。
marshaller - マーシャラーおよびアンマーシャラーとして使用されるオブジェクト public MarshallingHttpMessageConverter(Marshaller marshaller, Unmarshaller unmarshaller)
Marshaller および Unmarshaller を使用して新しい MarshallingMessageConverter を構築します。marshaller - 使用するマーシャラー unmarshaller - 使用するアンマーシャラー public void setMarshaller(Marshaller marshaller)
Marshaller を設定します。public void setUnmarshaller(Unmarshaller unmarshaller)
Unmarshaller を設定します。public boolean canRead(ClassSE<?> clazz, @Nullable MediaType mediaType)
AbstractHttpMessageConverterHttpMessageConverter<ObjectSE> の canRead AbstractHttpMessageConverter<ObjectSE> の canRead clazz - 読み込み可能性をテストするクラス mediaType - 読み取るメディア型(指定しない場合は null にできます); 通常、Content-Type ヘッダーの値。true。それ以外の場合は false public boolean canWrite(ClassSE<?> clazz, @Nullable MediaType mediaType)
AbstractHttpMessageConverterHttpMessageConverter<ObjectSE> の canWrite AbstractHttpMessageConverter<ObjectSE> の canWrite clazz - 書き込み可能性をテストするクラス mediaType - 書き込むメディア型(指定しない場合は null にすることができます); 通常、Accept ヘッダーの値。true。それ以外の場合は false protected boolean supports(ClassSE<?> clazz)
AbstractHttpMessageConverterAbstractHttpMessageConverter<ObjectSE> の supports clazz - サポートをテストするクラス true。それ以外の場合は false protected ObjectSE readFromSource(ClassSE<?> clazz, HttpHeaders headers, SourceSE source) throws ExceptionSE
AbstractXmlHttpMessageConverterAbstractHttpMessageConverter.read(Class, HttpInputMessage) から呼び出される抽象テンプレートメソッド。AbstractXmlHttpMessageConverter<ObjectSE> の readFromSource clazz - 返すオブジェクトの型 headers - HTTP 入力ヘッダー source - HTTP 入力本体 ExceptionSE - I/O または変換エラーの場合 protected void writeToResult(ObjectSE o, HttpHeaders headers, ResultSE result) throws ExceptionSE
AbstractXmlHttpMessageConverterAbstractXmlHttpMessageConverter.writeInternal(Object, HttpOutputMessage) から呼び出される抽象テンプレートメソッド。AbstractXmlHttpMessageConverter<ObjectSE> の writeToResult o - 出力メッセージに書き込むオブジェクト headers - HTTP 出力ヘッダー result - HTTP 出力本文 ExceptionSE - I/O または変換エラーの場合