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.PRintln( "<%=attrName%>" ); <% } } //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 %>