public class CastorMarshaller extends AbstractMarshaller implements InitializingBean, BeanClassLoaderAware
Marshaller
インターフェースの実装。デフォルトでは、Castor に追加の構成は必要ありませんが、ターゲットクラス、ターゲットパッケージの設定、マッピングファイルの提供を使用して、Castor の動作をより詳細に制御できます。 ターゲットクラスが setTargetClass
を使用して指定されている場合、CastorMarshaller
はその特定のクラスを表す XML を非整列化するためにのみ使用できます。複数のクラスを非整列化する場合は、setMappingLocations
を使用してマッピングファイルを提供する必要があります。
Castor の API の制限により、出力ストリームへの書き込みに使用されるエンコードを設定する必要があります。デフォルトは UTF-8
です。
setEncoding(String)
, setTargetClass(Class)
, setTargetPackages(String[])
, setMappingLocation(Resource)
, setMappingLocations(Resource[])
修飾子と型 | フィールドと説明 |
---|---|
static StringSE | DEFAULT_ENCODING ストリームアクセスに使用されるデフォルトのエンコーディング: UTF-8。 |
logger
コンストラクターと説明 |
---|
CastorMarshaller() |
修飾子と型 | メソッドと説明 |
---|---|
void | afterPropertiesSet() 指定されたすべての Bean プロパティを設定した(そして BeanFactoryAware と ApplicationContextAware を満たした)後に BeanFactory によって呼び出されます。 |
protected XmlMappingException | convertCastorException(org.exolab.castor.xml.XMLException ex, boolean marshalling) 指定された XMLException を org.springframework.oxm 階層からの適切な例外に変換します。 |
protected org.exolab.castor.xml.XMLContext | createXMLContext(Resource[] mappingLocations, ClassSE<?>[] targetClasses, StringSE[] targetPackages) Castor XMLContext を作成します。 |
protected void | customizeMarshaller(org.exolab.castor.xml.Marshaller marshaller) 特定の Castor Marshaller のカスタマイズを可能にするテンプレートメソッド。 |
protected void | customizeUnmarshaller(org.exolab.castor.xml.Unmarshaller unmarshaller) 特定の Castor Unmarshaller のカスタマイズを可能にするテンプレートメソッド。 |
protected StringSE | getDefaultEncoding() バイトストリームからのマーシャリングまたはアンマーシャリングに使用するデフォルトエンコーディングを決定します。存在しない場合は null を決定します。 |
protected void | marshalDomNode(ObjectSE graph, NodeSE node) 指定されたオブジェクトグラフを DOM Node にマーシャリングする抽象テンプレートメソッド。 |
protected void | marshalOutputStream(ObjectSE graph, OutputStreamSE outputStream) 指定されたオブジェクトグラフを OutputStream にマーシャリングする抽象テンプレートメソッド。 |
protected void | marshalSaxHandlers(ObjectSE graph, ContentHandlerSE contentHandler, LexicalHandlerSE lexicalHandler) 指定されたオブジェクトグラフを SAX ContentHandler にマーシャリングする抽象テンプレートメソッド。 |
protected void | marshalWriter(ObjectSE graph, WriterSE writer) 指定されたオブジェクトグラフを Writer にマーシャリングする抽象テンプレートメソッド。 |
protected void | marshalXmlEventWriter(ObjectSE graph, XMLEventWriterSE eventWriter) 指定されたオブジェクトを StAX XMLEventWriter にマーシャリングする抽象テンプレートメソッド。 |
protected void | marshalXmlStreamWriter(ObjectSE graph, XMLStreamWriterSE streamWriter) 指定されたオブジェクトを StAX XMLStreamWriter にマーシャリングする抽象テンプレートメソッド。 |
void | setBeanClassLoader(ClassLoaderSE classLoader) Bean class loader SE を Bean インスタンスに提供するコールバック。 |
void | setCastorProperties(MapSE<StringSE, StringSE> castorProperties) マーシャリングとアンマーシャリングの Castor 固有のプロパティを設定します。 |
void | setClassDescriptorResolver(org.exolab.castor.xml.XMLClassDescriptorResolver classDescriptorResolver) アンマーシャリング中に使用される XMLClassDescriptorResolver を設定します。 |
void | setClearCollections(boolean clearCollections) このアンマーシャラーが最初の使用時にコレクションをクリアするかどうかを設定します。 |
void | setDoctypes(MapSE<StringSE, StringSE> doctypes) マーシャラーのドキュメント型定義を含むマップを設定します。 |
void | setEncoding(StringSE encoding) ストリームアクセスに使用するエンコードを設定します。 |
void | setEntityResolver(EntityResolverSE entityResolver) アンマーシャリング中に使用される EntityResolver SE を設定します。 |
void | setIdResolver(org.exolab.castor.xml.IDResolver idResolver) アンマーシャリング中に使用する Castor IDResolver を設定します。 |
void | setIgnoreExtraAttributes(boolean ignoreExtraAttributes) Castor Unmarshaller が特定のフィールドに一致しない属性を無視するかどうかを設定します。 |
void | setIgnoreExtraElements(boolean ignoreExtraElements) Castor Unmarshaller が特定のフィールドに一致しない要素を無視するかどうかを設定します。 |
void | setMappingLocation(Resource mappingLocation) Castor XML マッピングファイルの場所を設定します。 |
void | setMappingLocations(Resource... mappingLocations) Castor XML マッピングファイルの場所を設定します。 |
void | setMarshalAsDocument(boolean marshalAsDocument) このマーシャラーが xml 宣言を出力するかどうかを設定します。 |
void | setMarshalExtendedType(boolean marshalExtendedType) このマーシャラーが指定された型の xsi:type 属性を出力するかどうかを設定します。 |
void | setNamespaceMappings(MapSE<StringSE, StringSE> namespaceMappings) 名前空間のマッピングを設定します。 |
void | setNamespaceToPackageMapping(MapSE<StringSE, StringSE> namespaceToPackageMapping) 名前空間をパッケージマッピングに設定します。 |
void | setNoNamespaceSchemaLocation(StringSE noNamespaceSchemaLocation) xsi:noNamespaceSchemaLocation 属性の値を設定します。 |
void | setObjectFactory(org.exolab.castor.util.ObjectFactory objectFactory) アンマーシャリング中に使用する Castor ObjectFactory を設定します。 |
void | setProcessingInstructions(MapSE<StringSE, StringSE> processingInstructions) マーシャリング中に使用される処理命令を設定します。 |
void | setReuseObjects(boolean reuseObjects) このアンマーシャラーがオブジェクトを再利用するかどうかを設定します。 |
void | setRootElement(StringSE rootElement) ルート要素の名前を設定します。 |
void | setRootObject(ObjectSE root) ソースが非整列化される非整列化のために予想されるルートオブジェクトを設定します。 |
void | setSchemaLocation(StringSE schemaLocation) xsi:schemaLocation 属性の値を設定します。 |
void | setSuppressNamespaces(boolean suppressNamespaces) このマーシャラーが名前空間を出力するかどうかを設定します。 |
void | setSuppressXsiType(boolean suppressXsiType) このマーシャラーが xsi:type 属性を出力するかどうかを設定します。 |
void | setTargetClass(ClassSE<?> targetClass) Castor ターゲットクラスを設定します。 |
void | setTargetClasses(ClassSE<?>... targetClasses) Castor ターゲットクラスを設定します。 |
void | setTargetPackage(StringSE targetPackage) Castor 記述子クラスを使用してパッケージの名前を設定します。 |
void | setTargetPackages(StringSE... targetPackages) Castor 記述子クラスを使用してパッケージの名前を設定します。 |
void | setUseXSITypeAtRoot(boolean useXSITypeAtRoot) このマーシャラーがルート要素の xsi:type 属性を出力するかどうかを設定します。 |
void | setValidating(boolean validating) このマーシャラーが送受信ドキュメントを検証するかどうかを設定します。 |
void | setWhitespacePreserve(boolean whitespacePreserve) Castor Unmarshaller が「無視できる」空白を保持するかどうかを設定します。 |
boolean | supports(ClassSE<?> clazz) すべてのクラスの true を返します。 |
protected ObjectSE | unmarshalDomNode(NodeSE node) 指定された DOM Node から非整列化するための抽象テンプレートメソッド。 |
protected ObjectSE | unmarshalInputStream(InputStreamSE inputStream) 指定された InputStream から非整列化するための抽象テンプレートメソッド。 |
protected ObjectSE | unmarshalReader(ReaderSE reader) 指定された Reader から非整列化するための抽象テンプレートメソッド。 |
protected ObjectSE | unmarshalSaxReader(XMLReaderSE xmlReader, InputSourceSE inputSource) 特定の SAX XMLReader および InputSource を使用して非整列化するための抽象テンプレートメソッド。 |
protected ObjectSE | unmarshalXmlEventReader(XMLEventReaderSE eventReader) 指定された Stax XMLEventReader から非整列化するための抽象テンプレートメソッド。 |
protected ObjectSE | unmarshalXmlStreamReader(XMLStreamReaderSE streamReader) 指定された Stax XMLStreamReader から非整列化するための抽象テンプレートメソッド。 |
buildDocument, createDocumentBuilder, createDocumentBuilderFactory, createXmlReader, isProcessExternalEntities, isSupportDtd, marshal, marshalDomResult, marshalSaxResult, marshalStaxResult, marshalStreamResult, setProcessExternalEntities, setSupportDtd, unmarshal, unmarshalDomSource, unmarshalSaxSource, unmarshalStaxSource, unmarshalStreamSource
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSE
public void setEncoding(StringSE encoding)
DEFAULT_ENCODING
protected StringSE getDefaultEncoding()
AbstractMarshaller
null
を決定します。 デフォルトの実装は null
を返します。
AbstractMarshaller
の getDefaultEncoding
public void setMappingLocation(Resource mappingLocation)
public void setMappingLocations(Resource... mappingLocations)
public void setTargetClass(ClassSE<?> targetClass)
public void setTargetClasses(ClassSE<?>... targetClasses)
public void setTargetPackage(StringSE targetPackage)
public void setTargetPackages(StringSE... targetPackages)
public void setValidating(boolean validating)
デフォルトは false
です。
Marshaller.setValidation(boolean)
public void setSuppressNamespaces(boolean suppressNamespaces)
デフォルトは false
です。つまり、名前空間が書き込まれます。
Marshaller.setSuppressNamespaces(boolean)
public void setSuppressXsiType(boolean suppressXsiType)
xsi:type
属性を出力するかどうかを設定します。 デフォルトは false
です。つまり、xsi:type
が書き込まれます。
Marshaller.setSuppressXSIType(boolean)
public void setMarshalAsDocument(boolean marshalAsDocument)
デフォルトは true
で、XML 宣言が書き込まれます。
Marshaller.setMarshalAsDocument(boolean)
public void setMarshalExtendedType(boolean marshalExtendedType)
xsi:type
属性を出力するかどうかを設定します。 デフォルトは true
で、xsi:type
属性が書き込まれます。
Marshaller.setMarshalExtendedType(boolean)
public void setRootElement(StringSE rootElement)
Marshaller.setRootElement(String)
public void setNoNamespaceSchemaLocation(StringSE noNamespaceSchemaLocation)
xsi:noNamespaceSchemaLocation
属性の値を設定します。設定すると、xsi:noNamespaceSchemaLocation
属性がルート要素に書き込まれます。Marshaller.setNoNamespaceSchemaLocation(String)
public void setSchemaLocation(StringSE schemaLocation)
xsi:schemaLocation
属性の値を設定します。設定すると、xsi:schemaLocation
属性がルート要素に書き込まれます。Marshaller.setSchemaLocation(String)
public void setUseXSITypeAtRoot(boolean useXSITypeAtRoot)
xsi:type
属性を出力するかどうかを設定します。これは、要素名から単純に要素の型を判別できない場合に役立ちます。 デフォルトは false
です。ルート要素の xsi:type
属性は書き込まれません。
Marshaller.setUseXSITypeAtRoot(boolean)
public void setWhitespacePreserve(boolean whitespacePreserve)
Unmarshaller
が「無視できる」空白を保持するかどうかを設定します。 デフォルトは false
です。
Unmarshaller.setWhitespacePreserve(boolean)
public void setIgnoreExtraAttributes(boolean ignoreExtraAttributes)
Unmarshaller
が特定のフィールドに一致しない属性を無視するかどうかを設定します。 デフォルトは true
です: 余分な属性は無視されます。
Unmarshaller.setIgnoreExtraAttributes(boolean)
public void setIgnoreExtraElements(boolean ignoreExtraElements)
Unmarshaller
が特定のフィールドに一致しない要素を無視するかどうかを設定します。 デフォルトは false
です: 余分な要素はエラーとしてフラグが立てられます。
Unmarshaller.setIgnoreExtraElements(boolean)
public void setRootObject(ObjectSE root)
Unmarshaller.setObject(Object)
public void setReuseObjects(boolean reuseObjects)
デフォルトは false
です。つまり、オブジェクトは再利用されません。
Unmarshaller.setReuseObjects(boolean)
public void setClearCollections(boolean clearCollections)
デフォルトは false
で、マーシャラーはコレクションをクリアしません。
Unmarshaller.setClearCollections(boolean)
public void setCastorProperties(MapSE<StringSE,StringSE> castorProperties)
Marshaller.setProperty(String, String)
, Unmarshaller.setProperty(String, String)
public void setDoctypes(MapSE<StringSE,StringSE> doctypes)
Marshaller.setDoctype(String, String)
public void setProcessingInstructions(MapSE<StringSE,StringSE> processingInstructions)
Marshaller.addProcessingInstruction(String, String)
public void setNamespaceMappings(MapSE<StringSE,StringSE> namespaceMappings)
Marshaller.setNamespaceMapping(String, String)
public void setNamespaceToPackageMapping(MapSE<StringSE,StringSE> namespaceToPackageMapping)
Marshaller.setNamespaceMapping(String, String)
public void setEntityResolver(EntityResolverSE entityResolver)
EntityResolver
SE を設定します。このリゾルバーは、システム ID とパブリック ID を解決するために使用されます。Unmarshaller.setEntityResolver(EntityResolver)
public void setClassDescriptorResolver(org.exolab.castor.xml.XMLClassDescriptorResolver classDescriptorResolver)
XMLClassDescriptorResolver
を設定します。このリゾルバーは、クラス記述子を解決するために使用されます。Unmarshaller.setResolver(XMLClassDescriptorResolver)
public void setIdResolver(org.exolab.castor.xml.IDResolver idResolver)
IDResolver
を設定します。Unmarshaller.setIDResolver(IDResolver)
public void setObjectFactory(org.exolab.castor.util.ObjectFactory objectFactory)
ObjectFactory
を設定します。Unmarshaller.setObjectFactory(ObjectFactory)
public void setBeanClassLoader(ClassLoaderSE classLoader)
BeanClassLoaderAware
class loader
SE を Bean インスタンスに提供するコールバック。 通常の Bean プロパティの設定後、ただし InitializingBean's
InitializingBean.afterPropertiesSet()
メソッドやカスタム init-method などの初期化コールバックの前に呼び出されます。
BeanClassLoaderAware
の setBeanClassLoader
classLoader
- 所有クラスローダー public void afterPropertiesSet() throws CastorMappingException, IOExceptionSE
InitializingBean
このメソッドにより、Bean インスタンスは、すべての Bean プロパティが設定されている場合にのみ可能な初期化を実行し、設定ミスの場合に例外をスローできます。
InitializingBean
の afterPropertiesSet
CastorMappingException
IOExceptionSE
protected org.exolab.castor.xml.XMLContext createXMLContext(@Nullable Resource[] mappingLocations, @Nullable ClassSE<?>[] targetClasses, @Nullable StringSE[] targetPackages) throws org.exolab.castor.mapping.MappingException, org.exolab.castor.xml.ResolverException, IOExceptionSE
XMLContext
を作成します。サブクラスはこれをオーバーライドしてカスタムコンテキストを作成できます。デフォルトの実装は、定義されている場合はマッピングファイルを、定義されている場合はターゲットクラスまたはパッケージをロードします。
org.exolab.castor.mapping.MappingException
- マッピングファイルをロードできない場合 IOExceptionSE
- I/O エラーの場合 org.exolab.castor.xml.ResolverException
XMLContext.addMapping(org.exolab.castor.mapping.Mapping)
, XMLContext.addClass(Class)
public boolean supports(ClassSE<?> clazz)
true
を返します。つまり、Castor は任意のクラスをサポートします。Marshaller
の supports
Unmarshaller
の supports
clazz
- このマーシャラーがマーシャリングできるかどうか尋ねられているクラス true
。それ以外の場合は false
protected void marshalDomNode(ObjectSE graph, NodeSE node) throws XmlMappingException
AbstractMarshaller
Node
にマーシャリングする抽象テンプレートメソッド。 実際には、ノードは Document
ノード、DocumentFragment
ノード、Element
ノードです。つまり、子を受け入れるノードです。
AbstractMarshaller
の marshalDomNode
graph
- マーシャリングするオブジェクトグラフのルート node
- 結果ツリーを含む DOM ノード XmlMappingException
- 指定されたオブジェクトを DOM ノードに整列化できない場合 Document
SE, DocumentFragment
SE, Element
SEprotected void marshalXmlEventWriter(ObjectSE graph, XMLEventWriterSE eventWriter) throws XmlMappingException
AbstractMarshaller
XMLEventWriter
にマーシャリングする抽象テンプレートメソッド。AbstractMarshaller
の marshalXmlEventWriter
graph
- マーシャリングするオブジェクトグラフのルート eventWriter
- 書き込む XMLEventWriter
XmlMappingException
- 指定されたオブジェクトを DOM ノードに整列化できない場合 protected void marshalXmlStreamWriter(ObjectSE graph, XMLStreamWriterSE streamWriter) throws XmlMappingException
AbstractMarshaller
XMLStreamWriter
にマーシャリングする抽象テンプレートメソッド。AbstractMarshaller
の marshalXmlStreamWriter
graph
- マーシャリングするオブジェクトグラフのルート streamWriter
- 書き込む XMLStreamWriter
XmlMappingException
- 指定されたオブジェクトを DOM ノードに整列化できない場合 protected void marshalSaxHandlers(ObjectSE graph, ContentHandlerSE contentHandler, @Nullable LexicalHandlerSE lexicalHandler) throws XmlMappingException
AbstractMarshaller
ContentHandler
にマーシャリングする抽象テンプレートメソッド。AbstractMarshaller
の marshalSaxHandlers
graph
- マーシャリングするオブジェクトグラフのルート contentHandler
- SAX ContentHandler
lexicalHandler
- SAX2 LexicalHandler
null
にすることができます。XmlMappingException
- 指定されたオブジェクトをハンドラーにマーシャリングできない場合 protected void marshalOutputStream(ObjectSE graph, OutputStreamSE outputStream) throws XmlMappingException, IOExceptionSE
AbstractMarshaller
OutputStream
にマーシャリングする抽象テンプレートメソッド。AbstractMarshaller
の marshalOutputStream
graph
- マーシャリングするオブジェクトグラフのルート outputStream
- 書き込む OutputStream
XmlMappingException
- 指定されたオブジェクトをライターにマーシャリングできない場合 IOExceptionSE
- I/O 例外が発生した場合 protected void marshalWriter(ObjectSE graph, WriterSE writer) throws XmlMappingException, IOExceptionSE
AbstractMarshaller
Writer
にマーシャリングする抽象テンプレートメソッド。AbstractMarshaller
の marshalWriter
graph
- マーシャリングするオブジェクトグラフのルート writer
- 書き込む Writer
XmlMappingException
- 指定されたオブジェクトをライターにマーシャリングできない場合 IOExceptionSE
- I/O 例外が発生した場合 protected void customizeMarshaller(org.exolab.castor.xml.Marshaller marshaller)
Marshaller
のカスタマイズを可能にするテンプレートメソッド。protected ObjectSE unmarshalDomNode(NodeSE node) throws XmlMappingException
AbstractMarshaller
Node
から非整列化するための抽象テンプレートメソッド。AbstractMarshaller
の unmarshalDomNode
node
- 非整列化するオブジェクトを含む DOM ノード XmlMappingException
- 指定された DOM ノードをオブジェクトにマップできない場合 protected ObjectSE unmarshalXmlEventReader(XMLEventReaderSE eventReader)
AbstractMarshaller
XMLEventReader
から非整列化するための抽象テンプレートメソッド。AbstractMarshaller
の unmarshalXmlEventReader
eventReader
- 読み込む XMLEventReader
protected ObjectSE unmarshalXmlStreamReader(XMLStreamReaderSE streamReader)
AbstractMarshaller
XMLStreamReader
から非整列化するための抽象テンプレートメソッド。AbstractMarshaller
の unmarshalXmlStreamReader
streamReader
- 読み込む XMLStreamReader
protected ObjectSE unmarshalSaxReader(XMLReaderSE xmlReader, InputSourceSE inputSource) throws XmlMappingException, IOExceptionSE
AbstractMarshaller
XMLReader
および InputSource
を使用して非整列化するための抽象テンプレートメソッド。AbstractMarshaller
の unmarshalSaxReader
xmlReader
- 解析する SAX XMLReader
inputSource
- 解析する入力ソース XmlMappingException
- 指定されたリーダーと入力ソースをオブジェクトに変換できない場合 IOExceptionSE
- I/O 例外が発生した場合 protected ObjectSE unmarshalInputStream(InputStreamSE inputStream) throws XmlMappingException, IOExceptionSE
AbstractMarshaller
InputStream
から非整列化するための抽象テンプレートメソッド。AbstractMarshaller
の unmarshalInputStream
inputStream
- 読み込む InputStreamStream
XmlMappingException
- 指定されたストリームをオブジェクトに変換できない場合 IOExceptionSE
- I/O 例外が発生した場合 protected ObjectSE unmarshalReader(ReaderSE reader) throws XmlMappingException, IOExceptionSE
AbstractMarshaller
Reader
から非整列化するための抽象テンプレートメソッド。AbstractMarshaller
の unmarshalReader
reader
- 読み込む Reader
XmlMappingException
- 指定されたリーダーをオブジェクトに変換できない場合 IOExceptionSE
- I/O 例外が発生した場合 protected void customizeUnmarshaller(org.exolab.castor.xml.Unmarshaller unmarshaller)
Unmarshaller
のカスタマイズを可能にするテンプレートメソッド。protected XmlMappingException convertCastorException(org.exolab.castor.xml.XMLException ex, boolean marshalling)
XMLException
を org.springframework.oxm
階層からの適切な例外に変換します。Castor 自体は例外階層でこの区別を行わないため、ブールフラグを使用して、この例外がマーシャリング中に発生するかアンマーシャリング中に発生するかを示します。
ex
- 発生したキャスター XMLException
marshalling
- マーシャリング中に例外が発生するか(true
)、アンマーシャリングするかを示します (false
)XmlMappingException