Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Re: How retrieve DefaultValue of a Property
Re: How retrieve DefaultValue of a Property [message #632591] Wed, 13 October 2010 14:13 Go to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Tom,

This sounds like a UML2 question that's best asked on the UML2
newsgroup, which I've added to the "to" list of the reply, so no need to
repost. I bet if you used the debugger (your best friend) to look at
the instance you'd know which field stores the value and then you could
look at the source code to see which method returns that field...


Tom Brandenburg wrote:
> Hello,
>
> currently I convert XMI files, to be processed in Eclipse. Following
> extract of the XMI:
>
> <ownedAttribute xmi:type="uml:Property" name="testAttr2"
> xmi:id="BOUML_0x27617_1" visibility="public">
> <defaultValue xmi:type="uml:LiteralString"
> xmi:id="BOUML_VALUE_0x27617_1" value="56"/>
> </ownedAttribute>
>
> evaluates to the following tree structure of the LiteralString:
>
> obj (LiteralStringImpl)
> |
> +- ...
> +- eContainer (PropertyImpl)
> |
> +- ...
> +- defaultValue (LiteralStringImpl)
> |
> +- ...
> +- value ("56")
>
> But with what method of "obj" I get the value "56" of the defaultValue?
>
> Thanks in advance and best regards
> Tom


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How retrieve DefaultValue of a Property [message #632652 is a reply to message #632591] Wed, 13 October 2010 17:15 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi Tom

I'm not a major UML expert, but it looks as if defaultValue is not part
of the model, just the meta-model, so:

At the modeling level you need an OCL ability to navigate the meta-model
that is not currently available (under discussion).

Pragmatically, you can just create a new object and see what value it
gets by default.

Using Ecore reflection you can navigate to the EClass and then the
EAttribute where the default value is reified.

Regards

Ed Willink


On 13/10/2010 15:13, Ed Merks wrote:
> Tom,
>
> This sounds like a UML2 question that's best asked on the UML2
> newsgroup, which I've added to the "to" list of the reply, so no need to
> repost. I bet if you used the debugger (your best friend) to look at the
> instance you'd know which field stores the value and then you could look
> at the source code to see which method returns that field...
>
>
> Tom Brandenburg wrote:
>> Hello,
>>
>> currently I convert XMI files, to be processed in Eclipse. Following
>> extract of the XMI:
>>
>> <ownedAttribute xmi:type="uml:Property" name="testAttr2"
>> xmi:id="BOUML_0x27617_1" visibility="public">
>> <defaultValue xmi:type="uml:LiteralString"
>> xmi:id="BOUML_VALUE_0x27617_1" value="56"/>
>> </ownedAttribute>
>>
>> evaluates to the following tree structure of the LiteralString:
>>
>> obj (LiteralStringImpl)
>> |
>> +- ...
>> +- eContainer (PropertyImpl)
>> |
>> +- ...
>> +- defaultValue (LiteralStringImpl)
>> |
>> +- ...
>> +- value ("56")
>>
>> But with what method of "obj" I get the value "56" of the defaultValue?
>>
>> Thanks in advance and best regards
>> Tom
Re: How retrieve DefaultValue of a Property [message #632707 is a reply to message #632591] Thu, 14 October 2010 01:28 Go to previous messageGo to next message
Rafael Chaves is currently offline Rafael ChavesFriend
Messages: 161
Registered: July 2009
Senior Member
Tom, this is some code from the TextUML Toolkit Graphviz-based renderer for showing the default value for a property:

		
                if (property.getDefaultValue() != null) {
			ValueSpecification defaultValue = property.getDefaultValue();
			String basicValue = defaultValue.stringValue();
			if ("String".equals(property.getType().getName())) 
				basicValue = "\"" + basicValue + "\"";
			w.print(" = " + basicValue);
		}


You can also just use property.getDefault().

Cheers,

Rafael
http://abstratt.com
Re: How retrieve DefaultValue of a Property [message #638480 is a reply to message #632707] Thu, 11 November 2010 12:57 Go to previous message
Tom Brandenburg is currently offline Tom BrandenburgFriend
Messages: 58
Registered: October 2010
Location: Abstatt, Germany
Member
Hello guys,

I just saw that this topic was moved to this newsgroup now. So here is what I've written in the old thread:

Quote:

Hello all,

ok I found it Smile Unfortunetely my previous search started at "LiteralStringImpl". Now I saw that already "Property" has a method called getDefaultValue Smile

Thanks and bye
Tom



Nevertheless thank you for your answers and help!

Bye Tom Smile
Previous Topic:defaultValue of an EnumerationLiteral is discarded
Next Topic:How to create property value of a Slot
Goto Forum:
  


Current Time: Wed Apr 24 22:23:40 GMT 2024

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

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

Back to the top