Set Enumeration Type in Property of Stereotype [message #1005433] |
Fri, 25 January 2013 12:32 |
edipo federle Messages: 21 Registered: November 2012 |
Junior Member |
|
|
Hello, I am trying via Java, set a property of a stereotype with an Enumeration. For Example:
First I create the enumeration and enumeration literals
private static void createBindingTimeEnumeration (Profile prof) {
try {
Enumeration bindingTime Helper.createEnumeration = (prof, "BidingTime");
Helper.createEnumerationLiteral (bindingTime, "DESIGN_TIME");
Helper.createEnumerationLiteral (bindingTime, "LINK_TIME");
Helper.createEnumerationLiteral (bindingTime, "COMPILE_TIME");
Helper.createEnumerationLiteral (bindingTime, "RUN_TIME");
} catch (Exception e) {
System.out.println (e.getMessage ());
}
}
Then I create the stereotype, and I would do something like this:
Helper.createAttribute (myStereotype, "bindingTime" bidingTime, 1, 1);
Where is the 'bidingTime' enumeration.
Can anyone help?
thank you
|
|
|
Re: Set Enumeration Type in Property of Stereotype [message #1005460 is a reply to message #1005433] |
Fri, 25 January 2013 14:23 |
|
What is "Helper" ? I assume that's some class you devised that wraps
the UMLFactory?
What is the problem? The bindingTime variable is a reference to the
Enumeration, which is a kind of Type. Just set it as the type of the
attribute. I assume that the Helper.createAttribute(...) method does
this already.
HTH,
Christian
On 2013-01-25 12:32:50 +0000, edipo federle said:
> Hello, I am trying via Java, set a property of a stereotype with an
> Enumeration. For Example:
>
> First I create the enumeration and enumeration literals
>
> private static void createBindingTimeEnumeration (Profile prof) {
> try {
> Enumeration bindingTime Helper.createEnumeration = (prof, "BidingTime");
> Helper.createEnumerationLiteral (bindingTime, "DESIGN_TIME");
> Helper.createEnumerationLiteral (bindingTime, "LINK_TIME");
> Helper.createEnumerationLiteral (bindingTime, "COMPILE_TIME");
> Helper.createEnumerationLiteral (bindingTime, "RUN_TIME");
> } catch (Exception e) {
> System.out.println (e.getMessage ());
> }
> }
>
> Then I create the stereotype, and I would do something like this:
>
> Helper.createAttribute (myStereotype, "bindingTime" bidingTime, 1, 1);
>
> Where is the 'bidingTime' enumeration.
>
> Can anyone help?
>
> thank you
|
|
|
Re: Set Enumeration Type in Property of Stereotype [message #1005464 is a reply to message #1005460] |
Fri, 25 January 2013 14:38 |
edipo federle Messages: 21 Registered: November 2012 |
Junior Member |
|
|
Actually I was with a problem with my method that return the enum by name. A cast problem;
Then, now everthing work: The code is:
Enumeration bindingTime = (Enumeration) getEnumerationByName(prof, "BidingTime");
Helper.createAttribute(variantPoint, "bindingTime", bindingTime , 1, 1);
private static PackageableElement getEnumerationByName(Profile prof, String name) {
EList<PackageableElement> a = prof.getPackagedElements();
for (PackageableElement packageableElement : a) {
if(packageableElement instanceof Enumeration && packageableElement.getName().equals(name))
return packageableElement;
}
return null; // TODO retaforar Exp
}
Thanks.
Sorry for the confusion
[]s
[Updated on: Fri, 25 January 2013 14:39] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.02189 seconds