Model elements:一個模型元素。XDE中提供了一個簡單的編程模型,可以通過對模型元素API的調用(比如得到一個類的所有公有方法)來完成給位復雜的代碼定制。和模式聯系在一起的時候,Model Elements類型的參數可以是模式中的一個模版參數,在模式展開的時候,會用具體的模版參數值來替換這個代碼模版中參數。
<% // assume: myClass is "this" Class with debug Operation function debugStatements(myClass) { var attributeCollection = myClass.GetAttributeCollection(); var attributeCollection1= Interfaces.queryInterface(attributeCollection, "com.rational.rms.IRMSElementCollection"); var attributeCount = attributeCollection.getCount(); debugStatements = ""; for (i=1; i<=attributeCount; i++) { var rmsAttribute = attributeCollection1.GetElementAt(i); var attrName = rmsAttribute.getName(); %> System.out.<% } } //assume: myOperation is debug operation function debugOperation(myOperation) { var thisOperation = Interfaces.queryInterface(myOperation, "com.rational.uml70.IUMLOperation"); var thisClass = thisOperation.GetContainer(); var myClass = Interfaces.queryInterface(thisClass, "com.rational.uml70.IUMLClass"); debugStatements(myClass); } var myOperation = Interfaces.queryInterface(thisElement, "com.rational.uml70.IUMLOperation"); debugOperation(myOperation); // end %>