Skip to main content



      Home
Home » Modeling » MDT (Model Development Tools) » [UML2] programmatically set the type of a newly created Parameter???
[UML2] programmatically set the type of a newly created Parameter??? [message #378091] Mon, 03 March 2008 11:41 Go to next message
Eclipse UserFriend
Hello everyone,

I have a questions:
I've programmatically created a Parameter, and how can I set the type of
it to Integer?

I've tried as following:
1 Parameter p = UMLFactory.eINSTANCE.createParameter();
2 p.setDirection(ParameterDirectionKind.RETURN_LITERAL);
3 p.setUpper(1);
4 p.setLower(1);
5 LiteralInteger li = UMLFactory.eINSTANCE.createLiteralInteger();
6 li.setValue(3);
7 System.out.println("type" + li.getType().toString());
8 p.setType(li.getType());
9 return p;

but at line 7, the type of "li" is still null??

so how to set the type of a Parameter to a primitive tpye, such as Integer
or String or boolean?

regards
Jinhui
Re: [UML2] programmatically set the type of a newly created Parameter??? [message #378097 is a reply to message #378091] Mon, 03 March 2008 13:27 Go to previous messageGo to next message
Eclipse UserFriend
Jinhui,

This question is more appropriate for the UML2 newsgroup (copied).

To progammatically set the type of a parameter, simply call setType(Type),
passing the desired type as an argument.

Kenn

"Jinhui" <zhuj@in.tum.de> wrote in message
news:0cf126e1bb6a4f41a1a402583bbd8e00$1@www.eclipse.org...
> Hello everyone,
> I have a questions: I've programmatically created a Parameter, and how can
> I set the type of it to Integer?
>
> I've tried as following:
> 1 Parameter p = UMLFactory.eINSTANCE.createParameter();
> 2 p.setDirection(ParameterDirectionKind.RETURN_LITERAL);
> 3 p.setUpper(1);
> 4 p.setLower(1);
> 5 LiteralInteger li = UMLFactory.eINSTANCE.createLiteralInteger();
> 6 li.setValue(3);
> 7 System.out.println("type" + li.getType().toString());
> 8 p.setType(li.getType());
> 9 return p;
>
> but at line 7, the type of "li" is still null??
> so how to set the type of a Parameter to a primitive tpye, such as Integer
> or String or boolean?
>
> regards
> Jinhui
>
Re: [UML2] programmatically set the type of a newly created Parameter??? [message #378100 is a reply to message #378097] Mon, 03 March 2008 13:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Jinhui,

Additionally, note that a LiteralInteger does not come into existence
knowing that its type is (or even should be) Integer. You will have to
retrieve the Integer primitive type from the UML (or Java) Primitive Types
model library in order to reference it as the parameter's type.

Cheers,

Christian


Kenn Hussey wrote:

> Jinhui,
>
> This question is more appropriate for the UML2 newsgroup (copied).
>
> To progammatically set the type of a parameter, simply call setType(Type),
> passing the desired type as an argument.
>
> Kenn
>
> "Jinhui" <zhuj@in.tum.de> wrote in message
> news:0cf126e1bb6a4f41a1a402583bbd8e00$1@www.eclipse.org...
>> Hello everyone,
>> I have a questions: I've programmatically created a Parameter, and how
>> can I set the type of it to Integer?
>>
>> I've tried as following:
>> 1 Parameter p = UMLFactory.eINSTANCE.createParameter();
>> 2 p.setDirection(ParameterDirectionKind.RETURN_LITERAL);
>> 3 p.setUpper(1);
>> 4 p.setLower(1);
>> 5 LiteralInteger li = UMLFactory.eINSTANCE.createLiteralInteger();
>> 6 li.setValue(3);
>> 7 System.out.println("type" + li.getType().toString());
>> 8 p.setType(li.getType());
>> 9 return p;
>>
>> but at line 7, the type of "li" is still null??
>> so how to set the type of a Parameter to a primitive tpye, such as
>> Integer or String or boolean?
>>
>> regards
>> Jinhui
>>
Re: [UML2] programmatically set the type of a newly created Parameter??? [message #378104 is a reply to message #378100] Mon, 03 March 2008 13:59 Go to previous message
Eclipse UserFriend
Hi Christian,


> Additionally, note that a LiteralInteger does not come into existence
> knowing that its type is (or even should be) Integer. You will have to
> retrieve the Integer primitive type from the UML (or Java) Primitive Types
> model library in order to reference it as the parameter's type.


well, I figured out this Problem too, but the problem now turned to be I
can't load the PrimitiveTypes.
See the other threads from me:

http://www.eclipse.org/newsportal/article.php?id=147&gro up=eclipse.modeling.mdt#147

btw, I am using RSA7.0.0.4.

best regards.

Jinhui
Re: [UML2] programmatically set the type of a newly created Parameter??? [message #584788 is a reply to message #378091] Mon, 03 March 2008 13:27 Go to previous message
Eclipse UserFriend
Jinhui,

This question is more appropriate for the UML2 newsgroup (copied).

To progammatically set the type of a parameter, simply call setType(Type),
passing the desired type as an argument.

Kenn

"Jinhui" <zhuj@in.tum.de> wrote in message
news:0cf126e1bb6a4f41a1a402583bbd8e00$1@www.eclipse.org...
> Hello everyone,
> I have a questions: I've programmatically created a Parameter, and how can
> I set the type of it to Integer?
>
> I've tried as following:
> 1 Parameter p = UMLFactory.eINSTANCE.createParameter();
> 2 p.setDirection(ParameterDirectionKind.RETURN_LITERAL);
> 3 p.setUpper(1);
> 4 p.setLower(1);
> 5 LiteralInteger li = UMLFactory.eINSTANCE.createLiteralInteger();
> 6 li.setValue(3);
> 7 System.out.println("type" + li.getType().toString());
> 8 p.setType(li.getType());
> 9 return p;
>
> but at line 7, the type of "li" is still null??
> so how to set the type of a Parameter to a primitive tpye, such as Integer
> or String or boolean?
>
> regards
> Jinhui
>
Re: [UML2] programmatically set the type of a newly created Parameter??? [message #584802 is a reply to message #378097] Mon, 03 March 2008 13:32 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Jinhui,

Additionally, note that a LiteralInteger does not come into existence
knowing that its type is (or even should be) Integer. You will have to
retrieve the Integer primitive type from the UML (or Java) Primitive Types
model library in order to reference it as the parameter's type.

Cheers,

Christian


Kenn Hussey wrote:

> Jinhui,
>
> This question is more appropriate for the UML2 newsgroup (copied).
>
> To progammatically set the type of a parameter, simply call setType(Type),
> passing the desired type as an argument.
>
> Kenn
>
> "Jinhui" <zhuj@in.tum.de> wrote in message
> news:0cf126e1bb6a4f41a1a402583bbd8e00$1@www.eclipse.org...
>> Hello everyone,
>> I have a questions: I've programmatically created a Parameter, and how
>> can I set the type of it to Integer?
>>
>> I've tried as following:
>> 1 Parameter p = UMLFactory.eINSTANCE.createParameter();
>> 2 p.setDirection(ParameterDirectionKind.RETURN_LITERAL);
>> 3 p.setUpper(1);
>> 4 p.setLower(1);
>> 5 LiteralInteger li = UMLFactory.eINSTANCE.createLiteralInteger();
>> 6 li.setValue(3);
>> 7 System.out.println("type" + li.getType().toString());
>> 8 p.setType(li.getType());
>> 9 return p;
>>
>> but at line 7, the type of "li" is still null??
>> so how to set the type of a Parameter to a primitive tpye, such as
>> Integer or String or boolean?
>>
>> regards
>> Jinhui
>>
Re: [UML2] programmatically set the type of a newly created Parameter??? [message #584813 is a reply to message #378100] Mon, 03 March 2008 13:59 Go to previous message
Eclipse UserFriend
Hi Christian,


> Additionally, note that a LiteralInteger does not come into existence
> knowing that its type is (or even should be) Integer. You will have to
> retrieve the Integer primitive type from the UML (or Java) Primitive Types
> model library in order to reference it as the parameter's type.


well, I figured out this Problem too, but the problem now turned to be I
can't load the PrimitiveTypes.
See the other threads from me:

http://www.eclipse.org/newsportal/article.php?id=147&gro up=eclipse.modeling.mdt#147

btw, I am using RSA7.0.0.4.

best regards.

Jinhui
Previous Topic:[UML2] how to load UML_PRIMITIVE_TYPES_LIBRARY
Next Topic:[Announce] UML2 Tools at EclipseCon 2008
Goto Forum:
  


Current Time: Sun May 18 20:01:22 EDT 2025

Powered by FUDForum. Page generated in 0.06181 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top