Question & Answer
Question
How do you get the attribute value of the base class using JAVA API in IBM Rational Rhapsody?
Cause
You would like to use Java Application Programming Interfaces [API] code to automate the manual task to be performed within Rational Rhapsody or to achieve something that is not possible through the Rhapsody GUI.
Answer
In order to get the attribute value of the base class in Rational Rhapsody you can use the below JAVA API code snippet.
All source code and/or binaries attached to this document are referred to here as "the Program". IBM is not providing program services of any kind for the Program. IBM is providing the Program on an "AS IS" basis without warranty of any kind. IBM WILL NOT BE LIABLE FOR ANY ACTUAL, DIRECT, SPECIAL, INCIDENTAL, OR INDIRECT DAMAGES OR FOR ANY ECONOMIC CONSEQUENTIAL DAMAGES (INCLUDING LOST PROFITS OR SAVINGS), EVEN IF IBM, OR ITS RESELLER, HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. |
---|
public class clsHidePort
{
public static void main(String[] args)
{
IRPApplication app = RhapsodyAppServer.getActiveRhapsodyApplication();
IRPInstance globalObj =(IRPInstance) app.getSelectedElement();
IRPClass cls = (IRPClass)globalObj.getOtherClass();
Iterator iter = cls.getAttributesIncludingBases().toList().iterator();
while(iter.hasNext())
{
IRPAttribute attr = (IRPAttribute)iter.next();
if(attr.getName().equals("myAttribute"))
{
System.out.println("Base Attribute Value : " + attr.getDefaultValue());
}
}
}
}
Product Synonym
Rational Rhapsody
Was this topic helpful?
Document Information
Modified date:
27 May 2022
UID
swg21638646