Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Direct Reference CrossReferencer?
Direct Reference CrossReferencer? [message #421498] Fri, 08 August 2008 01:26 Go to next message
Alberto Ricart is currently offline Alberto RicartFriend
Messages: 33
Registered: July 2009
Member
Hello,


I am wondering if there's a way to determine if a reference is direct
or indirect.
Example if I have 3 objects, A which references B, which references C:

A->B->C


If I use any of the CrossReferencers to get the references held by A, I
will not only get B but also C. In the case that I am looking
(implementing a builder and refactoring), I would like to obtain only
direct references, so A will report 'B' as its only reference and 'B'
will report 'C' as its only reference.

Is there a way of doing this, I naively to filter things based on the
source's uri, but that doesn't seem to do the trick.

protected boolean crossReference(EObject object, EReference reference,
EObject crossReferencedEObject)
{
boolean isInternal = me.equals(object.eResource().getURI());
return isInternal;
}

protected boolean resolve()
{
return false;
}

Any help appreciated.

Thanks,

/a
Re: Direct Reference CrossReferencer? [message #421518 is a reply to message #421498] Fri, 08 August 2008 12:00 Go to previous message
Ed Merks is currently online Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Alberto,

Comments below.

Alberto Ricart wrote:
> Hello,
>
>
> I am wondering if there's a way to determine if a reference is direct
> or indirect.
> Example if I have 3 objects, A which references B, which references C:
>
> A->B->C
>
>
> If I use any of the CrossReferencers to get the references held by A,
> I will not only get B but also C.
I don't think so. The cross referencer will only return
EStructuralFeature.Setting instances where the key of the map is a
member of a value in the setting. It also does the opposite, i.e., it
yields incoming references not outgoing references. For x of type A,
x.eCrossReferences() returns all the direct references held by A.
> In the case that I am looking (implementing a builder and
> refactoring), I would like to obtain only direct references, so A will
> report 'B' as its only reference and 'B' will report 'C' as its only
> reference.
>
> Is there a way of doing this, I naively to filter things based on the
> source's uri, but that doesn't seem to do the trick.
>
> protected boolean crossReference(EObject object, EReference reference,
> EObject crossReferencedEObject)
> {
> boolean isInternal = me.equals(object.eResource().getURI());
> return isInternal;
> }
>
> protected boolean resolve()
> {
> return false;
> }
>
> Any help appreciated.
I'm a little confused. Is suspect you're misinterpreting something, but
it's not clear what. Note that ECrossReferenceAdapter might be handy
because it will allow you to efficiently determine the inverse of any
unidirectional reference because it keeps an up-to-date cross referencer
for that. (Of course bidirectional references directly track their inverse.)
>
> Thanks,
>
> /a
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:EMF clipboard copy and paste
Next Topic:Property sheet does not update
Goto Forum:
  


Current Time: Fri Apr 26 06:28:42 GMT 2024

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

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

Back to the top