Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » initializing EMap
initializing EMap [message #417239] Mon, 03 March 2008 13:51 Go to next message
Eclipse UserFriend
Originally posted by: karin.schellner.lixto.com

Hi,

I need to specify an EMap in my ecore model and did already find several
articles on this, one (I think from Ed) is giving the following
instructions:

>To define an EDataType for EMap, you'd need to use "Sample Ecore
> Editor->Show Generics" to enable the editor of Generics. You'd create
> the EDataType, set the instance class name to
> org.eclipse.emf.common.util.EMap and you'd use "Create Child->EType
> Parameter" to create type parameters "K" and "V". Then where you
> reference this data type (as the return type of an operation for
> example), you could expand to show the generic type and right click on
> it to invoke "Create Child->EGeneric Type Parameter" and then you could
> use the properties view to make the type parameter's classifier
> reference "B".
(http://www.eclipsepowered.com/eclipse/forums/t92052.html)


I think I did everything right following this example - I could generate the
model and use the getter and setter.
I am just having problems getting the map stored persistently, as I am most
probably using the wrong class for construction:

private EMap<String,Integer> statusMap = new BasicEMap<String,Integer>();

the example often cited is the one used in EAnnotation:

details = new EcoreEMap<String,
String>(EcorePackage.Literals.ESTRING_TO_STRING_MAP_ENTRY,
EStringToStringMapEntryImpl.class, this, EcorePackage.EANNOTATION__DETAILS)


here the EcoreEMap is used, but I am pretty unsure about how to use this
constructor (also I have a String-Integer-Map not a String-String-Map) ...

Can anyone help in this matter?

Thanks very much,
karin.
Re: initializing EMap [message #417240 is a reply to message #417239] Mon, 03 March 2008 14:01 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------040606010706050306090806
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Karin,

Comments below.

Karin Schellner wrote:
> Hi,
>
> I need to specify an EMap in my ecore model and did already find several
> articles on this, one (I think from Ed) is giving the following
> instructions:
>
>
>> To define an EDataType for EMap, you'd need to use "Sample Ecore
>> Editor->Show Generics" to enable the editor of Generics. You'd create
>> the EDataType, set the instance class name to
>> org.eclipse.emf.common.util.EMap and you'd use "Create Child->EType
>> Parameter" to create type parameters "K" and "V". Then where you
>> reference this data type (as the return type of an operation for
>> example), you could expand to show the generic type and right click on
>> it to invoke "Create Child->EGeneric Type Parameter" and then you could
>> use the properties view to make the type parameter's classifier
>> reference "B".
>>
> (http://www.eclipsepowered.com/eclipse/forums/t92052.html)
>
>
> I think I did everything right following this example - I could generate the
> model and use the getter and setter.
> I am just having problems getting the map stored persistently, as I am most
> probably using the wrong class for construction:
>
That advice was specifically for defining an EDataType for an EMap so
you could reference it in an EOperation, for example.
> private EMap<String,Integer> statusMap = new BasicEMap<String,Integer>();
>
> the example often cited is the one used in EAnnotation:
>
> details = new EcoreEMap<String,
> String>(EcorePackage.Literals.ESTRING_TO_STRING_MAP_ENTRY,
> EStringToStringMapEntryImpl.class, this, EcorePackage.EANNOTATION__DETAILS)
>
>
> here the EcoreEMap is used, but I am pretty unsure about how to use this
> constructor (also I have a String-Integer-Map not a String-String-Map) ...
>
> Can anyone help in this matter?
>
The instructions in the FAQ are what you need:
http://wiki.eclipse.org/index.php/EMF-FAQ#How_do_I_create_a_ Map_in_EMF.3F

It's important that you end up defining an EClass with
instanceTypeName="java.util.Map$Entry" as well as two features, one
named key and one named value. You'll EMap feature will then be a a
containment EReference of that EClass type.
> Thanks very much,
> karin.
>
>
>


--------------040606010706050306090806
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Karin,<br>
<br>
Comments below.<br>
<br>
Karin Schellner wrote:
<blockquote cite="mid:fqgvo7$cli$1@build.eclipse.org" type="cite">
<pre wrap="">Hi,

I need to specify an EMap in my ecore model and did already find several
articles on this, one (I think from Ed) is giving the following
instructions:

</pre>
<blockquote type="cite">
<pre wrap="">To define an EDataType for EMap, you'd need to use "Sample Ecore
Editor-&gt;Show Generics" to enable the editor of Generics. You'd create
the EDataType, set the instance class name to
org.eclipse.emf.common.util.EMap and you'd use "Create Child-&gt;EType
Parameter" to create type parameters "K" and "V". Then where you
reference this data type (as the return type of an operation for
example), you could expand to show the generic type and right click on
it to invoke "Create Child-&gt;EGeneric Type Parameter" and then you could
use the properties view to make the type parameter's classifier
reference "B".
</pre>
</blockquote>
<pre wrap=""><!---->(<a class="moz-txt-link-freetext" href="http://www.eclipsepowered.com/eclipse/forums/t92052.html">http://www.eclipsepowered.com/eclipse/forums/t92052.html</a>)


I think I did everything right following this example - I could generate the
model and use the getter and setter.
I am just having problems getting the map stored persistently, as I am most
probably using the wrong class for construction:
</pre>
</blockquote>
That advice was specifically for defining an EDataType for an EMap so
you could reference it in an EOperation, for example. <br>
<blockquote cite="mid:fqgvo7$cli$1@build.eclipse.org" type="cite">
<pre wrap="">
private EMap&lt;String,Integer&gt; statusMap = new BasicEMap&lt;String,Integer&gt;();

the example often cited is the one used in EAnnotation:

details = new EcoreEMap&lt;String,
String&gt;(EcorePackage.Literals.ESTRING_TO_STRING_MAP_E NTRY,
EStringToStringMapEntryImpl.class, this, EcorePackage.EANNOTATION__DETAILS)


here the EcoreEMap is used, but I am pretty unsure about how to use this
constructor (also I have a String-Integer-Map not a String-String-Map) ...

Can anyone help in this matter?
</pre>
</blockquote>
The instructions in the FAQ are what you need: <a
href=" http://wiki.eclipse.org/index.php/EMF-FAQ#How_do_I_create_a_ Map_in_EMF.3F"> http://wiki.eclipse.org/index.php/EMF-FAQ#How_do_I_create_a_ Map_in_EMF.3F</a><br>
<br>
It's important that you end up defining an EClass with
instanceTypeName="java.util.Map$Entry" as well as two features, one
named key and one named value.&nbsp; You'll EMap feature will then be a a
containment EReference of that EClass type.<br>
<blockquote cite="mid:fqgvo7$cli$1@build.eclipse.org" type="cite">
<pre wrap="">
Thanks very much,
karin.


</pre>
</blockquote>
<br>
</body>
</html>

--------------040606010706050306090806--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: initializing EMap [message #417355 is a reply to message #417240] Thu, 06 March 2008 09:14 Go to previous message
Eclipse UserFriend
Originally posted by: karin.schellner.lixto.com

This is a multi-part message in MIME format.

------=_NextPart_000_0013_01C87F72.E3E7AEB0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Thanks Ed, it worked fine with these instructions!
The instructions in the FAQ are what you need: =
http://wiki.eclipse.org/index.php/EMF-FAQ#How_do_I_create_a_ Map_in_EMF.3F=


It's important that you end up defining an EClass with =
instanceTypeName=3D"java.util.Map$Entry" as well as two features, one =
named key and one named value. You'll EMap feature will then be a a =
containment EReference of that EClass type. =20

------=_NextPart_000_0013_01C87F72.E3E7AEB0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type =
content=3Dtext/html;charset=3DISO-8859-1>
<META content=3D"MSHTML 6.00.2900.3268" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Thanks Ed, it worked fine with these=20
instructions!</FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>The instructions in the FAQ are what you need: <A=20
=
href=3D" http://wiki.eclipse.org/index.php/EMF-FAQ#How_do_I_create_a_ Map_i=
n_EMF.3F"> http://wiki.eclipse.org/index.php/EMF-FAQ#How_do_I_create_a_ Map=
_in_EMF.3F</A><BR><BR>It's=20
important that you end up defining an EClass with=20
instanceTypeName=3D"java.util.Map$Entry" as well as two features, one =
named key=20
and one named value.&nbsp; You'll EMap feature will then be a a =
containment=20
EReference of that EClass type.&nbsp; =
<BR></DIV></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_0013_01C87F72.E3E7AEB0--
Previous Topic:Constrain which values an attribute is allowed to get
Next Topic:Customizing property values
Goto Forum:
  


Current Time: Fri Apr 26 02:36:24 GMT 2024

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

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

Back to the top