Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EList support list or not
EList support list or not [message #416633] Fri, 08 February 2008 15:55 Go to next message
Simon Mc Duff is currently offline Simon Mc DuffFriend
Messages: 596
Registered: July 2009
Senior Member
I would like to know if EList support null pointer.


If yes I got an exception when I'm using it with DelegatingEcoreEList.

protected EObject resolveProxy(EObject eObject)
{

return eObject.eIsProxy() ? owner.eResolveProxy((InternalEObject)eObject) :
eObject;

}


eObject == null... So it is failing.

Simon
Re: EList support null ? [message #416634 is a reply to message #416633] Fri, 08 February 2008 15:56 Go to previous messageGo to next message
Simon Mc Duff is currently offline Simon Mc DuffFriend
Messages: 596
Registered: July 2009
Senior Member
Correct the title.

"Simon McDuff" <smcduff@hotmail.com> wrote in message
news:fohu2f$1j0$1@build.eclipse.org...
>I would like to know if EList support null pointer.
>
>
> If yes I got an exception when I'm using it with DelegatingEcoreEList.
>
> protected EObject resolveProxy(EObject eObject)
> {
>
> return eObject.eIsProxy() ? owner.eResolveProxy((InternalEObject)eObject)
> : eObject;
>
> }
>
>
> eObject == null... So it is failing.
>
> Simon
>
>
>
>
Re: EList support null ? [message #416635 is a reply to message #416634] Fri, 08 February 2008 16:54 Go to previous messageGo to next message
David Steinberg is currently offline David SteinbergFriend
Messages: 489
Registered: July 2009
Senior Member
Hi Simon,

ELists may or may not support null elements. Notice how BasicEList
defines a canContainNull(), which it consults when deciding whether to
allow an element to be added. Subclasses can (and do) override this to
disallow null.

Lists implementing data types (EDataTypeEList, etc.) allow null. Those
implementing references (EObjectEList, etc.) do not.
DelegatingEcoreEList's implementation of canContainNull() is supposed to
return the right result based on the type of feature the list is
representing.

If it's allowing you to add null for a reference and that's later
causing a failure in resolveProxy(), I'd say that's a bug, which is best
addressed by opening a bugzilla, preferably with a a reproduceable test
case.

Cheers,
Dave


Simon McDuff wrote:
> I would like to know if EList support null pointer.
>
> If yes I got an exception when I'm using it with DelegatingEcoreEList.
>
> protected EObject resolveProxy(EObject eObject)
> {
> return eObject.eIsProxy() ? owner.eResolveProxy((InternalEObject)eObject)
> : eObject;
> }
>
> eObject == null... So it is failing.
>
> Simon
>
>
Re: EList support null ? [message #416648 is a reply to message #416635] Sun, 10 February 2008 03:15 Go to previous messageGo to next message
Simon Mc Duff is currently offline Simon Mc DuffFriend
Messages: 596
Registered: July 2009
Senior Member
Here what it is doing

Another question in the following class
DelegatingEcoreEList

@Override

protected boolean canContainNull()

{

return (kind & (IS_EOBJECT | IS_PRIMITIVE | IS_ENUM)) == 0;

}

This mean that for primitive and IS_EOBJECT .. it cannot support null.
How can I create a List of reference that support null in my model ?

By looking at the code above, it seems impossible since as soon as I have a
Reference, it doesn`t support null.
(IS_EOBJECT will be activated if the EStruturalFeature instanceof
EReference)



"Dave Steinberg" <davidms@ca.ibm.com> a
Re: EList support null ? [message #416649 is a reply to message #416648] Sun, 10 February 2008 17:37 Go to previous messageGo to next message
David Steinberg is currently offline David SteinbergFriend
Messages: 489
Registered: July 2009
Senior Member
Simon McDuff wrote:
> Another question in the following class
> DelegatingEcoreEList
>
> @Override
> protected boolean canContainNull()
> {
> return (kind & (IS_EOBJECT | IS_PRIMITIVE | IS_ENUM)) == 0;
> }

Hi Simon,

Note that this is actually the implementation for
DelegatingEcoreEList.Generic, though this doesn't have any impact on
your question as the DelegatingEcoreEList implementation is similar.

> This mean that for primitive and IS_EOBJECT .. it cannot support null.

That's right. The list representing a multi-valued reference cannot
contain null.

> How can I create a List of reference that support null in my model ?

As far as I know, you can't. When you model something like this:

+---+ b +---+
| A |------>| B |
+---+ 0..* +---+

You're saying simply that reference b can refer to 0 or more instances
of B. One instance of B, followed by null, followed by another instance
of B doesn't match that description. So, I believe it's quite widely
accepted that a Java List that doesn't accept null is a reasonable
implementation of that construct.

It's also quite handy for client code, and framework stuff like
serialization.

Why do you need to put null in the list?

Cheers,
Dave
Re: EList support null ? [message #416650 is a reply to message #416649] Sun, 10 February 2008 18:15 Go to previous messageGo to next message
Simon Mc Duff is currently offline Simon Mc DuffFriend
Messages: 596
Registered: July 2009
Senior Member
My task is to migrate our projects to EMF.
Old structure uses ArrayList. ArrayList supports null.

I`m really surprised that in JAVA we can.. but not in EMF.

In a structure where position is important.. it is kind of really useful.
You can know If a specific position was initialized by a process or not.

For sure we can uses others structures... but will not be as efficient
because I will need to create objects to wrap my reel value.

class Entry
{
T reelEntry;
};

A list by definition could support NULL, I find it weird .. that in EMF it
is never the case for reference. Don`t you ?





"Dave Steinberg" <davidms@ca.ibm.com> a
Re: EList support null ? [message #416651 is a reply to message #416650] Sun, 10 February 2008 19:28 Go to previous message
David Steinberg is currently offline David SteinbergFriend
Messages: 489
Registered: July 2009
Senior Member
Simon McDuff wrote:
> In a structure where position is important.. it is kind of really useful.
> You can know If a specific position was initialized by a process or not.

I'd think that normally the items in a list would be treated uniformly.
I can't think of why you'd especially want to be selectively
initializing items in a list.

Hmm...I wonder if it might make some sense to use proxies in your
scenario? They're kind of like uninitialized objects. Perhaps there's
someone else here who's faced this problem and might have a suggestion?

> For sure we can uses others structures... but will not be as efficient
> A list by definition could support NULL, I find it weird .. that in EMF it
> is never the case for reference. Don`t you ?

Given EMF's MOF heritage, not especially. But given its evolving Swiss
Army Knife use, I see your point. ;)

Cheers,
Dave
Previous Topic:EMF configure problem
Next Topic:User data in validation
Goto Forum:
  


Current Time: Fri Mar 29 06:04:43 GMT 2024

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

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

Back to the top