Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Defining 'equals'-operation on custom datatype
Defining 'equals'-operation on custom datatype [message #512955] Mon, 08 February 2010 12:40 Go to next message
RJ is currently offline RJFriend
Messages: 19
Registered: October 2009
Location: Eindhoven, The Netherland...
Junior Member
Hi all,

I created a custom datatype to represent String, let's call it XString. I did this so that I could put a constraints on the allowed characters in the XString. So I added a datatype to my Ecore model, and set the Instance Class Name to java.lang.String

However, now I get an error when I want to compare XStrings:

Could find operation '==(Model::XString)' for type 'Model:XString'


While it is true that I did not define this operation, I kind of hoped it was implied by setting the instance class to java.lang.String. But apparently this is not the case.

So my question now is, what to do? Where do I define the equals operation? Or do I have to link my datatype to the standard String datatype in another way?

Thanks in advance,
Re: Defining 'equals'-operation on custom datatype [message #512983 is a reply to message #512955] Mon, 08 February 2010 13:46 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
RJ,

Comments below.

RJ wrote:
> Hi all,
>
> I created a custom datatype to represent String, let's call it
> XString. I did this so that I could put a constraints on the allowed
> characters in the XString. So I added a datatype to my Ecore model,
> and set the Instance Class Name to java.lang.String
>
> However, now I get an error when I want to compare XStrings:
>
> Could find operation '==(Model::XString)' for type 'Model:XString'
Where are you seeing this error?
>
>
> While it is true that I did not define this operation, I kind of hoped
> it was implied by setting the instance class to java.lang.String. But
> apparently this is not the case.
>
> So my question now is, what to do? Where do I define the equals
> operation? Or do I have to link my datatype to the standard String
> datatype in another way?
I get the sense this is an OCL question or belongs somewhere else. I
don't know how this issue arises purely with EMF itself...
>
> Thanks in advance,


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Defining 'equals'-operation on custom datatype [message #513002 is a reply to message #512955] Mon, 08 February 2010 14:46 Go to previous messageGo to next message
RJ is currently offline RJFriend
Messages: 19
Registered: October 2009
Location: Eindhoven, The Netherland...
Junior Member
Maybe you're right about that. I get the error in .chk files (which are indeed OCL) and in extension files for Xpand (which is I guess also (a form of) OCL).

But then again, it is a problem that occurs in different parts of the Framework, that's why I figured I'd post it in the general EMF forum.

Furthermore, the problem (I think) is caused by the fact that I can't link the XString datatype correctly to the original Java String datatype, which is an Ecore related question.

But if you feel that this question is in the wrong section, by all means, move it to a correct one. I'm just hoping to get an answer to my question.

[Updated on: Mon, 08 February 2010 14:46]

Report message to a moderator

Re: Defining 'equals'-operation on custom datatype [message #513013 is a reply to message #513002] Mon, 08 February 2010 10:24 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
RJ,

I'm really not sure what the correct place is. If it's about OCL, then
yes, ask on the OCL newsgroup/forum. If it's about Xpand, ask there.
There's nothing in Ecore itself to help or hinder this.


RJ wrote:
> Maybe you're right about that. I get the error in .chk files (which
> are indeed OCL) and in extension files for Xpand (which is I guess
> also (a form of) OCL).
>
> But then again, it is a problem that occurs in different parts of the
> Framework, that's why I figured I'd post it in the general EMF forum.
>
> Furthermore, the problem (I thinks) is caused by the fact that I can't
> link the XString datatype correctly to the original Java String
> datatype, which is an Ecore related question.
>
> But if you feel that this question is in the wrong section, by all
> means, move it to a correct one. I'm just hoping to get an answer to
> my question.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Defining 'equals'-operation on custom datatype [message #513043 is a reply to message #513002] Mon, 08 February 2010 16:12 Go to previous message
Christian Damus is currently offline Christian DamusFriend
Messages: 1270
Registered: July 2009
Location: Canada
Senior Member

--=-Epyf9Ju6eJ5SldiGXhXN
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hi, RJ,

The Check language is not OCL, though its syntax borrows heavily from
OCL. It is maintained in the M2T XPand project, so you should ask about
how to define the == operation for datatypes in Xpand in the
modeling.m2t newsgroup.

Cheers,

Christian


On Mon, 2010-02-08 at 15:46 +0100, RJ wrote:

> Maybe you're right about that. I get the error in .chk files (which are indeed OCL) and in extension files for Xpand (which is I guess also (a form of) OCL).
>
> But then again, it is a problem that occurs in different parts of the Framework, that's why I figured I'd post it in the general EMF forum.
>
> Furthermore, the problem (I thinks) is caused by the fact that I can't link the XString datatype correctly to the original Java String datatype, which is an Ecore related question.
>
> But if you feel that this question is in the wrong section, by all means, move it to a correct one. I'm just hoping to get an answer to my question.

--=-Epyf9Ju6eJ5SldiGXhXN
Content-Type: text/html; charset="utf-8"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.24.1.1">
</HEAD>
<BODY>
Hi, RJ,<BR>
<BR>
The Check language is not OCL, though its syntax borrows heavily from OCL.&nbsp; It is maintained in the M2T XPand project, so you should ask about how to define the == operation for datatypes in Xpand in the modeling.m2t newsgroup.<BR>
<BR>
Cheers,<BR>
<BR>
Christian<BR>
<BR>
<BR>
On Mon, 2010-02-08 at 15:46 +0100, RJ wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
Maybe you're right about that. I get the error in .chk files (which are indeed OCL) and in extension files for Xpand (which is I guess also (a form of) OCL).

But then again, it is a problem that occurs in different parts of the Framework, that's why I figured I'd post it in the general EMF forum.

Furthermore, the problem (I thinks) is caused by the fact that I can't link the XString datatype correctly to the original Java String datatype, which is an Ecore related question.

But if you feel that this question is in the wrong section, by all means, move it to a correct one. I'm just hoping to get an answer to my question.
</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>

--=-Epyf9Ju6eJ5SldiGXhXN--
Previous Topic:[EMF Transaction] How to obtain domain element from TransactionalEditingDomain?
Next Topic:containment attribute for references
Goto Forum:
  


Current Time: Thu Apr 25 11:54:34 GMT 2024

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

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

Back to the top