WebSphere Enterprise Service Bus バージョン 6.2.0 オペレーティング・システム: AIX、HP-UX、i5/OS、Linux、Solaris、Windows


どうすれば DataObject に anyAttribute タグがあるかどうかが分かるか

DataObject のインスタンス内に anyAttribute 値が設定されているかどうかは、インスタンスのプロパティーを調べて、いずれかのオープン・プロパティーが属性であるかどうかを確認すれば、簡単に判別できます。

DataObject は DataObject Type に anyAttribute タグがあるかどうかを判別するメカニズムを備えていません。DataObject には、any と <anyAttribute/> の両方に適用され、any の Property を自由に追加できる「オープン」の概念だけがあります。DataObject has isOpen() = true で isSequenced() = false の場合には anyAttribute タグがなければならないということは正しいのですが、isOpen() = true で isSequenced() = true の場合には、DataObject Type は anyAttribute タグを持つ場合と持たない場合があります。

DataObject は、その DataObject を生成するために使用された XSD 構造に関するこれらの疑問にプログラマチックに回答する、メタデータ照会メソッドを備えています。必要であれば、InfoSet モデルに照会して、anyAttribute タグが存在するかどうかを知ることができます。anyAttribute は単数形で、true かそうでないかであるため、ビジネス・オブジェクトは BOXSDHelper hasAnyAttribute(Type) メソッドも提供して、この DataObject にオープン属性を設定しても有効な結果が得られるかどうかを判別できるようにします。次のコード例は、それらの概念を実際に示したものです。

	DataObject dobj = ...

	// タイプがオープンであるかどうかを検査し、そうでなければ
	// 中に anyAttribute 値が設定されていることはありえない。
	boolean isOpen = dobj.getType().isOpen();

	if (!isOpen) return false;  // anyAttribute 値は設定されていない

	// オープン・プロパティーはインスタンス・プロパティー・リストに追加されるが
	// プロパティー・リストには追加されないため、それらのサイズを比較すれば
	// 設定されたオープン・データがあるかどうかを簡単に判別できる
	int instancePropertyCount = dobj.getInstanceProperties().size();
	int definedPropertyCount = dobj.getType().getProperties().size();

	// 同じであれば、オープン・コンテンツは設定されていない
	if (instancePropertyCount == definedPropertyCount) return false;

	// オープン・コンテンツの Property を調べて、any が Attribute で
	// あるかどうかを判別する
	for (int i=definedPropertyCount; i<instancePropertyCount; i++)
	{
	    Property prop = (Property)dobj.getInstanceProperties().get(i);
	    if (boXsdHelper.isAttribute(prop))
	    {
	        return true;  // anyAttribute 値が検出された
	    }
	}

	return false;  // anyAttribute 値は設定されていない

concept 概念トピック

ご利用条件 | フィードバック


タイムスタンプ・アイコン 最終更新: 2010/07/05


http://publib.boulder.ibm.com/infocenter/dmndhelp/v6r2mx/topic//com.ibm.websphere.wesb620.doc/doc/cbo_howdataobjany.html
Copyright IBM Corporation 2005, 2010. All Rights Reserved.
このインフォメーション・センターでは Eclipse テクノロジーが採用されています (http://www.eclipse.org)。