public abstract class AbstractMarshaller extends ObjectSE implements Marshaller, Unmarshaller
Marshaller
および Unmarshaller
インターフェースの抽象実装。この実装は、指定された Source
または Result
をインスペクションし、さらに処理をオーバーライド可能なテンプレートメソッドに委譲します。コンストラクターと説明 |
---|
AbstractMarshaller() |
修飾子と型 | メソッドと説明 |
---|---|
protected DocumentSE | buildDocument() DOM ノードのプレースホルダーとして、このマーシャラーの DocumentBuilderFactory SE から新しい Document SE を構築します。 |
protected DocumentBuilderSE | createDocumentBuilder(DocumentBuilderFactorySE factory) このマーシャラーが空の DOMSource を渡されたときに DOM ドキュメントを作成するために使用する DocumentBuilder を作成します。 |
protected DocumentBuilderFactorySE | createDocumentBuilderFactory() このマーシャラーが空の DOMSource を渡されたときに DOM ドキュメントを作成するために使用する DocumentBuilder を作成します。 |
protected XMLReaderSE | createXmlReader() このマーシャラーが空の SAXSource を渡されたときに XMLReader を作成します。 |
protected StringSE | getDefaultEncoding() バイトストリームからのマーシャリングまたはアンマーシャリングに使用するデフォルトエンコーディングを決定します。存在しない場合は null を決定します。 |
boolean | isProcessExternalEntities() XML 外部エンティティが許可されているかどうかを返します。 |
boolean | isSupportDtd() DTD 解析がサポートされているかどうかを返します。 |
void | marshal(ObjectSE graph, ResultSE result) 指定されたルートを持つオブジェクトグラフを、提供された javax.xml.transform.Result にマーシャリングします。 |
protected abstract void | marshalDomNode(ObjectSE graph, NodeSE node) 指定されたオブジェクトグラフを DOM Node にマーシャリングする抽象テンプレートメソッド。 |
protected void | marshalDomResult(ObjectSE graph, DOMResultSE domResult) DOMResult を処理するためのテンプレートメソッド。 |
protected abstract void | marshalOutputStream(ObjectSE graph, OutputStreamSE outputStream) 指定されたオブジェクトグラフを OutputStream にマーシャリングする抽象テンプレートメソッド。 |
protected abstract void | marshalSaxHandlers(ObjectSE graph, ContentHandlerSE contentHandler, LexicalHandlerSE lexicalHandler) 指定されたオブジェクトグラフを SAX ContentHandler にマーシャリングする抽象テンプレートメソッド。 |
protected void | marshalSaxResult(ObjectSE graph, SAXResultSE saxResult) SAXResult を処理するためのテンプレートメソッド。 |
protected void | marshalStaxResult(ObjectSE graph, ResultSE staxResult) StaxResult を処理するためのテンプレートメソッド。 |
protected void | marshalStreamResult(ObjectSE graph, StreamResultSE streamResult) StreamResult を処理するためのテンプレートメソッド。 |
protected abstract void | marshalWriter(ObjectSE graph, WriterSE writer) 指定されたオブジェクトグラフを Writer にマーシャリングする抽象テンプレートメソッド。 |
protected abstract void | marshalXmlEventWriter(ObjectSE graph, XMLEventWriterSE eventWriter) 指定されたオブジェクトを StAX XMLEventWriter にマーシャリングする抽象テンプレートメソッド。 |
protected abstract void | marshalXmlStreamWriter(ObjectSE graph, XMLStreamWriterSE streamWriter) 指定されたオブジェクトを StAX XMLStreamWriter にマーシャリングする抽象テンプレートメソッド。 |
void | setProcessExternalEntities(boolean processExternalEntities) 非整列化時に外部 XML エンティティが処理されるかどうかを示します。 |
void | setSupportDtd(boolean supportDtd) DTD 解析をサポートする必要があるかどうかを示します。 |
ObjectSE | unmarshal(SourceSE source) 指定された提供された javax.xml.transform.Source をオブジェクトグラフに非整列化します。 |
protected abstract ObjectSE | unmarshalDomNode(NodeSE node) 指定された DOM Node から非整列化するための抽象テンプレートメソッド。 |
protected ObjectSE | unmarshalDomSource(DOMSourceSE domSource) DOMSource を処理するためのテンプレートメソッド。 |
protected abstract ObjectSE | unmarshalInputStream(InputStreamSE inputStream) 指定された InputStream から非整列化するための抽象テンプレートメソッド。 |
protected abstract ObjectSE | unmarshalReader(ReaderSE reader) 指定された Reader から非整列化するための抽象テンプレートメソッド。 |
protected abstract ObjectSE | unmarshalSaxReader(XMLReaderSE xmlReader, InputSourceSE inputSource) 特定の SAX XMLReader および InputSource を使用して非整列化するための抽象テンプレートメソッド。 |
protected ObjectSE | unmarshalSaxSource(SAXSourceSE saxSource) SAXSource を処理するためのテンプレートメソッド。 |
protected ObjectSE | unmarshalStaxSource(SourceSE staxSource) StaxSource を処理するためのテンプレートメソッド。 |
protected ObjectSE | unmarshalStreamSource(StreamSourceSE streamSource) StreamSource を処理するためのテンプレートメソッド。 |
protected abstract ObjectSE | unmarshalXmlEventReader(XMLEventReaderSE eventReader) 指定された Stax XMLEventReader から非整列化するための抽象テンプレートメソッド。 |
protected abstract ObjectSE | unmarshalXmlStreamReader(XMLStreamReaderSE streamReader) 指定された Stax XMLStreamReader から非整列化するための抽象テンプレートメソッド。 |
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSE
supports
supports
protected final Log logger
public void setSupportDtd(boolean supportDtd)
デフォルトは false
で、DTD が無効になっています。
public boolean isSupportDtd()
public void setProcessExternalEntities(boolean processExternalEntities)
デフォルトは false
です。これは、外部エンティティが解決されないことを意味します。unmarshal(Source)
に渡される Source
が SAXSource
SE または StreamSource
SE である場合にのみ、外部エンティティの処理が有効または無効になることに注意してください。DOMSource
SE または StAXSource
SE インスタンスには影響しません。
注意 : このオプションを true
に設定すると、setSupportDtd(boolean)
が true
に自動的に設定されます。
public boolean isProcessExternalEntities()
createXmlReader()
protected DocumentSE buildDocument()
DocumentBuilderFactory
SE から新しい Document
SE を構築します。protected DocumentBuilderFactorySE createDocumentBuilderFactory() throws ParserConfigurationExceptionSE
DOMSource
を渡されたときに DOM ドキュメントを作成するために使用する DocumentBuilder
を作成します。 結果の DocumentBuilderFactory
はキャッシュされるため、このメソッドは一度だけ呼び出されます。
ParserConfigurationExceptionSE
- JAXP メソッドによってスローされた場合 protected DocumentBuilderSE createDocumentBuilder(DocumentBuilderFactorySE factory) throws ParserConfigurationExceptionSE
DOMSource
を渡されたときに DOM ドキュメントを作成するために使用する DocumentBuilder
を作成します。サブクラスでオーバーライドでき、ビルダーの初期化を追加します。
factory
- DocumentBuilder を作成する DocumentBuilderFactory
DocumentBuilder
ParserConfigurationExceptionSE
- JAXP メソッドによってスローされた場合 protected XMLReaderSE createXmlReader() throws SAXExceptionSE
SAXSource
を渡されたときに XMLReader
を作成します。SAXExceptionSE
- JAXP メソッドによってスローされた場合 @Nullable protected StringSE getDefaultEncoding()
null
を決定します。 デフォルトの実装は null
を返します。
public final void marshal(ObjectSE graph, ResultSE result) throws IOExceptionSE, XmlMappingException
javax.xml.transform.Result
にマーシャリングします。 この実装は、指定された結果をインスペクションし、marshalDomResult
、marshalSaxResult
、marshalStreamResult
を呼び出します。
Marshaller
の marshal
graph
- マーシャリングするオブジェクトグラフのルート result
- マーシャリングする結果 IOExceptionSE
- I/O 例外が発生した場合 XmlMappingException
- 指定されたオブジェクトを結果に整列化できない場合 IllegalArgumentExceptionSE
- result
の場合 DOMResult
、SAXResult
、StreamResult
のいずれでもない場合 marshalDomResult(Object, javax.xml.transform.dom.DOMResult)
, marshalSaxResult(Object, javax.xml.transform.sax.SAXResult)
, marshalStreamResult(Object, javax.xml.transform.stream.StreamResult)
protected void marshalDomResult(ObjectSE graph, DOMResultSE domResult) throws XmlMappingException
DOMResult
を処理するためのテンプレートメソッド。 この実装は marshalDomNode
に委譲します。
graph
- マーシャリングするオブジェクトグラフのルート domResult
- DOMResult
XmlMappingException
- 指定されたオブジェクトを結果に整列化できない場合 IllegalArgumentExceptionSE
- domResult
が空の場合 marshalDomNode(Object, org.w3c.dom.Node)
protected void marshalStaxResult(ObjectSE graph, ResultSE staxResult) throws XmlMappingException
StaxResult
を処理するためのテンプレートメソッド。 この実装は、StaxResult
の内容に応じて、marshalXMLSteamWriter
または marshalXMLEventConsumer
に委譲します。
graph
- マーシャリングするオブジェクトグラフのルート staxResult
- JAXP 1.4 StAXSource
SEXmlMappingException
- 指定されたオブジェクトを結果に整列化できない場合 IllegalArgumentExceptionSE
- domResult
が空の場合 marshalDomNode(Object, org.w3c.dom.Node)
protected void marshalSaxResult(ObjectSE graph, SAXResultSE saxResult) throws XmlMappingException
SAXResult
を処理するためのテンプレートメソッド。 この実装は marshalSaxHandlers
に委譲します。
graph
- マーシャリングするオブジェクトグラフのルート saxResult
- SAXResult
XmlMappingException
- 指定されたオブジェクトを結果に整列化できない場合 marshalSaxHandlers(Object, org.xml.sax.ContentHandler, org.xml.sax.ext.LexicalHandler)
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
も含まれていない場合 public final ObjectSE unmarshal(SourceSE source) throws IOExceptionSE, XmlMappingException
javax.xml.transform.Source
をオブジェクトグラフに非整列化します。 この実装は、指定された結果をインスペクションし、unmarshalDomSource
、unmarshalSaxSource
、unmarshalStreamSource
を呼び出します。
Unmarshaller
の unmarshal
source
- マーシャリングのソース IOExceptionSE
- I/O 例外が発生した場合 XmlMappingException
- 指定されたソースをオブジェクトにマップできない場合 IllegalArgumentExceptionSE
- source
が DOMSource
、SAXSource
、StreamSource
でない場合 unmarshalDomSource(javax.xml.transform.dom.DOMSource)
, unmarshalSaxSource(javax.xml.transform.sax.SAXSource)
, unmarshalStreamSource(javax.xml.transform.stream.StreamSource)
protected ObjectSE unmarshalDomSource(DOMSourceSE domSource) throws XmlMappingException
DOMSource
を処理するためのテンプレートメソッド。 この実装は unmarshalDomNode
に委譲します。指定されたソースが空の場合、空のソース Document
がプレースホルダーとして作成されます。
domSource
- DOMSource
XmlMappingException
- 指定されたソースをオブジェクトにマップできない場合 IllegalArgumentExceptionSE
- domSource
が空の場合 unmarshalDomNode(org.w3c.dom.Node)
protected ObjectSE unmarshalStaxSource(SourceSE staxSource) throws XmlMappingException
StaxSource
を処理するためのテンプレートメソッド。 この実装は unmarshalXmlStreamReader
または unmarshalXmlEventReader
に委譲します。
staxSource
- StaxSource
XmlMappingException
- 指定されたソースをオブジェクトにマップできない場合 protected ObjectSE unmarshalSaxSource(SAXSourceSE saxSource) throws XmlMappingException, IOExceptionSE
SAXSource
を処理するためのテンプレートメソッド。 この実装は unmarshalSaxReader
に委譲します。
saxSource
- SAXSource
XmlMappingException
- 指定されたソースをオブジェクトにマップできない場合 IOExceptionSE
- I/O 例外が発生した場合 unmarshalSaxReader(org.xml.sax.XMLReader, org.xml.sax.InputSource)
protected ObjectSE unmarshalStreamSource(StreamSourceSE streamSource) throws XmlMappingException, IOExceptionSE
StreamSource
を処理するためのテンプレートメソッド。 この実装は unmarshalInputStream
または unmarshalReader
に委譲します。
streamSource
- StreamSource
IOExceptionSE
- I/O 例外が発生した場合 XmlMappingException
- 指定されたソースをオブジェクトにマップできない場合 protected abstract void marshalDomNode(ObjectSE graph, NodeSE node) throws XmlMappingException
Node
にマーシャリングする抽象テンプレートメソッド。 実際には、ノードは Document
ノード、DocumentFragment
ノード、Element
ノードです。つまり、子を受け入れるノードです。
graph
- マーシャリングするオブジェクトグラフのルート node
- 結果ツリーを含む DOM ノード XmlMappingException
- 指定されたオブジェクトを DOM ノードに整列化できない場合 Document
SE, DocumentFragment
SE, Element
SEprotected abstract void marshalXmlEventWriter(ObjectSE graph, XMLEventWriterSE eventWriter) throws XmlMappingException
XMLEventWriter
にマーシャリングする抽象テンプレートメソッド。graph
- マーシャリングするオブジェクトグラフのルート eventWriter
- 書き込む XMLEventWriter
XmlMappingException
- 指定されたオブジェクトを DOM ノードに整列化できない場合 protected abstract void marshalXmlStreamWriter(ObjectSE graph, XMLStreamWriterSE streamWriter) throws XmlMappingException
XMLStreamWriter
にマーシャリングする抽象テンプレートメソッド。graph
- マーシャリングするオブジェクトグラフのルート streamWriter
- 書き込む XMLStreamWriter
XmlMappingException
- 指定されたオブジェクトを DOM ノードに整列化できない場合 protected abstract void marshalSaxHandlers(ObjectSE graph, ContentHandlerSE contentHandler, @Nullable LexicalHandlerSE lexicalHandler) throws XmlMappingException
ContentHandler
にマーシャリングする抽象テンプレートメソッド。graph
- マーシャリングするオブジェクトグラフのルート contentHandler
- SAX ContentHandler
lexicalHandler
- SAX2 LexicalHandler
null
にすることができます。XmlMappingException
- 指定されたオブジェクトをハンドラーにマーシャリングできない場合 protected abstract void marshalOutputStream(ObjectSE graph, OutputStreamSE outputStream) throws XmlMappingException, IOExceptionSE
OutputStream
にマーシャリングする抽象テンプレートメソッド。graph
- マーシャリングするオブジェクトグラフのルート outputStream
- 書き込む OutputStream
XmlMappingException
- 指定されたオブジェクトをライターにマーシャリングできない場合 IOExceptionSE
- I/O 例外が発生した場合 protected abstract void marshalWriter(ObjectSE graph, WriterSE writer) throws XmlMappingException, IOExceptionSE
Writer
にマーシャリングする抽象テンプレートメソッド。graph
- マーシャリングするオブジェクトグラフのルート writer
- 書き込む Writer
XmlMappingException
- 指定されたオブジェクトをライターにマーシャリングできない場合 IOExceptionSE
- I/O 例外が発生した場合 protected abstract ObjectSE unmarshalDomNode(NodeSE node) throws XmlMappingException
Node
から非整列化するための抽象テンプレートメソッド。node
- 非整列化するオブジェクトを含む DOM ノード XmlMappingException
- 指定された DOM ノードをオブジェクトにマップできない場合 protected abstract ObjectSE unmarshalXmlEventReader(XMLEventReaderSE eventReader) throws XmlMappingException
XMLEventReader
から非整列化するための抽象テンプレートメソッド。eventReader
- 読み込む XMLEventReader
XmlMappingException
- 指定されたイベントリーダーをオブジェクトに変換できない場合 protected abstract ObjectSE unmarshalXmlStreamReader(XMLStreamReaderSE streamReader) throws XmlMappingException
XMLStreamReader
から非整列化するための抽象テンプレートメソッド。streamReader
- 読み込む XMLStreamReader
XmlMappingException
- 指定されたストリームリーダーをオブジェクトに変換できない場合 protected abstract ObjectSE unmarshalSaxReader(XMLReaderSE xmlReader, InputSourceSE inputSource) throws XmlMappingException, IOExceptionSE
XMLReader
および InputSource
を使用して非整列化するための抽象テンプレートメソッド。xmlReader
- 解析する SAX XMLReader
inputSource
- 解析する入力ソース XmlMappingException
- 指定されたリーダーと入力ソースをオブジェクトに変換できない場合 IOExceptionSE
- I/O 例外が発生した場合 protected abstract ObjectSE unmarshalInputStream(InputStreamSE inputStream) throws XmlMappingException, IOExceptionSE
InputStream
から非整列化するための抽象テンプレートメソッド。inputStream
- 読み込む InputStreamStream
XmlMappingException
- 指定されたストリームをオブジェクトに変換できない場合 IOExceptionSE
- I/O 例外が発生した場合 protected abstract ObjectSE unmarshalReader(ReaderSE reader) throws XmlMappingException, IOExceptionSE
Reader
から非整列化するための抽象テンプレートメソッド。reader
- 読み込む Reader
XmlMappingException
- 指定されたリーダーをオブジェクトに変換できない場合 IOExceptionSE
- I/O 例外が発生した場合