Import java Set? / java Type?

MagicDraw OpenAPI, scripting related questions and discussions

Moderator: Moderators

Import java Set? / java Type?

Postby Luciana Alvite » Wed Feb 01, 2006 5:47 am

Hello,

I'm implementing a new pattern that will (among other things) create a
new java class with an iterator method, something like this:

Set collectionOfObjects;

public Iterator iteratorOfOrder( )
{
return collectionOfObjects.iterator();
}

but I cant set attribute's and operation's Type as Set. I realise that
in the application this is only possible if the java profile is loaded.
how can I make this profile available through the API or is there a way
to assign the Type as some sort of collection, so that when code is
generated I get correct .java files? in the open API the interface Type
does not have collection types available.

another question: is there a way of editing method's body? I have a
creator method:

public MyClass createMyObject( )
{
return null;
}

I was able to create a new class in the model (MyClass) , but I can't
make this method have the right body, which would include the actual
creation of the object (return new MyClass() ).
I'm using MagicDraw 10.5.

Thanks in advance,
Best Regards,

Luciana
Luciana Alvite
 
Posts Rating:

RE: Import java Set? / java Type?

Postby Tomas Pugzlys » Mon Feb 06, 2006 11:20 pm

Hello,

See the answers below.

>how can I make this profile available through the API or is there a way
>to assign the Type as some sort of collection

Code generation needs existing java.util.Set class in the model.

Your plugin may create the following package structure in the model:
<package with any name and with "modelLibrary" stereotype
assigned>javautilSet

Or you may load Java profile in the following way:

File profilesDirectory = new File(System.getProperty("install.root"),
"profiles");
File profile = new File(profilesDirectory, "Java_5_0_Profile.mdzip");
ProjectDescriptor descriptor = new LocalProjectDescriptor(null, profile);

Project project = Application.getInstance().getProject();
Application.getInstance().getProjectsManager().useModule(project,
descriptor);

>another question: is there a way of editing method's body?

MagicDraw does not provide functionality to specify a method body for code
generation.

Note for setters/getters: In order to generate correct setter/getter bodies
"setter", "getter" stereotypes should be assigned on operation.

Feel free to contact us, if you have more questions.

Best Regards,
--
Tomas Pugzlys
Programmer
No Magic Lithuanian Development Center
Savanoriu pr. 363- IV, LT-49425, Kaunas
P.O. box 2166, LT-44011, Kaunas
Phone: +370 37 324032 Fax: +370 37 320670
e-mail : tomasp
WWW: http://www.magicdraw.com
--
MagicDraw - UML Made Simple



Tomas Pugzlys
 
Posts Rating:


Return to Programmatic Extendibility

Who is online

Users browsing this forum: No registered users and 1 guest