Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » No Cast in case of templates
No Cast in case of templates [message #472883] Thu, 10 May 2007 23:13 Go to next message
Pradeep is currently offline PradeepFriend
Messages: 54
Registered: July 2009
Member
Hi,

I created a uml primitive type with Map<String, Datum> and assigned it to
content variable in a class.
Now when I convert it to Ecore then to code, I am getting the following
code. If you see the eUnset function there is proper cast but there is none
in eSet function. The compiler is complaining about the same saying it
cannot accept object.

How can I avoid this.

/**

* <!-- begin-user-doc -->

* <!-- end-user-doc -->

* @generated

*/

@SuppressWarnings("unchecked")

@Override

public void eSet(int featureID, Object newValue) {

switch (featureID) {

case NewheadPackage.DATA_MAP__CONTENT:

setContent(newValue);

return;

}

super.eSet(featureID, newValue);

}


/**

* <!-- begin-user-doc -->

* <!-- end-user-doc -->

* @generated

*/

@Override

public void eUnset(int featureID) {

switch (featureID) {

case NewheadPackage.DATA_MAP__CONTENT:

setContent((Map<String, Datum>)null);

return;

}

super.eUnset(featureID);

}
Re: No Cast in case of templates [message #472884 is a reply to message #472883] Thu, 10 May 2007 23:25 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Pradeep,

I'll need to see an Ecore model that reproduces this problem to
comment. It could be a bug, but without an example, who knows...


Pradeep wrote:
> Hi,
>
> I created a uml primitive type with Map<String, Datum> and assigned it to
> content variable in a class.
> Now when I convert it to Ecore then to code, I am getting the following
> code. If you see the eUnset function there is proper cast but there is none
> in eSet function. The compiler is complaining about the same saying it
> cannot accept object.
>
> How can I avoid this.
>
> /**
>
> * <!-- begin-user-doc -->
>
> * <!-- end-user-doc -->
>
> * @generated
>
> */
>
> @SuppressWarnings("unchecked")
>
> @Override
>
> public void eSet(int featureID, Object newValue) {
>
> switch (featureID) {
>
> case NewheadPackage.DATA_MAP__CONTENT:
>
> setContent(newValue);
>
> return;
>
> }
>
> super.eSet(featureID, newValue);
>
> }
>
>
> /**
>
> * <!-- begin-user-doc -->
>
> * <!-- end-user-doc -->
>
> * @generated
>
> */
>
> @Override
>
> public void eUnset(int featureID) {
>
> switch (featureID) {
>
> case NewheadPackage.DATA_MAP__CONTENT:
>
> setContent((Map<String, Datum>)null);
>
> return;
>
> }
>
> super.eUnset(featureID);
>
> }
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: No Cast in case of templates [message #472885 is a reply to message #472884] Thu, 10 May 2007 23:48 Go to previous messageGo to next message
Pradeep is currently offline PradeepFriend
Messages: 54
Registered: July 2009
Member
Please find the uml file attached. I used the file to generate genmodel and
then code.

Please import java.util.Map in the generated code.



"Ed Merks" <merks@ca.ibm.com> wrote in message
news:f209lo$5hf$1@build.eclipse.org...
> Pradeep,
>
> I'll need to see an Ecore model that reproduces this problem to
> comment. It could be a bug, but without an example, who knows...
>
>
> Pradeep wrote:
>> Hi,
>>
>> I created a uml primitive type with Map<String, Datum> and assigned it to
>> content variable in a class.
>> Now when I convert it to Ecore then to code, I am getting the following
>> code. If you see the eUnset function there is proper cast but there is
>> none
>> in eSet function. The compiler is complaining about the same saying it
>> cannot accept object.
>>
>> How can I avoid this.
>>
>> /**
>>
>> * <!-- begin-user-doc -->
>>
>> * <!-- end-user-doc -->
>>
>> * @generated
>>
>> */
>>
>> @SuppressWarnings("unchecked")
>>
>> @Override
>>
>> public void eSet(int featureID, Object newValue) {
>>
>> switch (featureID) {
>>
>> case NewheadPackage.DATA_MAP__CONTENT:
>>
>> setContent(newValue);
>>
>> return;
>>
>> }
>>
>> super.eSet(featureID, newValue);
>>
>> }
>>
>>
>> /**
>>
>> * <!-- begin-user-doc -->
>>
>> * <!-- end-user-doc -->
>>
>> * @generated
>>
>> */
>>
>> @Override
>>
>> public void eUnset(int featureID) {
>>
>> switch (featureID) {
>>
>> case NewheadPackage.DATA_MAP__CONTENT:
>>
>> setContent((Map<String, Datum>)null);
>>
>> return;
>>
>> }
>>
>> super.eUnset(featureID);
>>
>> }
>>
>>
>>


  • Attachment: test.uml
    (Size: 1.40KB, Downloaded 231 times)
Re: No Cast in case of templates [message #472886 is a reply to message #472884] Thu, 10 May 2007 23:57 Go to previous messageGo to next message
Pradeep is currently offline PradeepFriend
Messages: 54
Registered: July 2009
Member
Hi Ed,

Also, Do you think there is a better way to create template variables. I
just reapplied the technique you suggested for creating arrays in my
previous post.

Suppose if I want to create an interface like

public interface Evaluate<E extends Datum>
{
Double eval(E input);
}

How should i proceed?

Thanks
pradeep


"Ed Merks" <merks@ca.ibm.com> wrote in message
news:f209lo$5hf$1@build.eclipse.org...
> Pradeep,
>
> I'll need to see an Ecore model that reproduces this problem to comment.
> It could be a bug, but without an example, who knows...
>
>
> Pradeep wrote:
>> Hi,
>>
>> I created a uml primitive type with Map<String, Datum> and assigned it to
>> content variable in a class.
>> Now when I convert it to Ecore then to code, I am getting the following
>> code. If you see the eUnset function there is proper cast but there is
>> none in eSet function. The compiler is complaining about the same saying
>> it cannot accept object.
>>
>> How can I avoid this.
>>
>> /**
>>
>> * <!-- begin-user-doc -->
>>
>> * <!-- end-user-doc -->
>>
>> * @generated
>>
>> */
>>
>> @SuppressWarnings("unchecked")
>>
>> @Override
>>
>> public void eSet(int featureID, Object newValue) {
>>
>> switch (featureID) {
>>
>> case NewheadPackage.DATA_MAP__CONTENT:
>>
>> setContent(newValue);
>>
>> return;
>>
>> }
>>
>> super.eSet(featureID, newValue);
>>
>> }
>>
>>
>> /**
>>
>> * <!-- begin-user-doc -->
>>
>> * <!-- end-user-doc -->
>>
>> * @generated
>>
>> */
>>
>> @Override
>>
>> public void eUnset(int featureID) {
>>
>> switch (featureID) {
>>
>> case NewheadPackage.DATA_MAP__CONTENT:
>>
>> setContent((Map<String, Datum>)null);
>>
>> return;
>>
>> }
>>
>> super.eUnset(featureID);
>>
>> }
>>
>>
>>
Re: No Cast in case of templates [message #472887 is a reply to message #472885] Fri, 11 May 2007 00:46 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------070205040900030509060607
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Pradeep,

You need to use fully qualified names in the instance class name, i.e.,
use java.util.Map<java.lang.String, java.lang.String>.

Pradeep wrote:
> Please find the uml file attached. I used the file to generate genmodel and
> then code.
>
> Please import java.util.Map in the generated code.
>
>
>
> "Ed Merks" <merks@ca.ibm.com> wrote in message
> news:f209lo$5hf$1@build.eclipse.org...
>
>> Pradeep,
>>
>> I'll need to see an Ecore model that reproduces this problem to
>> comment. It could be a bug, but without an example, who knows...
>>
>>
>> Pradeep wrote:
>>
>>> Hi,
>>>
>>> I created a uml primitive type with Map<String, Datum> and assigned it to
>>> content variable in a class.
>>> Now when I convert it to Ecore then to code, I am getting the following
>>> code. If you see the eUnset function there is proper cast but there is
>>> none
>>> in eSet function. The compiler is complaining about the same saying it
>>> cannot accept object.
>>>
>>> How can I avoid this.
>>>
>>> /**
>>>
>>> * <!-- begin-user-doc -->
>>>
>>> * <!-- end-user-doc -->
>>>
>>> * @generated
>>>
>>> */
>>>
>>> @SuppressWarnings("unchecked")
>>>
>>> @Override
>>>
>>> public void eSet(int featureID, Object newValue) {
>>>
>>> switch (featureID) {
>>>
>>> case NewheadPackage.DATA_MAP__CONTENT:
>>>
>>> setContent(newValue);
>>>
>>> return;
>>>
>>> }
>>>
>>> super.eSet(featureID, newValue);
>>>
>>> }
>>>
>>>
>>> /**
>>>
>>> * <!-- begin-user-doc -->
>>>
>>> * <!-- end-user-doc -->
>>>
>>> * @generated
>>>
>>> */
>>>
>>> @Override
>>>
>>> public void eUnset(int featureID) {
>>>
>>> switch (featureID) {
>>>
>>> case NewheadPackage.DATA_MAP__CONTENT:
>>>
>>> setContent((Map<String, Datum>)null);
>>>
>>> return;
>>>
>>> }
>>>
>>> super.eUnset(featureID);
>>>
>>> }
>>>
>>>
>>>
>>>
>
>
>


--------------070205040900030509060607
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">
Pradeep,<br>
<br>
You need to use fully qualified names in the instance class name, i.e.,
use java.util.Map&lt;java.lang.String, java.lang.String&gt;.<br>
<br>
Pradeep wrote:
<blockquote cite="midf20avl$7mv$1@build.eclipse.org" type="cite">
<pre wrap="">Please find the uml file attached. I used the file to generate genmodel and
then code.

Please import java.util.Map in the generated code.



"Ed Merks" <a class="moz-txt-link-rfc2396E" href="mailto:merks@ca.ibm.com">&lt;merks@ca.ibm.com&gt;</a> wrote in message
<a class="moz-txt-link-freetext" href="news:f209lo$5hf$1@build.eclipse.org">news:f209lo$5hf$1@build.eclipse.org</a>...
</pre>
<blockquote type="cite">
<pre wrap="">Pradeep,

I'll need to see an Ecore model that reproduces this problem to
comment. It could be a bug, but without an example, who knows...


Pradeep wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi,

I created a uml primitive type with Map&lt;String, Datum&gt; and assigned it to
content variable in a class.
Now when I convert it to Ecore then to code, I am getting the following
code. If you see the eUnset function there is proper cast but there is
none
in eSet function. The compiler is complaining about the same saying it
cannot accept object.

How can I avoid this.

/**

* &lt;!-- begin-user-doc --&gt;

* &lt;!-- end-user-doc --&gt;

* @generated

*/

@SuppressWarnings("unchecked")

@Override

public void eSet(int featureID, Object newValue) {

switch (featureID) {

case NewheadPackage.DATA_MAP__CONTENT:

setContent(newValue);

return;

}

super.eSet(featureID, newValue);

}


/**

* &lt;!-- begin-user-doc --&gt;

* &lt;!-- end-user-doc --&gt;

* @generated

*/

@Override

public void eUnset(int featureID) {

switch (featureID) {

case NewheadPackage.DATA_MAP__CONTENT:

setContent((Map&lt;String, Datum&gt;)null);

return;

}

super.eUnset(featureID);

}



</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->

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

--------------070205040900030509060607--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: No Cast in case of templates [message #472888 is a reply to message #472886] Fri, 11 May 2007 00:55 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------000904080807020303060403
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Pradeep,

It's a UML2 question. In the Ecore editor you can create this directly,
but I'm not sure how to express it in UML2. I produced the attached UML
by modifying your example's .ecore and exporting it to UML.


Pradeep wrote:
> Hi Ed,
>
> Also, Do you think there is a better way to create template variables. I
> just reapplied the technique you suggested for creating arrays in my
> previous post.
>
> Suppose if I want to create an interface like
>
> public interface Evaluate<E extends Datum>
> {
> Double eval(E input);
> }
>
> How should i proceed?
>
> Thanks
> pradeep
>
>
> "Ed Merks" <merks@ca.ibm.com> wrote in message
> news:f209lo$5hf$1@build.eclipse.org...
>
>> Pradeep,
>>
>> I'll need to see an Ecore model that reproduces this problem to comment.
>> It could be a bug, but without an example, who knows...
>>
>>
>> Pradeep wrote:
>>
>>> Hi,
>>>
>>> I created a uml primitive type with Map<String, Datum> and assigned it to
>>> content variable in a class.
>>> Now when I convert it to Ecore then to code, I am getting the following
>>> code. If you see the eUnset function there is proper cast but there is
>>> none in eSet function. The compiler is complaining about the same saying
>>> it cannot accept object.
>>>
>>> How can I avoid this.
>>>
>>> /**
>>>
>>> * <!-- begin-user-doc -->
>>>
>>> * <!-- end-user-doc -->
>>>
>>> * @generated
>>>
>>> */
>>>
>>> @SuppressWarnings("unchecked")
>>>
>>> @Override
>>>
>>> public void eSet(int featureID, Object newValue) {
>>>
>>> switch (featureID) {
>>>
>>> case NewheadPackage.DATA_MAP__CONTENT:
>>>
>>> setContent(newValue);
>>>
>>> return;
>>>
>>> }
>>>
>>> super.eSet(featureID, newValue);
>>>
>>> }
>>>
>>>
>>> /**
>>>
>>> * <!-- begin-user-doc -->
>>>
>>> * <!-- end-user-doc -->
>>>
>>> * @generated
>>>
>>> */
>>>
>>> @Override
>>>
>>> public void eUnset(int featureID) {
>>>
>>> switch (featureID) {
>>>
>>> case NewheadPackage.DATA_MAP__CONTENT:
>>>
>>> setContent((Map<String, Datum>)null);
>>>
>>> return;
>>>
>>> }
>>>
>>> super.eUnset(featureID);
>>>
>>> }
>>>
>>>
>>>
>>>
>
>
>


--------------000904080807020303060403
Content-Type: text/xml;
name="test.uml"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="test.uml"

<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:Ecore="http://www.eclipse.org/uml2/schemas/Ecore/4" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:uml="http://www.eclipse.org/uml2/2.1.0/UML" xsi:schemaLocation="http://www.eclipse.org/uml2/schemas/Ecore/4 pathmap://UML_PROFILES/Ecore.profile.uml#_B7dOIMEREduRdatXod jBjA">
<uml:Model xmi:id="_8Pp2gP9ZEdu2-NJ3YDjyEA" name="test">
<packagedElement xmi:type="uml:PrimitiveType" xmi:id="_8Pp2gf9ZEdu2-NJ3YDjyEA" name="MapStringString"/>
<packagedElement xmi:type="uml:Class" xmi:id="_8Pp2gv9ZEdu2-NJ3YDjyEA" name="DataBag">
<ownedTemplateSignature xmi:type="uml:RedefinableTemplateSignature" xmi:id="_8Pp2g_9ZEdu2-NJ3YDjyEA" parameter="_8Pp2hP9ZEdu2-NJ3YDjyEA">
<ownedParameter xmi:type="uml:ClassifierTemplateParameter" xmi:id="_8Pp2hP9ZEdu2-NJ3YDjyEA" parameteredElement="_8Pp2hf9ZEdu2-NJ3YDjyEA">
<ownedParameteredElement xmi:type="uml:Class" xmi:id="_8Pp2hf9ZEdu2-NJ3YDjyEA" name="E" templateParameter="_8Pp2hP9ZEdu2-NJ3YDjyEA"/>
</ownedParameter>
</ownedTemplateSignature>
<ownedAttribute xmi:id="_8Pp2hv9ZEdu2-NJ3YDjyEA" name="content" visibility="public" type="_8Pp2gf9ZEdu2-NJ3YDjyEA"/>
<ownedOperation xmi:id="_8Pp2h_9ZEdu2-NJ3YDjyEA" name="eval" visibility="public">
<ownedParameter xmi:id="_8Pp2iP9ZEdu2-NJ3YDjyEA" isOrdered="true" direction="return">
<lowerValue xmi:type="uml:LiteralInteger" xmi:id="_8Pp2if9ZEdu2-NJ3YDjyEA"/>
</ownedParameter>
<ownedParameter xmi:id="_8Pp2iv9ZEdu2-NJ3YDjyEA" name="input" type="_8Pp2hf9ZEdu2-NJ3YDjyEA" isOrdered="true">
<lowerValue xmi:type="uml:LiteralInteger" xmi:id="_8Pp2i_9ZEdu2-NJ3YDjyEA"/>
</ownedParameter>
</ownedOperation>
</packagedElement>
<profileApplication xmi:id="_8Pp2jP9ZEdu2-NJ3YDjyEA">
<eAnnotations xmi:id="_8Pp2jf9ZEdu2-NJ3YDjyEA" source="http://www.eclipse.org/uml2/2.0.0/UML">
<references xmi:type="ecore:EPackage" href=" pathmap://UML_PROFILES/Ecore.profile.uml#_B7dOIMEREduRdatXod jBjA"/>
</eAnnotations>
<appliedProfile href="pathmap://UML_PROFILES/Ecore.profile.uml#_0"/>
</profileApplication>
</uml:Model>
<Ecore:EPackage xmi:id="_8Pp2jv9ZEdu2-NJ3YDjyEA" base_Package="_8Pp2gP9ZEdu2-NJ3YDjyEA" nsPrefix="test" nsURI="http:///test.ecore"/>
<Ecore:EDataType xmi:id="_8Pp2j_9ZEdu2-NJ3YDjyEA" instanceClassName="Map&lt;String, String>" base_PrimitiveType="_8Pp2gf9ZEdu2-NJ3YDjyEA"/>
<Ecore:EClass xmi:id="_8Pp2kP9ZEdu2-NJ3YDjyEA" base_Class="_8Pp2gv9ZEdu2-NJ3YDjyEA"/>
<Ecore:ETypeParameter xmi:id="_8Pp2kf9ZEdu2-NJ3YDjyEA" base_TemplateParameter="_8Pp2hP9ZEdu2-NJ3YDjyEA">
<bounds xmi:type="uml:PrimitiveType" href=" pathmap://UML_LIBRARIES/EcorePrimitiveTypes.library.uml#EStr ing"/>
</Ecore:ETypeParameter>
<Ecore:EAttribute xmi:id="_8Pp2kv9ZEdu2-NJ3YDjyEA" base_Property="_8Pp2hv9ZEdu2-NJ3YDjyEA"/>
<Ecore:EOperation xmi:id="_8Pp2k_9ZEdu2-NJ3YDjyEA" base_Operation="_8Pp2h_9ZEdu2-NJ3YDjyEA"/>
<Ecore:EParameter xmi:id="_8Pp2lP9ZEdu2-NJ3YDjyEA" base_Parameter="_8Pp2iv9ZEdu2-NJ3YDjyEA"/>
</xmi:XMI>

--------------000904080807020303060403--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: No Cast in case of templates [message #472889 is a reply to message #472887] Fri, 11 May 2007 03:03 Go to previous messageGo to next message
Pradeep is currently offline PradeepFriend
Messages: 54
Registered: July 2009
Member
This is a multi-part message in MIME format.

------=_NextPart_000_0181_01C7933E.3AFEC8E0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Thanks a lot. That worked.
"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:f20ecd$112$1@build.eclipse.org...
Pradeep,

You need to use fully qualified names in the instance class name, =
i.e., use java.util.Map<java.lang.String, java.lang.String>.

Pradeep wrote:=20
Please find the uml file attached. I used the file to generate genmodel =
and=20
then code.

Please import java.util.Map in the generated code.



"Ed Merks" <merks@ca.ibm.com> wrote in message=20
news:f209lo$5hf$1@build.eclipse.org...
Pradeep,

I'll need to see an Ecore model that reproduces this problem to
comment. It could be a bug, but without an example, who knows...


Pradeep wrote:
Hi,

I created a uml primitive type with Map<String, Datum> and assigned it =
to
content variable in a class.
Now when I convert it to Ecore then to code, I am getting the following
code. If you see the eUnset function there is proper cast but there is=20
none
in eSet function. The compiler is complaining about the same saying it
cannot accept object.

How can I avoid this.

/**

* <!-- begin-user-doc -->

* <!-- end-user-doc -->

* @generated

*/

@SuppressWarnings("unchecked")

@Override

public void eSet(int featureID, Object newValue) {

switch (featureID) {

case NewheadPackage.DATA_MAP__CONTENT:

setContent(newValue);

return;

}

super.eSet(featureID, newValue);

}


/**

* <!-- begin-user-doc -->

* <!-- end-user-doc -->

* @generated

*/

@Override

public void eUnset(int featureID) {

switch (featureID) {

case NewheadPackage.DATA_MAP__CONTENT:

setContent((Map<String, Datum>)null);

return;

}

super.eUnset(featureID);

}



=20

=20

------=_NextPart_000_0181_01C7933E.3AFEC8E0
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.6000.16414" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Thanks a lot. That worked.</FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A =
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt;=20
wrote in message <A=20
=
href=3D"news:f20ecd$112$1@build.eclipse.org">news:f20ecd$112$1@build.ecli=
pse.org</A>...</DIV>Pradeep,<BR><BR>You=20
need to use fully qualified names in the instance class name, i.e., =
use=20
java.util.Map&lt;java.lang.String, =
java.lang.String&gt;.<BR><BR>Pradeep wrote:=20

<BLOCKQUOTE cite=3Dmidf20avl$7mv$1@build.eclipse.org =
type=3D"cite"><PRE wrap=3D"">Please find the uml file attached. I used =
the file to generate genmodel and=20
then code.

Please import java.util.Map in the generated code.



"Ed Merks" <A class=3Dmoz-txt-link-rfc2396E =
href=3D"mailto:merks@ca.ibm.com">&lt;merks@ca.ibm.com&gt;</A> wrote in =
message=20
<A class=3Dmoz-txt-link-freetext =
href=3D"news:f209lo$5hf$1@build.eclipse.org">news:f209lo$5hf$1@build.ecli=
pse.org</A>...
</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">Pradeep,

I'll need to see an Ecore model that reproduces this problem to
comment. It could be a bug, but without an example, who knows...


Pradeep wrote:
</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">Hi,

I created a uml primitive type with Map&lt;String, Datum&gt; and =
assigned it to
content variable in a class.
Now when I convert it to Ecore then to code, I am getting the following
code. If you see the eUnset function there is proper cast but there is=20
none
in eSet function. The compiler is complaining about the same saying it
cannot accept object.

How can I avoid this.

/**

* &lt;!-- begin-user-doc --&gt;

* &lt;!-- end-user-doc --&gt;

* @generated

*/

@SuppressWarnings("unchecked")

@Override

public void eSet(int featureID, Object newValue) {

switch (featureID) {

case NewheadPackage.DATA_MAP__CONTENT:

setContent(newValue);

return;

}

super.eSet(featureID, newValue);

}


/**

* &lt;!-- begin-user-doc --&gt;

* &lt;!-- end-user-doc --&gt;

* @generated

*/

@Override

public void eUnset(int featureID) {

switch (featureID) {

case NewheadPackage.DATA_MAP__CONTENT:

setContent((Map&lt;String, Datum&gt;)null);

return;

}

super.eUnset(featureID);

}



</PRE></BLOCKQUOTE></BLOCKQUOTE><PRE wrap=3D""><!---->

</PRE></BLOCKQUOTE><BR></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_0181_01C7933E.3AFEC8E0--
Re: No Cast in case of templates [message #472890 is a reply to message #472888] Fri, 11 May 2007 03:04 Go to previous messageGo to next message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
The draft document at https://bugs.eclipse.org/bugs/attachment.cgi?id=57909
describes how UML templates map to Ecore generics. We will be focusing on
documentation (polishing this and other articles, etc.) once we declare M7
for this release.

Kenn

"Ed Merks" <merks@ca.ibm.com> wrote in message
news:f20euk$8tb$1@build.eclipse.org...
> Pradeep,
>
> It's a UML2 question. In the Ecore editor you can create this directly,
> but I'm not sure how to express it in UML2. I produced the attached UML
> by modifying your example's .ecore and exporting it to UML.
>
>
> Pradeep wrote:
>> Hi Ed,
>>
>> Also, Do you think there is a better way to create template variables. I
>> just reapplied the technique you suggested for creating arrays in my
>> previous post.
>>
>> Suppose if I want to create an interface like
>>
>> public interface Evaluate<E extends Datum>
>> {
>> Double eval(E input);
>> }
>>
>> How should i proceed?
>>
>> Thanks
>> pradeep
>>
>>
>> "Ed Merks" <merks@ca.ibm.com> wrote in message
>> news:f209lo$5hf$1@build.eclipse.org...
>>
>>> Pradeep,
>>>
>>> I'll need to see an Ecore model that reproduces this problem to comment.
>>> It could be a bug, but without an example, who knows...
>>>
>>>
>>> Pradeep wrote:
>>>
>>>> Hi,
>>>>
>>>> I created a uml primitive type with Map<String, Datum> and assigned it
>>>> to
>>>> content variable in a class.
>>>> Now when I convert it to Ecore then to code, I am getting the following
>>>> code. If you see the eUnset function there is proper cast but there is
>>>> none in eSet function. The compiler is complaining about the same
>>>> saying
>>>> it cannot accept object.
>>>>
>>>> How can I avoid this.
>>>>
>>>> /**
>>>>
>>>> * <!-- begin-user-doc -->
>>>>
>>>> * <!-- end-user-doc -->
>>>>
>>>> * @generated
>>>>
>>>> */
>>>>
>>>> @SuppressWarnings("unchecked")
>>>>
>>>> @Override
>>>>
>>>> public void eSet(int featureID, Object newValue) {
>>>>
>>>> switch (featureID) {
>>>>
>>>> case NewheadPackage.DATA_MAP__CONTENT:
>>>>
>>>> setContent(newValue);
>>>>
>>>> return;
>>>>
>>>> }
>>>>
>>>> super.eSet(featureID, newValue);
>>>>
>>>> }
>>>>
>>>>
>>>> /**
>>>>
>>>> * <!-- begin-user-doc -->
>>>>
>>>> * <!-- end-user-doc -->
>>>>
>>>> * @generated
>>>>
>>>> */
>>>>
>>>> @Override
>>>>
>>>> public void eUnset(int featureID) {
>>>>
>>>> switch (featureID) {
>>>>
>>>> case NewheadPackage.DATA_MAP__CONTENT:
>>>>
>>>> setContent((Map<String, Datum>)null);
>>>>
>>>> return;
>>>>
>>>> }
>>>>
>>>> super.eUnset(featureID);
>>>>
>>>> }
>>>>
>>>>
>>>>
>>>>
>>
>>
>>
>
>


------------------------------------------------------------ --------------------


> <?xml version="1.0" encoding="UTF-8"?>
> <xmi:XMI xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:Ecore="http://www.eclipse.org/uml2/schemas/Ecore/4"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
> xmlns:uml="http://www.eclipse.org/uml2/2.1.0/UML"
> xsi:schemaLocation="http://www.eclipse.org/uml2/schemas/Ecore/4
> pathmap://UML_PROFILES/Ecore.profile.uml#_B7dOIMEREduRdatXod jBjA">
> <uml:Model xmi:id="_8Pp2gP9ZEdu2-NJ3YDjyEA" name="test">
> <packagedElement xmi:type="uml:PrimitiveType"
> xmi:id="_8Pp2gf9ZEdu2-NJ3YDjyEA" name="MapStringString"/>
> <packagedElement xmi:type="uml:Class" xmi:id="_8Pp2gv9ZEdu2-NJ3YDjyEA"
> name="DataBag">
> <ownedTemplateSignature xmi:type="uml:RedefinableTemplateSignature"
> xmi:id="_8Pp2g_9ZEdu2-NJ3YDjyEA" parameter="_8Pp2hP9ZEdu2-NJ3YDjyEA">
> <ownedParameter xmi:type="uml:ClassifierTemplateParameter"
> xmi:id="_8Pp2hP9ZEdu2-NJ3YDjyEA"
> parameteredElement="_8Pp2hf9ZEdu2-NJ3YDjyEA">
> <ownedParameteredElement xmi:type="uml:Class"
> xmi:id="_8Pp2hf9ZEdu2-NJ3YDjyEA" name="E"
> templateParameter="_8Pp2hP9ZEdu2-NJ3YDjyEA"/>
> </ownedParameter>
> </ownedTemplateSignature>
> <ownedAttribute xmi:id="_8Pp2hv9ZEdu2-NJ3YDjyEA" name="content"
> visibility="public" type="_8Pp2gf9ZEdu2-NJ3YDjyEA"/>
> <ownedOperation xmi:id="_8Pp2h_9ZEdu2-NJ3YDjyEA" name="eval"
> visibility="public">
> <ownedParameter xmi:id="_8Pp2iP9ZEdu2-NJ3YDjyEA" isOrdered="true"
> direction="return">
> <lowerValue xmi:type="uml:LiteralInteger"
> xmi:id="_8Pp2if9ZEdu2-NJ3YDjyEA"/>
> </ownedParameter>
> <ownedParameter xmi:id="_8Pp2iv9ZEdu2-NJ3YDjyEA" name="input"
> type="_8Pp2hf9ZEdu2-NJ3YDjyEA" isOrdered="true">
> <lowerValue xmi:type="uml:LiteralInteger"
> xmi:id="_8Pp2i_9ZEdu2-NJ3YDjyEA"/>
> </ownedParameter>
> </ownedOperation>
> </packagedElement>
> <profileApplication xmi:id="_8Pp2jP9ZEdu2-NJ3YDjyEA">
> <eAnnotations xmi:id="_8Pp2jf9ZEdu2-NJ3YDjyEA"
> source="http://www.eclipse.org/uml2/2.0.0/UML">
> <references xmi:type="ecore:EPackage"
> href=" pathmap://UML_PROFILES/Ecore.profile.uml#_B7dOIMEREduRdatXod jBjA"/>
> </eAnnotations>
> <appliedProfile href="pathmap://UML_PROFILES/Ecore.profile.uml#_0"/>
> </profileApplication>
> </uml:Model>
> <Ecore:EPackage xmi:id="_8Pp2jv9ZEdu2-NJ3YDjyEA"
> base_Package="_8Pp2gP9ZEdu2-NJ3YDjyEA" nsPrefix="test"
> nsURI="http:///test.ecore"/>
> <Ecore:EDataType xmi:id="_8Pp2j_9ZEdu2-NJ3YDjyEA"
> instanceClassName="Map&lt;String, String>"
> base_PrimitiveType="_8Pp2gf9ZEdu2-NJ3YDjyEA"/>
> <Ecore:EClass xmi:id="_8Pp2kP9ZEdu2-NJ3YDjyEA"
> base_Class="_8Pp2gv9ZEdu2-NJ3YDjyEA"/>
> <Ecore:ETypeParameter xmi:id="_8Pp2kf9ZEdu2-NJ3YDjyEA"
> base_TemplateParameter="_8Pp2hP9ZEdu2-NJ3YDjyEA">
> <bounds xmi:type="uml:PrimitiveType"
> href=" pathmap://UML_LIBRARIES/EcorePrimitiveTypes.library.uml#EStr ing"/>
> </Ecore:ETypeParameter>
> <Ecore:EAttribute xmi:id="_8Pp2kv9ZEdu2-NJ3YDjyEA"
> base_Property="_8Pp2hv9ZEdu2-NJ3YDjyEA"/>
> <Ecore:EOperation xmi:id="_8Pp2k_9ZEdu2-NJ3YDjyEA"
> base_Operation="_8Pp2h_9ZEdu2-NJ3YDjyEA"/>
> <Ecore:EParameter xmi:id="_8Pp2lP9ZEdu2-NJ3YDjyEA"
> base_Parameter="_8Pp2iv9ZEdu2-NJ3YDjyEA"/>
> </xmi:XMI>
>
Re: No Cast in case of templates [message #472892 is a reply to message #472890] Fri, 11 May 2007 04:34 Go to previous messageGo to next message
Pradeep is currently offline PradeepFriend
Messages: 54
Registered: July 2009
Member
Hi Ed and Kenn,

Somehow my UML editor is not opening the UML file sent by Ed.

The word document, even though incomplete, helped me a lot. I am able
achieve the different template definitions that I want using the illustrated
figures.

Actually both EMF and UML2 has more support for Generics than I thought. I
recently listened to a podcast by Ed in which he said that while Ecore
generates generic classes, support for user defined generic classes is
little into the future. I didn't realize he literally meant "little". :)

Thanks once again for both of you.

Pradeep



"Kenn Hussey" <khussey@ca.ibm.com> wrote in message
news:f20mfs$l38$1@build.eclipse.org...
> The draft document at
> https://bugs.eclipse.org/bugs/attachment.cgi?id=57909 describes how UML
> templates map to Ecore generics. We will be focusing on documentation
> (polishing this and other articles, etc.) once we declare M7 for this
> release.
>
> Kenn
>
> "Ed Merks" <merks@ca.ibm.com> wrote in message
> news:f20euk$8tb$1@build.eclipse.org...
>> Pradeep,
>>
>> It's a UML2 question. In the Ecore editor you can create this directly,
>> but I'm not sure how to express it in UML2. I produced the attached UML
>> by modifying your example's .ecore and exporting it to UML.
>>
>>
>> Pradeep wrote:
>>> Hi Ed,
>>>
>>> Also, Do you think there is a better way to create template variables. I
>>> just reapplied the technique you suggested for creating arrays in my
>>> previous post.
>>>
>>> Suppose if I want to create an interface like
>>>
>>> public interface Evaluate<E extends Datum>
>>> {
>>> Double eval(E input);
>>> }
>>>
>>> How should i proceed?
>>>
>>> Thanks
>>> pradeep
>>>
>>>
>>> "Ed Merks" <merks@ca.ibm.com> wrote in message
>>> news:f209lo$5hf$1@build.eclipse.org...
>>>
>>>> Pradeep,
>>>>
>>>> I'll need to see an Ecore model that reproduces this problem to
>>>> comment.
>>>> It could be a bug, but without an example, who knows...
>>>>
>>>>
>>>> Pradeep wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I created a uml primitive type with Map<String, Datum> and assigned it
>>>>> to
>>>>> content variable in a class.
>>>>> Now when I convert it to Ecore then to code, I am getting the
>>>>> following
>>>>> code. If you see the eUnset function there is proper cast but there is
>>>>> none in eSet function. The compiler is complaining about the same
>>>>> saying
>>>>> it cannot accept object.
>>>>>
>>>>> How can I avoid this.
>>>>>
>>>>> /**
>>>>>
>>>>> * <!-- begin-user-doc -->
>>>>>
>>>>> * <!-- end-user-doc -->
>>>>>
>>>>> * @generated
>>>>>
>>>>> */
>>>>>
>>>>> @SuppressWarnings("unchecked")
>>>>>
>>>>> @Override
>>>>>
>>>>> public void eSet(int featureID, Object newValue) {
>>>>>
>>>>> switch (featureID) {
>>>>>
>>>>> case NewheadPackage.DATA_MAP__CONTENT:
>>>>>
>>>>> setContent(newValue);
>>>>>
>>>>> return;
>>>>>
>>>>> }
>>>>>
>>>>> super.eSet(featureID, newValue);
>>>>>
>>>>> }
>>>>>
>>>>>
>>>>> /**
>>>>>
>>>>> * <!-- begin-user-doc -->
>>>>>
>>>>> * <!-- end-user-doc -->
>>>>>
>>>>> * @generated
>>>>>
>>>>> */
>>>>>
>>>>> @Override
>>>>>
>>>>> public void eUnset(int featureID) {
>>>>>
>>>>> switch (featureID) {
>>>>>
>>>>> case NewheadPackage.DATA_MAP__CONTENT:
>>>>>
>>>>> setContent((Map<String, Datum>)null);
>>>>>
>>>>> return;
>>>>>
>>>>> }
>>>>>
>>>>> super.eUnset(featureID);
>>>>>
>>>>> }
>>>>>
>>>>>
>>>>>
>>>>>
>>>
>>>
>>>
>>
>>
>
>
> ------------------------------------------------------------ --------------------
>
>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <xmi:XMI xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xmlns:Ecore="http://www.eclipse.org/uml2/schemas/Ecore/4"
>> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
>> xmlns:uml="http://www.eclipse.org/uml2/2.1.0/UML"
>> xsi:schemaLocation="http://www.eclipse.org/uml2/schemas/Ecore/4
>> pathmap://UML_PROFILES/Ecore.profile.uml#_B7dOIMEREduRdatXod jBjA">
>> <uml:Model xmi:id="_8Pp2gP9ZEdu2-NJ3YDjyEA" name="test">
>> <packagedElement xmi:type="uml:PrimitiveType"
>> xmi:id="_8Pp2gf9ZEdu2-NJ3YDjyEA" name="MapStringString"/>
>> <packagedElement xmi:type="uml:Class" xmi:id="_8Pp2gv9ZEdu2-NJ3YDjyEA"
>> name="DataBag">
>> <ownedTemplateSignature xmi:type="uml:RedefinableTemplateSignature"
>> xmi:id="_8Pp2g_9ZEdu2-NJ3YDjyEA" parameter="_8Pp2hP9ZEdu2-NJ3YDjyEA">
>> <ownedParameter xmi:type="uml:ClassifierTemplateParameter"
>> xmi:id="_8Pp2hP9ZEdu2-NJ3YDjyEA"
>> parameteredElement="_8Pp2hf9ZEdu2-NJ3YDjyEA">
>> <ownedParameteredElement xmi:type="uml:Class"
>> xmi:id="_8Pp2hf9ZEdu2-NJ3YDjyEA" name="E"
>> templateParameter="_8Pp2hP9ZEdu2-NJ3YDjyEA"/>
>> </ownedParameter>
>> </ownedTemplateSignature>
>> <ownedAttribute xmi:id="_8Pp2hv9ZEdu2-NJ3YDjyEA" name="content"
>> visibility="public" type="_8Pp2gf9ZEdu2-NJ3YDjyEA"/>
>> <ownedOperation xmi:id="_8Pp2h_9ZEdu2-NJ3YDjyEA" name="eval"
>> visibility="public">
>> <ownedParameter xmi:id="_8Pp2iP9ZEdu2-NJ3YDjyEA" isOrdered="true"
>> direction="return">
>> <lowerValue xmi:type="uml:LiteralInteger"
>> xmi:id="_8Pp2if9ZEdu2-NJ3YDjyEA"/>
>> </ownedParameter>
>> <ownedParameter xmi:id="_8Pp2iv9ZEdu2-NJ3YDjyEA" name="input"
>> type="_8Pp2hf9ZEdu2-NJ3YDjyEA" isOrdered="true">
>> <lowerValue xmi:type="uml:LiteralInteger"
>> xmi:id="_8Pp2i_9ZEdu2-NJ3YDjyEA"/>
>> </ownedParameter>
>> </ownedOperation>
>> </packagedElement>
>> <profileApplication xmi:id="_8Pp2jP9ZEdu2-NJ3YDjyEA">
>> <eAnnotations xmi:id="_8Pp2jf9ZEdu2-NJ3YDjyEA"
>> source="http://www.eclipse.org/uml2/2.0.0/UML">
>> <references xmi:type="ecore:EPackage"
>> href=" pathmap://UML_PROFILES/Ecore.profile.uml#_B7dOIMEREduRdatXod jBjA"/>
>> </eAnnotations>
>> <appliedProfile href="pathmap://UML_PROFILES/Ecore.profile.uml#_0"/>
>> </profileApplication>
>> </uml:Model>
>> <Ecore:EPackage xmi:id="_8Pp2jv9ZEdu2-NJ3YDjyEA"
>> base_Package="_8Pp2gP9ZEdu2-NJ3YDjyEA" nsPrefix="test"
>> nsURI="http:///test.ecore"/>
>> <Ecore:EDataType xmi:id="_8Pp2j_9ZEdu2-NJ3YDjyEA"
>> instanceClassName="Map&lt;String, String>"
>> base_PrimitiveType="_8Pp2gf9ZEdu2-NJ3YDjyEA"/>
>> <Ecore:EClass xmi:id="_8Pp2kP9ZEdu2-NJ3YDjyEA"
>> base_Class="_8Pp2gv9ZEdu2-NJ3YDjyEA"/>
>> <Ecore:ETypeParameter xmi:id="_8Pp2kf9ZEdu2-NJ3YDjyEA"
>> base_TemplateParameter="_8Pp2hP9ZEdu2-NJ3YDjyEA">
>> <bounds xmi:type="uml:PrimitiveType"
>> href=" pathmap://UML_LIBRARIES/EcorePrimitiveTypes.library.uml#EStr ing"/>
>> </Ecore:ETypeParameter>
>> <Ecore:EAttribute xmi:id="_8Pp2kv9ZEdu2-NJ3YDjyEA"
>> base_Property="_8Pp2hv9ZEdu2-NJ3YDjyEA"/>
>> <Ecore:EOperation xmi:id="_8Pp2k_9ZEdu2-NJ3YDjyEA"
>> base_Operation="_8Pp2h_9ZEdu2-NJ3YDjyEA"/>
>> <Ecore:EParameter xmi:id="_8Pp2lP9ZEdu2-NJ3YDjyEA"
>> base_Parameter="_8Pp2iv9ZEdu2-NJ3YDjyEA"/>
>> </xmi:XMI>
>>
>
>
Re: No Cast in case of templates [message #472896 is a reply to message #472892] Fri, 11 May 2007 20:34 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Pradeep,

To open the model Ed sent you, you'll need to use the latest integration
build of UML2 (I200705111324). This is because the namespace URI for UML2
changed, as previously announced on the newsgroup.

Kenn

"Pradeep" <eclipseuser123@yahoo.com> wrote in message
news:f20rp1$v73$1@build.eclipse.org...
> Hi Ed and Kenn,
>
> Somehow my UML editor is not opening the UML file sent by Ed.
>
> The word document, even though incomplete, helped me a lot. I am able
> achieve the different template definitions that I want using the
> illustrated figures.
>
> Actually both EMF and UML2 has more support for Generics than I thought. I
> recently listened to a podcast by Ed in which he said that while Ecore
> generates generic classes, support for user defined generic classes is
> little into the future. I didn't realize he literally meant "little". :)
>
> Thanks once again for both of you.
>
> Pradeep
>
>
>
> "Kenn Hussey" <khussey@ca.ibm.com> wrote in message
> news:f20mfs$l38$1@build.eclipse.org...
>> The draft document at
>> https://bugs.eclipse.org/bugs/attachment.cgi?id=57909 describes how UML
>> templates map to Ecore generics. We will be focusing on documentation
>> (polishing this and other articles, etc.) once we declare M7 for this
>> release.
>>
>> Kenn
>>
>> "Ed Merks" <merks@ca.ibm.com> wrote in message
>> news:f20euk$8tb$1@build.eclipse.org...
>>> Pradeep,
>>>
>>> It's a UML2 question. In the Ecore editor you can create this directly,
>>> but I'm not sure how to express it in UML2. I produced the attached UML
>>> by modifying your example's .ecore and exporting it to UML.
>>>
>>>
>>> Pradeep wrote:
>>>> Hi Ed,
>>>>
>>>> Also, Do you think there is a better way to create template variables.
>>>> I
>>>> just reapplied the technique you suggested for creating arrays in my
>>>> previous post.
>>>>
>>>> Suppose if I want to create an interface like
>>>>
>>>> public interface Evaluate<E extends Datum>
>>>> {
>>>> Double eval(E input);
>>>> }
>>>>
>>>> How should i proceed?
>>>>
>>>> Thanks
>>>> pradeep
>>>>
>>>>
>>>> "Ed Merks" <merks@ca.ibm.com> wrote in message
>>>> news:f209lo$5hf$1@build.eclipse.org...
>>>>
>>>>> Pradeep,
>>>>>
>>>>> I'll need to see an Ecore model that reproduces this problem to
>>>>> comment.
>>>>> It could be a bug, but without an example, who knows...
>>>>>
>>>>>
>>>>> Pradeep wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I created a uml primitive type with Map<String, Datum> and assigned
>>>>>> it to
>>>>>> content variable in a class.
>>>>>> Now when I convert it to Ecore then to code, I am getting the
>>>>>> following
>>>>>> code. If you see the eUnset function there is proper cast but there
>>>>>> is
>>>>>> none in eSet function. The compiler is complaining about the same
>>>>>> saying
>>>>>> it cannot accept object.
>>>>>>
>>>>>> How can I avoid this.
>>>>>>
>>>>>> /**
>>>>>>
>>>>>> * <!-- begin-user-doc -->
>>>>>>
>>>>>> * <!-- end-user-doc -->
>>>>>>
>>>>>> * @generated
>>>>>>
>>>>>> */
>>>>>>
>>>>>> @SuppressWarnings("unchecked")
>>>>>>
>>>>>> @Override
>>>>>>
>>>>>> public void eSet(int featureID, Object newValue) {
>>>>>>
>>>>>> switch (featureID) {
>>>>>>
>>>>>> case NewheadPackage.DATA_MAP__CONTENT:
>>>>>>
>>>>>> setContent(newValue);
>>>>>>
>>>>>> return;
>>>>>>
>>>>>> }
>>>>>>
>>>>>> super.eSet(featureID, newValue);
>>>>>>
>>>>>> }
>>>>>>
>>>>>>
>>>>>> /**
>>>>>>
>>>>>> * <!-- begin-user-doc -->
>>>>>>
>>>>>> * <!-- end-user-doc -->
>>>>>>
>>>>>> * @generated
>>>>>>
>>>>>> */
>>>>>>
>>>>>> @Override
>>>>>>
>>>>>> public void eUnset(int featureID) {
>>>>>>
>>>>>> switch (featureID) {
>>>>>>
>>>>>> case NewheadPackage.DATA_MAP__CONTENT:
>>>>>>
>>>>>> setContent((Map<String, Datum>)null);
>>>>>>
>>>>>> return;
>>>>>>
>>>>>> }
>>>>>>
>>>>>> super.eUnset(featureID);
>>>>>>
>>>>>> }
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>> ------------------------------------------------------------ --------------------
>>
>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <xmi:XMI xmi:version="2.1"
>>> xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>> xmlns:Ecore="http://www.eclipse.org/uml2/schemas/Ecore/4"
>>> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
>>> xmlns:uml="http://www.eclipse.org/uml2/2.1.0/UML"
>>> xsi:schemaLocation="http://www.eclipse.org/uml2/schemas/Ecore/4
>>> pathmap://UML_PROFILES/Ecore.profile.uml#_B7dOIMEREduRdatXod jBjA">
>>> <uml:Model xmi:id="_8Pp2gP9ZEdu2-NJ3YDjyEA" name="test">
>>> <packagedElement xmi:type="uml:PrimitiveType"
>>> xmi:id="_8Pp2gf9ZEdu2-NJ3YDjyEA" name="MapStringString"/>
>>> <packagedElement xmi:type="uml:Class"
>>> xmi:id="_8Pp2gv9ZEdu2-NJ3YDjyEA" name="DataBag">
>>> <ownedTemplateSignature xmi:type="uml:RedefinableTemplateSignature"
>>> xmi:id="_8Pp2g_9ZEdu2-NJ3YDjyEA" parameter="_8Pp2hP9ZEdu2-NJ3YDjyEA">
>>> <ownedParameter xmi:type="uml:ClassifierTemplateParameter"
>>> xmi:id="_8Pp2hP9ZEdu2-NJ3YDjyEA"
>>> parameteredElement="_8Pp2hf9ZEdu2-NJ3YDjyEA">
>>> <ownedParameteredElement xmi:type="uml:Class"
>>> xmi:id="_8Pp2hf9ZEdu2-NJ3YDjyEA" name="E"
>>> templateParameter="_8Pp2hP9ZEdu2-NJ3YDjyEA"/>
>>> </ownedParameter>
>>> </ownedTemplateSignature>
>>> <ownedAttribute xmi:id="_8Pp2hv9ZEdu2-NJ3YDjyEA" name="content"
>>> visibility="public" type="_8Pp2gf9ZEdu2-NJ3YDjyEA"/>
>>> <ownedOperation xmi:id="_8Pp2h_9ZEdu2-NJ3YDjyEA" name="eval"
>>> visibility="public">
>>> <ownedParameter xmi:id="_8Pp2iP9ZEdu2-NJ3YDjyEA" isOrdered="true"
>>> direction="return">
>>> <lowerValue xmi:type="uml:LiteralInteger"
>>> xmi:id="_8Pp2if9ZEdu2-NJ3YDjyEA"/>
>>> </ownedParameter>
>>> <ownedParameter xmi:id="_8Pp2iv9ZEdu2-NJ3YDjyEA" name="input"
>>> type="_8Pp2hf9ZEdu2-NJ3YDjyEA" isOrdered="true">
>>> <lowerValue xmi:type="uml:LiteralInteger"
>>> xmi:id="_8Pp2i_9ZEdu2-NJ3YDjyEA"/>
>>> </ownedParameter>
>>> </ownedOperation>
>>> </packagedElement>
>>> <profileApplication xmi:id="_8Pp2jP9ZEdu2-NJ3YDjyEA">
>>> <eAnnotations xmi:id="_8Pp2jf9ZEdu2-NJ3YDjyEA"
>>> source="http://www.eclipse.org/uml2/2.0.0/UML">
>>> <references xmi:type="ecore:EPackage"
>>> href=" pathmap://UML_PROFILES/Ecore.profile.uml#_B7dOIMEREduRdatXod jBjA"/>
>>> </eAnnotations>
>>> <appliedProfile
>>> href="pathmap://UML_PROFILES/Ecore.profile.uml#_0"/>
>>> </profileApplication>
>>> </uml:Model>
>>> <Ecore:EPackage xmi:id="_8Pp2jv9ZEdu2-NJ3YDjyEA"
>>> base_Package="_8Pp2gP9ZEdu2-NJ3YDjyEA" nsPrefix="test"
>>> nsURI="http:///test.ecore"/>
>>> <Ecore:EDataType xmi:id="_8Pp2j_9ZEdu2-NJ3YDjyEA"
>>> instanceClassName="Map&lt;String, String>"
>>> base_PrimitiveType="_8Pp2gf9ZEdu2-NJ3YDjyEA"/>
>>> <Ecore:EClass xmi:id="_8Pp2kP9ZEdu2-NJ3YDjyEA"
>>> base_Class="_8Pp2gv9ZEdu2-NJ3YDjyEA"/>
>>> <Ecore:ETypeParameter xmi:id="_8Pp2kf9ZEdu2-NJ3YDjyEA"
>>> base_TemplateParameter="_8Pp2hP9ZEdu2-NJ3YDjyEA">
>>> <bounds xmi:type="uml:PrimitiveType"
>>> href=" pathmap://UML_LIBRARIES/EcorePrimitiveTypes.library.uml#EStr ing"/>
>>> </Ecore:ETypeParameter>
>>> <Ecore:EAttribute xmi:id="_8Pp2kv9ZEdu2-NJ3YDjyEA"
>>> base_Property="_8Pp2hv9ZEdu2-NJ3YDjyEA"/>
>>> <Ecore:EOperation xmi:id="_8Pp2k_9ZEdu2-NJ3YDjyEA"
>>> base_Operation="_8Pp2h_9ZEdu2-NJ3YDjyEA"/>
>>> <Ecore:EParameter xmi:id="_8Pp2lP9ZEdu2-NJ3YDjyEA"
>>> base_Parameter="_8Pp2iv9ZEdu2-NJ3YDjyEA"/>
>>> </xmi:XMI>
>>>
>>
>>
>
>
Re: No Cast in case of templates [message #615690 is a reply to message #472883] Thu, 10 May 2007 23:25 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Pradeep,

I'll need to see an Ecore model that reproduces this problem to
comment. It could be a bug, but without an example, who knows...


Pradeep wrote:
> Hi,
>
> I created a uml primitive type with Map<String, Datum> and assigned it to
> content variable in a class.
> Now when I convert it to Ecore then to code, I am getting the following
> code. If you see the eUnset function there is proper cast but there is none
> in eSet function. The compiler is complaining about the same saying it
> cannot accept object.
>
> How can I avoid this.
>
> /**
>
> * <!-- begin-user-doc -->
>
> * <!-- end-user-doc -->
>
> * @generated
>
> */
>
> @SuppressWarnings("unchecked")
>
> @Override
>
> public void eSet(int featureID, Object newValue) {
>
> switch (featureID) {
>
> case NewheadPackage.DATA_MAP__CONTENT:
>
> setContent(newValue);
>
> return;
>
> }
>
> super.eSet(featureID, newValue);
>
> }
>
>
> /**
>
> * <!-- begin-user-doc -->
>
> * <!-- end-user-doc -->
>
> * @generated
>
> */
>
> @Override
>
> public void eUnset(int featureID) {
>
> switch (featureID) {
>
> case NewheadPackage.DATA_MAP__CONTENT:
>
> setContent((Map<String, Datum>)null);
>
> return;
>
> }
>
> super.eUnset(featureID);
>
> }
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: No Cast in case of templates [message #615691 is a reply to message #472884] Thu, 10 May 2007 23:48 Go to previous message
Pradeep is currently offline PradeepFriend
Messages: 54
Registered: July 2009
Member
Please find the uml file attached. I used the file to generate genmodel and
then code.

Please import java.util.Map in the generated code.



"Ed Merks" <merks@ca.ibm.com> wrote in message
news:f209lo$5hf$1@build.eclipse.org...
> Pradeep,
>
> I'll need to see an Ecore model that reproduces this problem to
> comment. It could be a bug, but without an example, who knows...
>
>
> Pradeep wrote:
>> Hi,
>>
>> I created a uml primitive type with Map<String, Datum> and assigned it to
>> content variable in a class.
>> Now when I convert it to Ecore then to code, I am getting the following
>> code. If you see the eUnset function there is proper cast but there is
>> none
>> in eSet function. The compiler is complaining about the same saying it
>> cannot accept object.
>>
>> How can I avoid this.
>>
>> /**
>>
>> * <!-- begin-user-doc -->
>>
>> * <!-- end-user-doc -->
>>
>> * @generated
>>
>> */
>>
>> @SuppressWarnings("unchecked")
>>
>> @Override
>>
>> public void eSet(int featureID, Object newValue) {
>>
>> switch (featureID) {
>>
>> case NewheadPackage.DATA_MAP__CONTENT:
>>
>> setContent(newValue);
>>
>> return;
>>
>> }
>>
>> super.eSet(featureID, newValue);
>>
>> }
>>
>>
>> /**
>>
>> * <!-- begin-user-doc -->
>>
>> * <!-- end-user-doc -->
>>
>> * @generated
>>
>> */
>>
>> @Override
>>
>> public void eUnset(int featureID) {
>>
>> switch (featureID) {
>>
>> case NewheadPackage.DATA_MAP__CONTENT:
>>
>> setContent((Map<String, Datum>)null);
>>
>> return;
>>
>> }
>>
>> super.eUnset(featureID);
>>
>> }
>>
>>
>>


  • Attachment: test.uml
    (Size: 1.40KB, Downloaded 214 times)
Re: No Cast in case of templates [message #615692 is a reply to message #472884] Thu, 10 May 2007 23:57 Go to previous message
Pradeep is currently offline PradeepFriend
Messages: 54
Registered: July 2009
Member
Hi Ed,

Also, Do you think there is a better way to create template variables. I
just reapplied the technique you suggested for creating arrays in my
previous post.

Suppose if I want to create an interface like

public interface Evaluate<E extends Datum>
{
Double eval(E input);
}

How should i proceed?

Thanks
pradeep


"Ed Merks" <merks@ca.ibm.com> wrote in message
news:f209lo$5hf$1@build.eclipse.org...
> Pradeep,
>
> I'll need to see an Ecore model that reproduces this problem to comment.
> It could be a bug, but without an example, who knows...
>
>
> Pradeep wrote:
>> Hi,
>>
>> I created a uml primitive type with Map<String, Datum> and assigned it to
>> content variable in a class.
>> Now when I convert it to Ecore then to code, I am getting the following
>> code. If you see the eUnset function there is proper cast but there is
>> none in eSet function. The compiler is complaining about the same saying
>> it cannot accept object.
>>
>> How can I avoid this.
>>
>> /**
>>
>> * <!-- begin-user-doc -->
>>
>> * <!-- end-user-doc -->
>>
>> * @generated
>>
>> */
>>
>> @SuppressWarnings("unchecked")
>>
>> @Override
>>
>> public void eSet(int featureID, Object newValue) {
>>
>> switch (featureID) {
>>
>> case NewheadPackage.DATA_MAP__CONTENT:
>>
>> setContent(newValue);
>>
>> return;
>>
>> }
>>
>> super.eSet(featureID, newValue);
>>
>> }
>>
>>
>> /**
>>
>> * <!-- begin-user-doc -->
>>
>> * <!-- end-user-doc -->
>>
>> * @generated
>>
>> */
>>
>> @Override
>>
>> public void eUnset(int featureID) {
>>
>> switch (featureID) {
>>
>> case NewheadPackage.DATA_MAP__CONTENT:
>>
>> setContent((Map<String, Datum>)null);
>>
>> return;
>>
>> }
>>
>> super.eUnset(featureID);
>>
>> }
>>
>>
>>
Re: No Cast in case of templates [message #615693 is a reply to message #472885] Fri, 11 May 2007 00:46 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------070205040900030509060607
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Pradeep,

You need to use fully qualified names in the instance class name, i.e.,
use java.util.Map<java.lang.String, java.lang.String>.

Pradeep wrote:
> Please find the uml file attached. I used the file to generate genmodel and
> then code.
>
> Please import java.util.Map in the generated code.
>
>
>
> "Ed Merks" <merks@ca.ibm.com> wrote in message
> news:f209lo$5hf$1@build.eclipse.org...
>
>> Pradeep,
>>
>> I'll need to see an Ecore model that reproduces this problem to
>> comment. It could be a bug, but without an example, who knows...
>>
>>
>> Pradeep wrote:
>>
>>> Hi,
>>>
>>> I created a uml primitive type with Map<String, Datum> and assigned it to
>>> content variable in a class.
>>> Now when I convert it to Ecore then to code, I am getting the following
>>> code. If you see the eUnset function there is proper cast but there is
>>> none
>>> in eSet function. The compiler is complaining about the same saying it
>>> cannot accept object.
>>>
>>> How can I avoid this.
>>>
>>> /**
>>>
>>> * <!-- begin-user-doc -->
>>>
>>> * <!-- end-user-doc -->
>>>
>>> * @generated
>>>
>>> */
>>>
>>> @SuppressWarnings("unchecked")
>>>
>>> @Override
>>>
>>> public void eSet(int featureID, Object newValue) {
>>>
>>> switch (featureID) {
>>>
>>> case NewheadPackage.DATA_MAP__CONTENT:
>>>
>>> setContent(newValue);
>>>
>>> return;
>>>
>>> }
>>>
>>> super.eSet(featureID, newValue);
>>>
>>> }
>>>
>>>
>>> /**
>>>
>>> * <!-- begin-user-doc -->
>>>
>>> * <!-- end-user-doc -->
>>>
>>> * @generated
>>>
>>> */
>>>
>>> @Override
>>>
>>> public void eUnset(int featureID) {
>>>
>>> switch (featureID) {
>>>
>>> case NewheadPackage.DATA_MAP__CONTENT:
>>>
>>> setContent((Map<String, Datum>)null);
>>>
>>> return;
>>>
>>> }
>>>
>>> super.eUnset(featureID);
>>>
>>> }
>>>
>>>
>>>
>>>
>
>
>


--------------070205040900030509060607
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">
Pradeep,<br>
<br>
You need to use fully qualified names in the instance class name, i.e.,
use java.util.Map&lt;java.lang.String, java.lang.String&gt;.<br>
<br>
Pradeep wrote:
<blockquote cite="midf20avl$7mv$1@build.eclipse.org" type="cite">
<pre wrap="">Please find the uml file attached. I used the file to generate genmodel and
then code.

Please import java.util.Map in the generated code.



"Ed Merks" <a class="moz-txt-link-rfc2396E" href="mailto:merks@ca.ibm.com">&lt;merks@ca.ibm.com&gt;</a> wrote in message
<a class="moz-txt-link-freetext" href="news:f209lo$5hf$1@build.eclipse.org">news:f209lo$5hf$1@build.eclipse.org</a>...
</pre>
<blockquote type="cite">
<pre wrap="">Pradeep,

I'll need to see an Ecore model that reproduces this problem to
comment. It could be a bug, but without an example, who knows...


Pradeep wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi,

I created a uml primitive type with Map&lt;String, Datum&gt; and assigned it to
content variable in a class.
Now when I convert it to Ecore then to code, I am getting the following
code. If you see the eUnset function there is proper cast but there is
none
in eSet function. The compiler is complaining about the same saying it
cannot accept object.

How can I avoid this.

/**

* &lt;!-- begin-user-doc --&gt;

* &lt;!-- end-user-doc --&gt;

* @generated

*/

@SuppressWarnings("unchecked")

@Override

public void eSet(int featureID, Object newValue) {

switch (featureID) {

case NewheadPackage.DATA_MAP__CONTENT:

setContent(newValue);

return;

}

super.eSet(featureID, newValue);

}


/**

* &lt;!-- begin-user-doc --&gt;

* &lt;!-- end-user-doc --&gt;

* @generated

*/

@Override

public void eUnset(int featureID) {

switch (featureID) {

case NewheadPackage.DATA_MAP__CONTENT:

setContent((Map&lt;String, Datum&gt;)null);

return;

}

super.eUnset(featureID);

}



</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->

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

--------------070205040900030509060607--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: No Cast in case of templates [message #615694 is a reply to message #472886] Fri, 11 May 2007 00:55 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------000904080807020303060403
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Pradeep,

It's a UML2 question. In the Ecore editor you can create this directly,
but I'm not sure how to express it in UML2. I produced the attached UML
by modifying your example's .ecore and exporting it to UML.


Pradeep wrote:
> Hi Ed,
>
> Also, Do you think there is a better way to create template variables. I
> just reapplied the technique you suggested for creating arrays in my
> previous post.
>
> Suppose if I want to create an interface like
>
> public interface Evaluate<E extends Datum>
> {
> Double eval(E input);
> }
>
> How should i proceed?
>
> Thanks
> pradeep
>
>
> "Ed Merks" <merks@ca.ibm.com> wrote in message
> news:f209lo$5hf$1@build.eclipse.org...
>
>> Pradeep,
>>
>> I'll need to see an Ecore model that reproduces this problem to comment.
>> It could be a bug, but without an example, who knows...
>>
>>
>> Pradeep wrote:
>>
>>> Hi,
>>>
>>> I created a uml primitive type with Map<String, Datum> and assigned it to
>>> content variable in a class.
>>> Now when I convert it to Ecore then to code, I am getting the following
>>> code. If you see the eUnset function there is proper cast but there is
>>> none in eSet function. The compiler is complaining about the same saying
>>> it cannot accept object.
>>>
>>> How can I avoid this.
>>>
>>> /**
>>>
>>> * <!-- begin-user-doc -->
>>>
>>> * <!-- end-user-doc -->
>>>
>>> * @generated
>>>
>>> */
>>>
>>> @SuppressWarnings("unchecked")
>>>
>>> @Override
>>>
>>> public void eSet(int featureID, Object newValue) {
>>>
>>> switch (featureID) {
>>>
>>> case NewheadPackage.DATA_MAP__CONTENT:
>>>
>>> setContent(newValue);
>>>
>>> return;
>>>
>>> }
>>>
>>> super.eSet(featureID, newValue);
>>>
>>> }
>>>
>>>
>>> /**
>>>
>>> * <!-- begin-user-doc -->
>>>
>>> * <!-- end-user-doc -->
>>>
>>> * @generated
>>>
>>> */
>>>
>>> @Override
>>>
>>> public void eUnset(int featureID) {
>>>
>>> switch (featureID) {
>>>
>>> case NewheadPackage.DATA_MAP__CONTENT:
>>>
>>> setContent((Map<String, Datum>)null);
>>>
>>> return;
>>>
>>> }
>>>
>>> super.eUnset(featureID);
>>>
>>> }
>>>
>>>
>>>
>>>
>
>
>


--------------000904080807020303060403
Content-Type: text/xml;
name="test.uml"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="test.uml"

<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:Ecore="http://www.eclipse.org/uml2/schemas/Ecore/4" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:uml="http://www.eclipse.org/uml2/2.1.0/UML" xsi:schemaLocation="http://www.eclipse.org/uml2/schemas/Ecore/4 pathmap://UML_PROFILES/Ecore.profile.uml#_B7dOIMEREduRdatXod jBjA">
<uml:Model xmi:id="_8Pp2gP9ZEdu2-NJ3YDjyEA" name="test">
<packagedElement xmi:type="uml:PrimitiveType" xmi:id="_8Pp2gf9ZEdu2-NJ3YDjyEA" name="MapStringString"/>
<packagedElement xmi:type="uml:Class" xmi:id="_8Pp2gv9ZEdu2-NJ3YDjyEA" name="DataBag">
<ownedTemplateSignature xmi:type="uml:RedefinableTemplateSignature" xmi:id="_8Pp2g_9ZEdu2-NJ3YDjyEA" parameter="_8Pp2hP9ZEdu2-NJ3YDjyEA">
<ownedParameter xmi:type="uml:ClassifierTemplateParameter" xmi:id="_8Pp2hP9ZEdu2-NJ3YDjyEA" parameteredElement="_8Pp2hf9ZEdu2-NJ3YDjyEA">
<ownedParameteredElement xmi:type="uml:Class" xmi:id="_8Pp2hf9ZEdu2-NJ3YDjyEA" name="E" templateParameter="_8Pp2hP9ZEdu2-NJ3YDjyEA"/>
</ownedParameter>
</ownedTemplateSignature>
<ownedAttribute xmi:id="_8Pp2hv9ZEdu2-NJ3YDjyEA" name="content" visibility="public" type="_8Pp2gf9ZEdu2-NJ3YDjyEA"/>
<ownedOperation xmi:id="_8Pp2h_9ZEdu2-NJ3YDjyEA" name="eval" visibility="public">
<ownedParameter xmi:id="_8Pp2iP9ZEdu2-NJ3YDjyEA" isOrdered="true" direction="return">
<lowerValue xmi:type="uml:LiteralInteger" xmi:id="_8Pp2if9ZEdu2-NJ3YDjyEA"/>
</ownedParameter>
<ownedParameter xmi:id="_8Pp2iv9ZEdu2-NJ3YDjyEA" name="input" type="_8Pp2hf9ZEdu2-NJ3YDjyEA" isOrdered="true">
<lowerValue xmi:type="uml:LiteralInteger" xmi:id="_8Pp2i_9ZEdu2-NJ3YDjyEA"/>
</ownedParameter>
</ownedOperation>
</packagedElement>
<profileApplication xmi:id="_8Pp2jP9ZEdu2-NJ3YDjyEA">
<eAnnotations xmi:id="_8Pp2jf9ZEdu2-NJ3YDjyEA" source="http://www.eclipse.org/uml2/2.0.0/UML">
<references xmi:type="ecore:EPackage" href=" pathmap://UML_PROFILES/Ecore.profile.uml#_B7dOIMEREduRdatXod jBjA"/>
</eAnnotations>
<appliedProfile href="pathmap://UML_PROFILES/Ecore.profile.uml#_0"/>
</profileApplication>
</uml:Model>
<Ecore:EPackage xmi:id="_8Pp2jv9ZEdu2-NJ3YDjyEA" base_Package="_8Pp2gP9ZEdu2-NJ3YDjyEA" nsPrefix="test" nsURI="http:///test.ecore"/>
<Ecore:EDataType xmi:id="_8Pp2j_9ZEdu2-NJ3YDjyEA" instanceClassName="Map&lt;String, String>" base_PrimitiveType="_8Pp2gf9ZEdu2-NJ3YDjyEA"/>
<Ecore:EClass xmi:id="_8Pp2kP9ZEdu2-NJ3YDjyEA" base_Class="_8Pp2gv9ZEdu2-NJ3YDjyEA"/>
<Ecore:ETypeParameter xmi:id="_8Pp2kf9ZEdu2-NJ3YDjyEA" base_TemplateParameter="_8Pp2hP9ZEdu2-NJ3YDjyEA">
<bounds xmi:type="uml:PrimitiveType" href=" pathmap://UML_LIBRARIES/EcorePrimitiveTypes.library.uml#EStr ing"/>
</Ecore:ETypeParameter>
<Ecore:EAttribute xmi:id="_8Pp2kv9ZEdu2-NJ3YDjyEA" base_Property="_8Pp2hv9ZEdu2-NJ3YDjyEA"/>
<Ecore:EOperation xmi:id="_8Pp2k_9ZEdu2-NJ3YDjyEA" base_Operation="_8Pp2h_9ZEdu2-NJ3YDjyEA"/>
<Ecore:EParameter xmi:id="_8Pp2lP9ZEdu2-NJ3YDjyEA" base_Parameter="_8Pp2iv9ZEdu2-NJ3YDjyEA"/>
</xmi:XMI>

--------------000904080807020303060403--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: No Cast in case of templates [message #615695 is a reply to message #472887] Fri, 11 May 2007 03:03 Go to previous message
Pradeep is currently offline PradeepFriend
Messages: 54
Registered: July 2009
Member
This is a multi-part message in MIME format.

------=_NextPart_000_0181_01C7933E.3AFEC8E0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Thanks a lot. That worked.
"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:f20ecd$112$1@build.eclipse.org...
Pradeep,

You need to use fully qualified names in the instance class name, =
i.e., use java.util.Map<java.lang.String, java.lang.String>.

Pradeep wrote:=20
Please find the uml file attached. I used the file to generate genmodel =
and=20
then code.

Please import java.util.Map in the generated code.



"Ed Merks" <merks@ca.ibm.com> wrote in message=20
news:f209lo$5hf$1@build.eclipse.org...
Pradeep,

I'll need to see an Ecore model that reproduces this problem to
comment. It could be a bug, but without an example, who knows...


Pradeep wrote:
Hi,

I created a uml primitive type with Map<String, Datum> and assigned it =
to
content variable in a class.
Now when I convert it to Ecore then to code, I am getting the following
code. If you see the eUnset function there is proper cast but there is=20
none
in eSet function. The compiler is complaining about the same saying it
cannot accept object.

How can I avoid this.

/**

* <!-- begin-user-doc -->

* <!-- end-user-doc -->

* @generated

*/

@SuppressWarnings("unchecked")

@Override

public void eSet(int featureID, Object newValue) {

switch (featureID) {

case NewheadPackage.DATA_MAP__CONTENT:

setContent(newValue);

return;

}

super.eSet(featureID, newValue);

}


/**

* <!-- begin-user-doc -->

* <!-- end-user-doc -->

* @generated

*/

@Override

public void eUnset(int featureID) {

switch (featureID) {

case NewheadPackage.DATA_MAP__CONTENT:

setContent((Map<String, Datum>)null);

return;

}

super.eUnset(featureID);

}



=20

=20

------=_NextPart_000_0181_01C7933E.3AFEC8E0
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.6000.16414" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Thanks a lot. That worked.</FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A =
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt;=20
wrote in message <A=20
=
href=3D"news:f20ecd$112$1@build.eclipse.org">news:f20ecd$112$1@build.ecli=
pse.org</A>...</DIV>Pradeep,<BR><BR>You=20
need to use fully qualified names in the instance class name, i.e., =
use=20
java.util.Map&lt;java.lang.String, =
java.lang.String&gt;.<BR><BR>Pradeep wrote:=20

<BLOCKQUOTE cite=3Dmidf20avl$7mv$1@build.eclipse.org =
type=3D"cite"><PRE wrap=3D"">Please find the uml file attached. I used =
the file to generate genmodel and=20
then code.

Please import java.util.Map in the generated code.



"Ed Merks" <A class=3Dmoz-txt-link-rfc2396E =
href=3D"mailto:merks@ca.ibm.com">&lt;merks@ca.ibm.com&gt;</A> wrote in =
message=20
<A class=3Dmoz-txt-link-freetext =
href=3D"news:f209lo$5hf$1@build.eclipse.org">news:f209lo$5hf$1@build.ecli=
pse.org</A>...
</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">Pradeep,

I'll need to see an Ecore model that reproduces this problem to
comment. It could be a bug, but without an example, who knows...


Pradeep wrote:
</PRE>
<BLOCKQUOTE type=3D"cite"><PRE wrap=3D"">Hi,

I created a uml primitive type with Map&lt;String, Datum&gt; and =
assigned it to
content variable in a class.
Now when I convert it to Ecore then to code, I am getting the following
code. If you see the eUnset function there is proper cast but there is=20
none
in eSet function. The compiler is complaining about the same saying it
cannot accept object.

How can I avoid this.

/**

* &lt;!-- begin-user-doc --&gt;

* &lt;!-- end-user-doc --&gt;

* @generated

*/

@SuppressWarnings("unchecked")

@Override

public void eSet(int featureID, Object newValue) {

switch (featureID) {

case NewheadPackage.DATA_MAP__CONTENT:

setContent(newValue);

return;

}

super.eSet(featureID, newValue);

}


/**

* &lt;!-- begin-user-doc --&gt;

* &lt;!-- end-user-doc --&gt;

* @generated

*/

@Override

public void eUnset(int featureID) {

switch (featureID) {

case NewheadPackage.DATA_MAP__CONTENT:

setContent((Map&lt;String, Datum&gt;)null);

return;

}

super.eUnset(featureID);

}



</PRE></BLOCKQUOTE></BLOCKQUOTE><PRE wrap=3D""><!---->

</PRE></BLOCKQUOTE><BR></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_0181_01C7933E.3AFEC8E0--
Re: No Cast in case of templates [message #615696 is a reply to message #472888] Fri, 11 May 2007 03:04 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
The draft document at https://bugs.eclipse.org/bugs/attachment.cgi?id=57909
describes how UML templates map to Ecore generics. We will be focusing on
documentation (polishing this and other articles, etc.) once we declare M7
for this release.

Kenn

"Ed Merks" <merks@ca.ibm.com> wrote in message
news:f20euk$8tb$1@build.eclipse.org...
> Pradeep,
>
> It's a UML2 question. In the Ecore editor you can create this directly,
> but I'm not sure how to express it in UML2. I produced the attached UML
> by modifying your example's .ecore and exporting it to UML.
>
>
> Pradeep wrote:
>> Hi Ed,
>>
>> Also, Do you think there is a better way to create template variables. I
>> just reapplied the technique you suggested for creating arrays in my
>> previous post.
>>
>> Suppose if I want to create an interface like
>>
>> public interface Evaluate<E extends Datum>
>> {
>> Double eval(E input);
>> }
>>
>> How should i proceed?
>>
>> Thanks
>> pradeep
>>
>>
>> "Ed Merks" <merks@ca.ibm.com> wrote in message
>> news:f209lo$5hf$1@build.eclipse.org...
>>
>>> Pradeep,
>>>
>>> I'll need to see an Ecore model that reproduces this problem to comment.
>>> It could be a bug, but without an example, who knows...
>>>
>>>
>>> Pradeep wrote:
>>>
>>>> Hi,
>>>>
>>>> I created a uml primitive type with Map<String, Datum> and assigned it
>>>> to
>>>> content variable in a class.
>>>> Now when I convert it to Ecore then to code, I am getting the following
>>>> code. If you see the eUnset function there is proper cast but there is
>>>> none in eSet function. The compiler is complaining about the same
>>>> saying
>>>> it cannot accept object.
>>>>
>>>> How can I avoid this.
>>>>
>>>> /**
>>>>
>>>> * <!-- begin-user-doc -->
>>>>
>>>> * <!-- end-user-doc -->
>>>>
>>>> * @generated
>>>>
>>>> */
>>>>
>>>> @SuppressWarnings("unchecked")
>>>>
>>>> @Override
>>>>
>>>> public void eSet(int featureID, Object newValue) {
>>>>
>>>> switch (featureID) {
>>>>
>>>> case NewheadPackage.DATA_MAP__CONTENT:
>>>>
>>>> setContent(newValue);
>>>>
>>>> return;
>>>>
>>>> }
>>>>
>>>> super.eSet(featureID, newValue);
>>>>
>>>> }
>>>>
>>>>
>>>> /**
>>>>
>>>> * <!-- begin-user-doc -->
>>>>
>>>> * <!-- end-user-doc -->
>>>>
>>>> * @generated
>>>>
>>>> */
>>>>
>>>> @Override
>>>>
>>>> public void eUnset(int featureID) {
>>>>
>>>> switch (featureID) {
>>>>
>>>> case NewheadPackage.DATA_MAP__CONTENT:
>>>>
>>>> setContent((Map<String, Datum>)null);
>>>>
>>>> return;
>>>>
>>>> }
>>>>
>>>> super.eUnset(featureID);
>>>>
>>>> }
>>>>
>>>>
>>>>
>>>>
>>
>>
>>
>
>


------------------------------------------------------------ --------------------


> <?xml version="1.0" encoding="UTF-8"?>
> <xmi:XMI xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:Ecore="http://www.eclipse.org/uml2/schemas/Ecore/4"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
> xmlns:uml="http://www.eclipse.org/uml2/2.1.0/UML"
> xsi:schemaLocation="http://www.eclipse.org/uml2/schemas/Ecore/4
> pathmap://UML_PROFILES/Ecore.profile.uml#_B7dOIMEREduRdatXod jBjA">
> <uml:Model xmi:id="_8Pp2gP9ZEdu2-NJ3YDjyEA" name="test">
> <packagedElement xmi:type="uml:PrimitiveType"
> xmi:id="_8Pp2gf9ZEdu2-NJ3YDjyEA" name="MapStringString"/>
> <packagedElement xmi:type="uml:Class" xmi:id="_8Pp2gv9ZEdu2-NJ3YDjyEA"
> name="DataBag">
> <ownedTemplateSignature xmi:type="uml:RedefinableTemplateSignature"
> xmi:id="_8Pp2g_9ZEdu2-NJ3YDjyEA" parameter="_8Pp2hP9ZEdu2-NJ3YDjyEA">
> <ownedParameter xmi:type="uml:ClassifierTemplateParameter"
> xmi:id="_8Pp2hP9ZEdu2-NJ3YDjyEA"
> parameteredElement="_8Pp2hf9ZEdu2-NJ3YDjyEA">
> <ownedParameteredElement xmi:type="uml:Class"
> xmi:id="_8Pp2hf9ZEdu2-NJ3YDjyEA" name="E"
> templateParameter="_8Pp2hP9ZEdu2-NJ3YDjyEA"/>
> </ownedParameter>
> </ownedTemplateSignature>
> <ownedAttribute xmi:id="_8Pp2hv9ZEdu2-NJ3YDjyEA" name="content"
> visibility="public" type="_8Pp2gf9ZEdu2-NJ3YDjyEA"/>
> <ownedOperation xmi:id="_8Pp2h_9ZEdu2-NJ3YDjyEA" name="eval"
> visibility="public">
> <ownedParameter xmi:id="_8Pp2iP9ZEdu2-NJ3YDjyEA" isOrdered="true"
> direction="return">
> <lowerValue xmi:type="uml:LiteralInteger"
> xmi:id="_8Pp2if9ZEdu2-NJ3YDjyEA"/>
> </ownedParameter>
> <ownedParameter xmi:id="_8Pp2iv9ZEdu2-NJ3YDjyEA" name="input"
> type="_8Pp2hf9ZEdu2-NJ3YDjyEA" isOrdered="true">
> <lowerValue xmi:type="uml:LiteralInteger"
> xmi:id="_8Pp2i_9ZEdu2-NJ3YDjyEA"/>
> </ownedParameter>
> </ownedOperation>
> </packagedElement>
> <profileApplication xmi:id="_8Pp2jP9ZEdu2-NJ3YDjyEA">
> <eAnnotations xmi:id="_8Pp2jf9ZEdu2-NJ3YDjyEA"
> source="http://www.eclipse.org/uml2/2.0.0/UML">
> <references xmi:type="ecore:EPackage"
> href=" pathmap://UML_PROFILES/Ecore.profile.uml#_B7dOIMEREduRdatXod jBjA"/>
> </eAnnotations>
> <appliedProfile href="pathmap://UML_PROFILES/Ecore.profile.uml#_0"/>
> </profileApplication>
> </uml:Model>
> <Ecore:EPackage xmi:id="_8Pp2jv9ZEdu2-NJ3YDjyEA"
> base_Package="_8Pp2gP9ZEdu2-NJ3YDjyEA" nsPrefix="test"
> nsURI="http:///test.ecore"/>
> <Ecore:EDataType xmi:id="_8Pp2j_9ZEdu2-NJ3YDjyEA"
> instanceClassName="Map&lt;String, String>"
> base_PrimitiveType="_8Pp2gf9ZEdu2-NJ3YDjyEA"/>
> <Ecore:EClass xmi:id="_8Pp2kP9ZEdu2-NJ3YDjyEA"
> base_Class="_8Pp2gv9ZEdu2-NJ3YDjyEA"/>
> <Ecore:ETypeParameter xmi:id="_8Pp2kf9ZEdu2-NJ3YDjyEA"
> base_TemplateParameter="_8Pp2hP9ZEdu2-NJ3YDjyEA">
> <bounds xmi:type="uml:PrimitiveType"
> href=" pathmap://UML_LIBRARIES/EcorePrimitiveTypes.library.uml#EStr ing"/>
> </Ecore:ETypeParameter>
> <Ecore:EAttribute xmi:id="_8Pp2kv9ZEdu2-NJ3YDjyEA"
> base_Property="_8Pp2hv9ZEdu2-NJ3YDjyEA"/>
> <Ecore:EOperation xmi:id="_8Pp2k_9ZEdu2-NJ3YDjyEA"
> base_Operation="_8Pp2h_9ZEdu2-NJ3YDjyEA"/>
> <Ecore:EParameter xmi:id="_8Pp2lP9ZEdu2-NJ3YDjyEA"
> base_Parameter="_8Pp2iv9ZEdu2-NJ3YDjyEA"/>
> </xmi:XMI>
>
Re: No Cast in case of templates [message #615698 is a reply to message #472890] Fri, 11 May 2007 04:34 Go to previous message
Pradeep is currently offline PradeepFriend
Messages: 54
Registered: July 2009
Member
Hi Ed and Kenn,

Somehow my UML editor is not opening the UML file sent by Ed.

The word document, even though incomplete, helped me a lot. I am able
achieve the different template definitions that I want using the illustrated
figures.

Actually both EMF and UML2 has more support for Generics than I thought. I
recently listened to a podcast by Ed in which he said that while Ecore
generates generic classes, support for user defined generic classes is
little into the future. I didn't realize he literally meant "little". :)

Thanks once again for both of you.

Pradeep



"Kenn Hussey" <khussey@ca.ibm.com> wrote in message
news:f20mfs$l38$1@build.eclipse.org...
> The draft document at
> https://bugs.eclipse.org/bugs/attachment.cgi?id=57909 describes how UML
> templates map to Ecore generics. We will be focusing on documentation
> (polishing this and other articles, etc.) once we declare M7 for this
> release.
>
> Kenn
>
> "Ed Merks" <merks@ca.ibm.com> wrote in message
> news:f20euk$8tb$1@build.eclipse.org...
>> Pradeep,
>>
>> It's a UML2 question. In the Ecore editor you can create this directly,
>> but I'm not sure how to express it in UML2. I produced the attached UML
>> by modifying your example's .ecore and exporting it to UML.
>>
>>
>> Pradeep wrote:
>>> Hi Ed,
>>>
>>> Also, Do you think there is a better way to create template variables. I
>>> just reapplied the technique you suggested for creating arrays in my
>>> previous post.
>>>
>>> Suppose if I want to create an interface like
>>>
>>> public interface Evaluate<E extends Datum>
>>> {
>>> Double eval(E input);
>>> }
>>>
>>> How should i proceed?
>>>
>>> Thanks
>>> pradeep
>>>
>>>
>>> "Ed Merks" <merks@ca.ibm.com> wrote in message
>>> news:f209lo$5hf$1@build.eclipse.org...
>>>
>>>> Pradeep,
>>>>
>>>> I'll need to see an Ecore model that reproduces this problem to
>>>> comment.
>>>> It could be a bug, but without an example, who knows...
>>>>
>>>>
>>>> Pradeep wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I created a uml primitive type with Map<String, Datum> and assigned it
>>>>> to
>>>>> content variable in a class.
>>>>> Now when I convert it to Ecore then to code, I am getting the
>>>>> following
>>>>> code. If you see the eUnset function there is proper cast but there is
>>>>> none in eSet function. The compiler is complaining about the same
>>>>> saying
>>>>> it cannot accept object.
>>>>>
>>>>> How can I avoid this.
>>>>>
>>>>> /**
>>>>>
>>>>> * <!-- begin-user-doc -->
>>>>>
>>>>> * <!-- end-user-doc -->
>>>>>
>>>>> * @generated
>>>>>
>>>>> */
>>>>>
>>>>> @SuppressWarnings("unchecked")
>>>>>
>>>>> @Override
>>>>>
>>>>> public void eSet(int featureID, Object newValue) {
>>>>>
>>>>> switch (featureID) {
>>>>>
>>>>> case NewheadPackage.DATA_MAP__CONTENT:
>>>>>
>>>>> setContent(newValue);
>>>>>
>>>>> return;
>>>>>
>>>>> }
>>>>>
>>>>> super.eSet(featureID, newValue);
>>>>>
>>>>> }
>>>>>
>>>>>
>>>>> /**
>>>>>
>>>>> * <!-- begin-user-doc -->
>>>>>
>>>>> * <!-- end-user-doc -->
>>>>>
>>>>> * @generated
>>>>>
>>>>> */
>>>>>
>>>>> @Override
>>>>>
>>>>> public void eUnset(int featureID) {
>>>>>
>>>>> switch (featureID) {
>>>>>
>>>>> case NewheadPackage.DATA_MAP__CONTENT:
>>>>>
>>>>> setContent((Map<String, Datum>)null);
>>>>>
>>>>> return;
>>>>>
>>>>> }
>>>>>
>>>>> super.eUnset(featureID);
>>>>>
>>>>> }
>>>>>
>>>>>
>>>>>
>>>>>
>>>
>>>
>>>
>>
>>
>
>
> ------------------------------------------------------------ --------------------
>
>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <xmi:XMI xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xmlns:Ecore="http://www.eclipse.org/uml2/schemas/Ecore/4"
>> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
>> xmlns:uml="http://www.eclipse.org/uml2/2.1.0/UML"
>> xsi:schemaLocation="http://www.eclipse.org/uml2/schemas/Ecore/4
>> pathmap://UML_PROFILES/Ecore.profile.uml#_B7dOIMEREduRdatXod jBjA">
>> <uml:Model xmi:id="_8Pp2gP9ZEdu2-NJ3YDjyEA" name="test">
>> <packagedElement xmi:type="uml:PrimitiveType"
>> xmi:id="_8Pp2gf9ZEdu2-NJ3YDjyEA" name="MapStringString"/>
>> <packagedElement xmi:type="uml:Class" xmi:id="_8Pp2gv9ZEdu2-NJ3YDjyEA"
>> name="DataBag">
>> <ownedTemplateSignature xmi:type="uml:RedefinableTemplateSignature"
>> xmi:id="_8Pp2g_9ZEdu2-NJ3YDjyEA" parameter="_8Pp2hP9ZEdu2-NJ3YDjyEA">
>> <ownedParameter xmi:type="uml:ClassifierTemplateParameter"
>> xmi:id="_8Pp2hP9ZEdu2-NJ3YDjyEA"
>> parameteredElement="_8Pp2hf9ZEdu2-NJ3YDjyEA">
>> <ownedParameteredElement xmi:type="uml:Class"
>> xmi:id="_8Pp2hf9ZEdu2-NJ3YDjyEA" name="E"
>> templateParameter="_8Pp2hP9ZEdu2-NJ3YDjyEA"/>
>> </ownedParameter>
>> </ownedTemplateSignature>
>> <ownedAttribute xmi:id="_8Pp2hv9ZEdu2-NJ3YDjyEA" name="content"
>> visibility="public" type="_8Pp2gf9ZEdu2-NJ3YDjyEA"/>
>> <ownedOperation xmi:id="_8Pp2h_9ZEdu2-NJ3YDjyEA" name="eval"
>> visibility="public">
>> <ownedParameter xmi:id="_8Pp2iP9ZEdu2-NJ3YDjyEA" isOrdered="true"
>> direction="return">
>> <lowerValue xmi:type="uml:LiteralInteger"
>> xmi:id="_8Pp2if9ZEdu2-NJ3YDjyEA"/>
>> </ownedParameter>
>> <ownedParameter xmi:id="_8Pp2iv9ZEdu2-NJ3YDjyEA" name="input"
>> type="_8Pp2hf9ZEdu2-NJ3YDjyEA" isOrdered="true">
>> <lowerValue xmi:type="uml:LiteralInteger"
>> xmi:id="_8Pp2i_9ZEdu2-NJ3YDjyEA"/>
>> </ownedParameter>
>> </ownedOperation>
>> </packagedElement>
>> <profileApplication xmi:id="_8Pp2jP9ZEdu2-NJ3YDjyEA">
>> <eAnnotations xmi:id="_8Pp2jf9ZEdu2-NJ3YDjyEA"
>> source="http://www.eclipse.org/uml2/2.0.0/UML">
>> <references xmi:type="ecore:EPackage"
>> href=" pathmap://UML_PROFILES/Ecore.profile.uml#_B7dOIMEREduRdatXod jBjA"/>
>> </eAnnotations>
>> <appliedProfile href="pathmap://UML_PROFILES/Ecore.profile.uml#_0"/>
>> </profileApplication>
>> </uml:Model>
>> <Ecore:EPackage xmi:id="_8Pp2jv9ZEdu2-NJ3YDjyEA"
>> base_Package="_8Pp2gP9ZEdu2-NJ3YDjyEA" nsPrefix="test"
>> nsURI="http:///test.ecore"/>
>> <Ecore:EDataType xmi:id="_8Pp2j_9ZEdu2-NJ3YDjyEA"
>> instanceClassName="Map&lt;String, String>"
>> base_PrimitiveType="_8Pp2gf9ZEdu2-NJ3YDjyEA"/>
>> <Ecore:EClass xmi:id="_8Pp2kP9ZEdu2-NJ3YDjyEA"
>> base_Class="_8Pp2gv9ZEdu2-NJ3YDjyEA"/>
>> <Ecore:ETypeParameter xmi:id="_8Pp2kf9ZEdu2-NJ3YDjyEA"
>> base_TemplateParameter="_8Pp2hP9ZEdu2-NJ3YDjyEA">
>> <bounds xmi:type="uml:PrimitiveType"
>> href=" pathmap://UML_LIBRARIES/EcorePrimitiveTypes.library.uml#EStr ing"/>
>> </Ecore:ETypeParameter>
>> <Ecore:EAttribute xmi:id="_8Pp2kv9ZEdu2-NJ3YDjyEA"
>> base_Property="_8Pp2hv9ZEdu2-NJ3YDjyEA"/>
>> <Ecore:EOperation xmi:id="_8Pp2k_9ZEdu2-NJ3YDjyEA"
>> base_Operation="_8Pp2h_9ZEdu2-NJ3YDjyEA"/>
>> <Ecore:EParameter xmi:id="_8Pp2lP9ZEdu2-NJ3YDjyEA"
>> base_Parameter="_8Pp2iv9ZEdu2-NJ3YDjyEA"/>
>> </xmi:XMI>
>>
>
>
Re: No Cast in case of templates [message #615702 is a reply to message #472892] Fri, 11 May 2007 20:34 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Pradeep,

To open the model Ed sent you, you'll need to use the latest integration
build of UML2 (I200705111324). This is because the namespace URI for UML2
changed, as previously announced on the newsgroup.

Kenn

"Pradeep" <eclipseuser123@yahoo.com> wrote in message
news:f20rp1$v73$1@build.eclipse.org...
> Hi Ed and Kenn,
>
> Somehow my UML editor is not opening the UML file sent by Ed.
>
> The word document, even though incomplete, helped me a lot. I am able
> achieve the different template definitions that I want using the
> illustrated figures.
>
> Actually both EMF and UML2 has more support for Generics than I thought. I
> recently listened to a podcast by Ed in which he said that while Ecore
> generates generic classes, support for user defined generic classes is
> little into the future. I didn't realize he literally meant "little". :)
>
> Thanks once again for both of you.
>
> Pradeep
>
>
>
> "Kenn Hussey" <khussey@ca.ibm.com> wrote in message
> news:f20mfs$l38$1@build.eclipse.org...
>> The draft document at
>> https://bugs.eclipse.org/bugs/attachment.cgi?id=57909 describes how UML
>> templates map to Ecore generics. We will be focusing on documentation
>> (polishing this and other articles, etc.) once we declare M7 for this
>> release.
>>
>> Kenn
>>
>> "Ed Merks" <merks@ca.ibm.com> wrote in message
>> news:f20euk$8tb$1@build.eclipse.org...
>>> Pradeep,
>>>
>>> It's a UML2 question. In the Ecore editor you can create this directly,
>>> but I'm not sure how to express it in UML2. I produced the attached UML
>>> by modifying your example's .ecore and exporting it to UML.
>>>
>>>
>>> Pradeep wrote:
>>>> Hi Ed,
>>>>
>>>> Also, Do you think there is a better way to create template variables.
>>>> I
>>>> just reapplied the technique you suggested for creating arrays in my
>>>> previous post.
>>>>
>>>> Suppose if I want to create an interface like
>>>>
>>>> public interface Evaluate<E extends Datum>
>>>> {
>>>> Double eval(E input);
>>>> }
>>>>
>>>> How should i proceed?
>>>>
>>>> Thanks
>>>> pradeep
>>>>
>>>>
>>>> "Ed Merks" <merks@ca.ibm.com> wrote in message
>>>> news:f209lo$5hf$1@build.eclipse.org...
>>>>
>>>>> Pradeep,
>>>>>
>>>>> I'll need to see an Ecore model that reproduces this problem to
>>>>> comment.
>>>>> It could be a bug, but without an example, who knows...
>>>>>
>>>>>
>>>>> Pradeep wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I created a uml primitive type with Map<String, Datum> and assigned
>>>>>> it to
>>>>>> content variable in a class.
>>>>>> Now when I convert it to Ecore then to code, I am getting the
>>>>>> following
>>>>>> code. If you see the eUnset function there is proper cast but there
>>>>>> is
>>>>>> none in eSet function. The compiler is complaining about the same
>>>>>> saying
>>>>>> it cannot accept object.
>>>>>>
>>>>>> How can I avoid this.
>>>>>>
>>>>>> /**
>>>>>>
>>>>>> * <!-- begin-user-doc -->
>>>>>>
>>>>>> * <!-- end-user-doc -->
>>>>>>
>>>>>> * @generated
>>>>>>
>>>>>> */
>>>>>>
>>>>>> @SuppressWarnings("unchecked")
>>>>>>
>>>>>> @Override
>>>>>>
>>>>>> public void eSet(int featureID, Object newValue) {
>>>>>>
>>>>>> switch (featureID) {
>>>>>>
>>>>>> case NewheadPackage.DATA_MAP__CONTENT:
>>>>>>
>>>>>> setContent(newValue);
>>>>>>
>>>>>> return;
>>>>>>
>>>>>> }
>>>>>>
>>>>>> super.eSet(featureID, newValue);
>>>>>>
>>>>>> }
>>>>>>
>>>>>>
>>>>>> /**
>>>>>>
>>>>>> * <!-- begin-user-doc -->
>>>>>>
>>>>>> * <!-- end-user-doc -->
>>>>>>
>>>>>> * @generated
>>>>>>
>>>>>> */
>>>>>>
>>>>>> @Override
>>>>>>
>>>>>> public void eUnset(int featureID) {
>>>>>>
>>>>>> switch (featureID) {
>>>>>>
>>>>>> case NewheadPackage.DATA_MAP__CONTENT:
>>>>>>
>>>>>> setContent((Map<String, Datum>)null);
>>>>>>
>>>>>> return;
>>>>>>
>>>>>> }
>>>>>>
>>>>>> super.eUnset(featureID);
>>>>>>
>>>>>> }
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>> ------------------------------------------------------------ --------------------
>>
>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <xmi:XMI xmi:version="2.1"
>>> xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>> xmlns:Ecore="http://www.eclipse.org/uml2/schemas/Ecore/4"
>>> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
>>> xmlns:uml="http://www.eclipse.org/uml2/2.1.0/UML"
>>> xsi:schemaLocation="http://www.eclipse.org/uml2/schemas/Ecore/4
>>> pathmap://UML_PROFILES/Ecore.profile.uml#_B7dOIMEREduRdatXod jBjA">
>>> <uml:Model xmi:id="_8Pp2gP9ZEdu2-NJ3YDjyEA" name="test">
>>> <packagedElement xmi:type="uml:PrimitiveType"
>>> xmi:id="_8Pp2gf9ZEdu2-NJ3YDjyEA" name="MapStringString"/>
>>> <packagedElement xmi:type="uml:Class"
>>> xmi:id="_8Pp2gv9ZEdu2-NJ3YDjyEA" name="DataBag">
>>> <ownedTemplateSignature xmi:type="uml:RedefinableTemplateSignature"
>>> xmi:id="_8Pp2g_9ZEdu2-NJ3YDjyEA" parameter="_8Pp2hP9ZEdu2-NJ3YDjyEA">
>>> <ownedParameter xmi:type="uml:ClassifierTemplateParameter"
>>> xmi:id="_8Pp2hP9ZEdu2-NJ3YDjyEA"
>>> parameteredElement="_8Pp2hf9ZEdu2-NJ3YDjyEA">
>>> <ownedParameteredElement xmi:type="uml:Class"
>>> xmi:id="_8Pp2hf9ZEdu2-NJ3YDjyEA" name="E"
>>> templateParameter="_8Pp2hP9ZEdu2-NJ3YDjyEA"/>
>>> </ownedParameter>
>>> </ownedTemplateSignature>
>>> <ownedAttribute xmi:id="_8Pp2hv9ZEdu2-NJ3YDjyEA" name="content"
>>> visibility="public" type="_8Pp2gf9ZEdu2-NJ3YDjyEA"/>
>>> <ownedOperation xmi:id="_8Pp2h_9ZEdu2-NJ3YDjyEA" name="eval"
>>> visibility="public">
>>> <ownedParameter xmi:id="_8Pp2iP9ZEdu2-NJ3YDjyEA" isOrdered="true"
>>> direction="return">
>>> <lowerValue xmi:type="uml:LiteralInteger"
>>> xmi:id="_8Pp2if9ZEdu2-NJ3YDjyEA"/>
>>> </ownedParameter>
>>> <ownedParameter xmi:id="_8Pp2iv9ZEdu2-NJ3YDjyEA" name="input"
>>> type="_8Pp2hf9ZEdu2-NJ3YDjyEA" isOrdered="true">
>>> <lowerValue xmi:type="uml:LiteralInteger"
>>> xmi:id="_8Pp2i_9ZEdu2-NJ3YDjyEA"/>
>>> </ownedParameter>
>>> </ownedOperation>
>>> </packagedElement>
>>> <profileApplication xmi:id="_8Pp2jP9ZEdu2-NJ3YDjyEA">
>>> <eAnnotations xmi:id="_8Pp2jf9ZEdu2-NJ3YDjyEA"
>>> source="http://www.eclipse.org/uml2/2.0.0/UML">
>>> <references xmi:type="ecore:EPackage"
>>> href=" pathmap://UML_PROFILES/Ecore.profile.uml#_B7dOIMEREduRdatXod jBjA"/>
>>> </eAnnotations>
>>> <appliedProfile
>>> href="pathmap://UML_PROFILES/Ecore.profile.uml#_0"/>
>>> </profileApplication>
>>> </uml:Model>
>>> <Ecore:EPackage xmi:id="_8Pp2jv9ZEdu2-NJ3YDjyEA"
>>> base_Package="_8Pp2gP9ZEdu2-NJ3YDjyEA" nsPrefix="test"
>>> nsURI="http:///test.ecore"/>
>>> <Ecore:EDataType xmi:id="_8Pp2j_9ZEdu2-NJ3YDjyEA"
>>> instanceClassName="Map&lt;String, String>"
>>> base_PrimitiveType="_8Pp2gf9ZEdu2-NJ3YDjyEA"/>
>>> <Ecore:EClass xmi:id="_8Pp2kP9ZEdu2-NJ3YDjyEA"
>>> base_Class="_8Pp2gv9ZEdu2-NJ3YDjyEA"/>
>>> <Ecore:ETypeParameter xmi:id="_8Pp2kf9ZEdu2-NJ3YDjyEA"
>>> base_TemplateParameter="_8Pp2hP9ZEdu2-NJ3YDjyEA">
>>> <bounds xmi:type="uml:PrimitiveType"
>>> href=" pathmap://UML_LIBRARIES/EcorePrimitiveTypes.library.uml#EStr ing"/>
>>> </Ecore:ETypeParameter>
>>> <Ecore:EAttribute xmi:id="_8Pp2kv9ZEdu2-NJ3YDjyEA"
>>> base_Property="_8Pp2hv9ZEdu2-NJ3YDjyEA"/>
>>> <Ecore:EOperation xmi:id="_8Pp2k_9ZEdu2-NJ3YDjyEA"
>>> base_Operation="_8Pp2h_9ZEdu2-NJ3YDjyEA"/>
>>> <Ecore:EParameter xmi:id="_8Pp2lP9ZEdu2-NJ3YDjyEA"
>>> base_Parameter="_8Pp2iv9ZEdu2-NJ3YDjyEA"/>
>>> </xmi:XMI>
>>>
>>
>>
>
>
Previous Topic:[Announce] MDT UML2 2.1.0 I200705111324 is available
Next Topic:Retrieving a Profile through a ProfileApplication
Goto Forum:
  


Current Time: Fri Apr 26 12:41:12 GMT 2024

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

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

Back to the top