高度なカスタマイズ > サービスおよびインフラストラクチャのカスタマイズ > インポートとエクスポートのフレームワーク > エクスポート/インポートハンドラの作成方法 > DTD ファイル > クラスのエクスポートハンドラの作成方法
  
クラスのエクスポートハンドラの作成方法
1. ClassExporterImporterTemplate を拡張するクラスを作成します。
2. オブジェクトのデータを読み込んで XML DOM ドキュメントに追加するメソッド exportAttributes(Object obj, Exporter exp) を実装します。以下は、"MyClass" のオブジェクトでのこのメソッドの例を示します。
public void exportAttributes (Object object, Exporter exporter) throws WTException {
try {
MyClass ob = (MyClass)object;
// export the local id
IxbHndHelper.exportAttribute(
ExpImpForLocalIdAttr.class, ob, fileXML, exporter);
// export other attributes that are specific to
// MyObject; e.g. name, number
IxbHndHelper.exportAttribute(
ExpImpForMyObjectAttr.class, ob, fileXML, exporter);
// export version information
IxbHndHelper.exportAttribute(
ExpImpForVersionAttr.class, ob, fileXML, exporter);
// export content
IxbHndHelper.exportAttribute(
ExpImpForContentAttr.class, ob, fileXML, exporter);

}
catch (Exception e) {
LogHelper.devExc ( e,
"exportAttributes: could not export
object=<"+object+">");
}
}
3. エクスポートされるオブジェクトタイプに適切なルートタグを返す getRootTag() メソッドをオーバーライドします。以下は、"MyClass" のオブジェクトでのこのメソッドの例を示します。
protected String getRootTag() {
return "MyClass";
}
4. ハンドラ XML ファイル (<Windchill>\registry\ixb\handlers\coreX10.dtd) に、エクスポートされるクラス (com.mycompany.MyObject)、コア Windchill オブジェクト用 XML DTD (standardX20.dtd)、クラス用のハンドラ (wt.ixb.handlers.forclasses.ExpImpForMyObject) を指定するエントリを追加します。以下にエントリの例を示します。
<classExporter>
<class>com.mycompany.MyObject</class>
<dtd>standardX20.dtd</dtd>
<targetTag>default</target>
<handler>wt.ixb.handlers.forclasses.ExpImpForMyObject</handler>
</classExporter>