クラス AbstractMarshaller

java.lang.ObjectSE
org.springframework.oxm.support.AbstractMarshaller
実装されたすべてのインターフェース:
MarshallerUnmarshaller
既知の直属サブクラス
XStreamMarshaller

public abstract class AbstractMarshaller extends ObjectSE implements Marshaller, Unmarshaller
Marshaller および Unmarshaller インターフェースの抽象実装。この実装は、指定された Source または Result をインスペクションし、さらに処理をオーバーライド可能なテンプレートメソッドに委譲します。
導入:
3.0
作成者:
Arjen Poutsma, Juergen Hoeller
  • フィールドの詳細

    • logger

      protected final Log logger
      サブクラスで利用可能なロガー。
  • コンストラクターの詳細

    • AbstractMarshaller

      public AbstractMarshaller()
  • メソッドの詳細

    • setSupportDtd

      public void setSupportDtd(boolean supportDtd)
      DTD 解析をサポートする必要があるかどうかを示します。

      デフォルトは false で、DTD が無効になっています。

    • isSupportDtd

      public boolean isSupportDtd()
      DTD 解析がサポートされているかどうかを返します。
    • setProcessExternalEntities

      public void setProcessExternalEntities(boolean processExternalEntities)
      非整列化時に外部 XML エンティティが処理されるかどうかを示します。

      デフォルトは false です。これは、外部エンティティが解決されないことを意味します。unmarshal(Source) に渡される Source が SAXSourceSE または StreamSourceSE である場合にのみ、外部エンティティの処理が有効または無効になることに注意してください。DOMSourceSE または StAXSourceSE インスタンスには影響しません。

      注意 : このオプションを true に設定すると、setSupportDtd(boolean) が true に自動的に設定されます。

    • isProcessExternalEntities

      public boolean isProcessExternalEntities()
      XML 外部エンティティが許可されているかどうかを返します。
      関連事項:
    • buildDocument

      protected DocumentSE buildDocument()
      DOM ノードのプレースホルダーとして、このマーシャラーの DocumentBuilderFactorySE から新しい DocumentSE を構築します。
      関連事項:
    • createDocumentBuilderFactory

      protected DocumentBuilderFactorySE createDocumentBuilderFactory() throws ParserConfigurationExceptionSE
      このマーシャラーが空の DOMSource を渡されたときに DOM ドキュメントを作成するために使用する DocumentBuilder を作成します。

      結果の DocumentBuilderFactory はキャッシュされるため、このメソッドは一度だけ呼び出されます。

      戻り値:
      DocumentBuilderFactory
      例外:
      ParserConfigurationExceptionSE - JAXP メソッドによってスローされた場合
    • createDocumentBuilder

      protected DocumentBuilderSE createDocumentBuilder(DocumentBuilderFactorySE factory) throws ParserConfigurationExceptionSE
      このマーシャラーが空の DOMSource を渡されたときに DOM ドキュメントを作成するために使用する DocumentBuilder を作成します。

      サブクラスでオーバーライドでき、ビルダーの初期化を追加します。

      パラメーター:
      factory - DocumentBuilder を作成する DocumentBuilderFactory 
      戻り値:
      DocumentBuilder
      例外:
      ParserConfigurationExceptionSE - JAXP メソッドによってスローされた場合
    • createXmlReader

      protected XMLReaderSE createXmlReader() throws SAXExceptionSE, ParserConfigurationExceptionSE
      このマーシャラーが空の SAXSource を渡されたときに XMLReader を作成します。
      戻り値:
      XMLReader
      例外:
      SAXExceptionSE - JAXP メソッドによってスローされた場合
      ParserConfigurationExceptionSE - JAXP メソッドによってスローされた場合
    • getDefaultEncoding

      @Nullable protected StringSE getDefaultEncoding()
      バイトストリームからのマーシャリングまたはアンマーシャリングに使用するデフォルトエンコーディングを決定します。存在しない場合は null を決定します。

      デフォルトの実装は null を返します。

    • marshal

      public final void marshal(ObjectSE graph, ResultSE result) throws IOExceptionSE, XmlMappingException
      指定されたルートを持つオブジェクトグラフを、提供された javax.xml.transform.Result にマーシャリングします。

      この実装は、指定された結果をインスペクションし、marshalDomResultmarshalSaxResultmarshalStreamResult を呼び出します。

      次で指定:
      インターフェース Marshallermarshal 
      パラメーター:
      graph - マーシャリングするオブジェクトグラフのルート
      result - マーシャリングする結果
      例外:
      IOExceptionSE - I/O 例外が発生した場合
      XmlMappingException - 指定されたオブジェクトを結果に整列化できない場合
      IllegalArgumentExceptionSE - result の場合 DOMResultSAXResultStreamResult のいずれでもない場合
      関連事項:
    • marshalDomResult

      protected void marshalDomResult(ObjectSE graph, DOMResultSE domResult) throws XmlMappingException
      DOMResult を処理するためのテンプレートメソッド。

      この実装は marshalDomNode に委譲します。

      パラメーター:
      graph - マーシャリングするオブジェクトグラフのルート
      domResult - DOMResult
      例外:
      XmlMappingException - 指定されたオブジェクトを結果に整列化できない場合
      IllegalArgumentExceptionSE - domResult が空の場合
      関連事項:
    • marshalStaxResult

      protected void marshalStaxResult(ObjectSE graph, ResultSE staxResult) throws XmlMappingException
      StaxResult を処理するためのテンプレートメソッド。

      この実装は、StaxResult の内容に応じて、marshalXMLSteamWriter または marshalXMLEventConsumer に委譲します。

      パラメーター:
      graph - マーシャリングするオブジェクトグラフのルート
      staxResult - JAXP 1.4 StAXSourceSE
      例外:
      XmlMappingException - 指定されたオブジェクトを結果に整列化できない場合
      IllegalArgumentExceptionSE - domResult が空の場合
      関連事項:
    • marshalSaxResult

      protected void marshalSaxResult(ObjectSE graph, SAXResultSE saxResult) throws XmlMappingException
      SAXResult を処理するためのテンプレートメソッド。

      この実装は marshalSaxHandlers に委譲します。

      パラメーター:
      graph - マーシャリングするオブジェクトグラフのルート
      saxResult - SAXResult
      例外:
      XmlMappingException - 指定されたオブジェクトを結果に整列化できない場合
      関連事項:
    • marshalStreamResult

      protected void marshalStreamResult(ObjectSE graph, StreamResultSE streamResult) throws XmlMappingException, IOExceptionSE
      StreamResult を処理するためのテンプレートメソッド。

      この実装は、StreamResult の内容に応じて、marshalOutputStream または marshalWriter に委譲します。

      パラメーター:
      graph - マーシャリングするオブジェクトグラフのルート
      streamResult - StreamResult
      例外:
      IOExceptionSE - I/O 例外が発生した場合
      XmlMappingException - 指定されたオブジェクトを結果に整列化できない場合
      IllegalArgumentExceptionSE - streamResult に OutputStream も Writer も含まれていない場合
    • unmarshal

      public final ObjectSE unmarshal(SourceSE source) throws IOExceptionSE, XmlMappingException
      指定された提供された javax.xml.transform.Source をオブジェクトグラフに非整列化します。

      この実装は、指定された結果をインスペクションし、unmarshalDomSourceunmarshalSaxSourceunmarshalStreamSource を呼び出します。

      次で指定:
      インターフェース Unmarshallerunmarshal 
      パラメーター:
      source - マーシャリングのソース
      戻り値:
      オブジェクトグラフ
      例外:
      IOExceptionSE - I/O 例外が発生した場合
      XmlMappingException - 指定されたソースをオブジェクトにマップできない場合
      IllegalArgumentExceptionSE - source が DOMSourceSAXSourceStreamSource でない場合
      関連事項:
    • unmarshalDomSource

      protected ObjectSE unmarshalDomSource(DOMSourceSE domSource) throws XmlMappingException
      DOMSource を処理するためのテンプレートメソッド。

      この実装は unmarshalDomNode に委譲します。指定されたソースが空の場合、空のソース Document がプレースホルダーとして作成されます。

      パラメーター:
      domSource - DOMSource
      戻り値:
      オブジェクトグラフ
      例外:
      XmlMappingException - 指定されたソースをオブジェクトにマップできない場合
      IllegalArgumentExceptionSE - domSource が空の場合
      関連事項:
    • unmarshalStaxSource

      protected ObjectSE unmarshalStaxSource(SourceSE staxSource) throws XmlMappingException
      StaxSource を処理するためのテンプレートメソッド。

      この実装は unmarshalXmlStreamReader または unmarshalXmlEventReader に委譲します。

      パラメーター:
      staxSource - StaxSource
      戻り値:
      オブジェクトグラフ
      例外:
      XmlMappingException - 指定されたソースをオブジェクトにマップできない場合
    • unmarshalSaxSource

      protected ObjectSE unmarshalSaxSource(SAXSourceSE saxSource) throws XmlMappingException, IOExceptionSE
      SAXSource を処理するためのテンプレートメソッド。

      この実装は unmarshalSaxReader に委譲します。

      パラメーター:
      saxSource - SAXSource
      戻り値:
      オブジェクトグラフ
      例外:
      XmlMappingException - 指定されたソースをオブジェクトにマップできない場合
      IOExceptionSE - I/O 例外が発生した場合
      関連事項:
    • unmarshalStreamSource

      protected ObjectSE unmarshalStreamSource(StreamSourceSE streamSource) throws XmlMappingException, IOExceptionSE
      StreamSource を処理するためのテンプレートメソッド。

      この実装は unmarshalInputStream または unmarshalReader に委譲します。

      パラメーター:
      streamSource - StreamSource
      戻り値:
      オブジェクトグラフ
      例外:
      IOExceptionSE - I/O 例外が発生した場合
      XmlMappingException - 指定されたソースをオブジェクトにマップできない場合
    • marshalDomNode

      protected abstract void marshalDomNode(ObjectSE graph, NodeSE node) throws XmlMappingException
      指定されたオブジェクトグラフを DOM Node にマーシャリングする抽象テンプレートメソッド。

      実際には、node は Document ノード、DocumentFragment ノード、Element ノードです。つまり、子を受け入れるノードです。

      パラメーター:
      graph - マーシャリングするオブジェクトグラフのルート
      node - 結果ツリーを含む DOM ノード
      例外:
      XmlMappingException - 指定されたオブジェクトを DOM ノードに整列化できない場合
      関連事項:
    • marshalXmlEventWriter

      protected abstract void marshalXmlEventWriter(ObjectSE graph, XMLEventWriterSE eventWriter) throws XmlMappingException
      指定されたオブジェクトを StAX XMLEventWriter にマーシャリングする抽象テンプレートメソッド。
      パラメーター:
      graph - マーシャリングするオブジェクトグラフのルート
      eventWriter - 書き込む XMLEventWriter 
      例外:
      XmlMappingException - 指定されたオブジェクトを DOM ノードに整列化できない場合
    • marshalXmlStreamWriter

      protected abstract void marshalXmlStreamWriter(ObjectSE graph, XMLStreamWriterSE streamWriter) throws XmlMappingException
      指定されたオブジェクトを StAX XMLStreamWriter にマーシャリングする抽象テンプレートメソッド。
      パラメーター:
      graph - マーシャリングするオブジェクトグラフのルート
      streamWriter - 書き込む XMLStreamWriter 
      例外:
      XmlMappingException - 指定されたオブジェクトを DOM ノードに整列化できない場合
    • marshalSaxHandlers

      protected abstract void marshalSaxHandlers(ObjectSE graph, ContentHandlerSE contentHandler, @Nullable LexicalHandlerSE lexicalHandler) throws XmlMappingException
      指定されたオブジェクトグラフを SAX ContentHandler にマーシャリングする抽象テンプレートメソッド。
      パラメーター:
      graph - マーシャリングするオブジェクトグラフのルート
      contentHandler - SAX ContentHandler
      lexicalHandler - SAX2 LexicalHandlernull にすることができます。
      例外:
      XmlMappingException - 指定されたオブジェクトをハンドラーにマーシャリングできない場合
    • marshalOutputStream

      protected abstract void marshalOutputStream(ObjectSE graph, OutputStreamSE outputStream) throws XmlMappingException, IOExceptionSE
      指定されたオブジェクトグラフを OutputStream にマーシャリングする抽象テンプレートメソッド。
      パラメーター:
      graph - マーシャリングするオブジェクトグラフのルート
      outputStream - 書き込む OutputStream 
      例外:
      XmlMappingException - 指定されたオブジェクトをライターにマーシャリングできない場合
      IOExceptionSE - I/O 例外が発生した場合
    • marshalWriter

      protected abstract void marshalWriter(ObjectSE graph, WriterSE writer) throws XmlMappingException, IOExceptionSE
      指定されたオブジェクトグラフを Writer にマーシャリングする抽象テンプレートメソッド。
      パラメーター:
      graph - マーシャリングするオブジェクトグラフのルート
      writer - 書き込む Writer 
      例外:
      XmlMappingException - 指定されたオブジェクトをライターにマーシャリングできない場合
      IOExceptionSE - I/O 例外が発生した場合
    • unmarshalDomNode

      protected abstract ObjectSE unmarshalDomNode(NodeSE node) throws XmlMappingException
      指定された DOM Node から非整列化するための抽象テンプレートメソッド。
      パラメーター:
      node - 非整列化するオブジェクトを含む DOM ノード
      戻り値:
      オブジェクトグラフ
      例外:
      XmlMappingException - 指定された DOM ノードをオブジェクトにマップできない場合
    • unmarshalXmlEventReader

      protected abstract ObjectSE unmarshalXmlEventReader(XMLEventReaderSE eventReader) throws XmlMappingException
      指定された Stax XMLEventReader から非整列化するための抽象テンプレートメソッド。
      パラメーター:
      eventReader - 読み込む XMLEventReader 
      戻り値:
      オブジェクトグラフ
      例外:
      XmlMappingException - 指定されたイベントリーダーをオブジェクトに変換できない場合
    • unmarshalXmlStreamReader

      protected abstract ObjectSE unmarshalXmlStreamReader(XMLStreamReaderSE streamReader) throws XmlMappingException
      指定された Stax XMLStreamReader から非整列化するための抽象テンプレートメソッド。
      パラメーター:
      streamReader - 読み込む XMLStreamReader 
      戻り値:
      オブジェクトグラフ
      例外:
      XmlMappingException - 指定されたストリームリーダーをオブジェクトに変換できない場合
    • unmarshalSaxReader

      protected abstract ObjectSE unmarshalSaxReader(XMLReaderSE xmlReader, InputSourceSE inputSource) throws XmlMappingException, IOExceptionSE
      特定の SAX XMLReader および InputSource を使用して非整列化するための抽象テンプレートメソッド。
      パラメーター:
      xmlReader - 解析する SAX XMLReader 
      inputSource - 解析する入力ソース
      戻り値:
      オブジェクトグラフ
      例外:
      XmlMappingException - 指定されたリーダーと入力ソースをオブジェクトに変換できない場合
      IOExceptionSE - I/O 例外が発生した場合
    • unmarshalInputStream

      protected abstract ObjectSE unmarshalInputStream(InputStreamSE inputStream) throws XmlMappingException, IOExceptionSE
      指定された InputStream から非整列化するための抽象テンプレートメソッド。
      パラメーター:
      inputStream - 読み込む InputStreamStream 
      戻り値:
      オブジェクトグラフ
      例外:
      XmlMappingException - 指定されたストリームをオブジェクトに変換できない場合
      IOExceptionSE - I/O 例外が発生した場合
    • unmarshalReader

      protected abstract ObjectSE unmarshalReader(ReaderSE reader) throws XmlMappingException, IOExceptionSE
      指定された Reader から非整列化するための抽象テンプレートメソッド。
      パラメーター:
      reader - 読み込む Reader 
      戻り値:
      オブジェクトグラフ
      例外:
      XmlMappingException - 指定されたリーダーをオブジェクトに変換できない場合
      IOExceptionSE - I/O 例外が発生した場合