Home » Modeling » UML2 » A question about the code
| |
Re: A question about the code [message #476779 is a reply to message #476771] |
Mon, 17 December 2007 19:32 |
Sunfire Messages: 71 Registered: July 2009 |
Member |
|
|
Kenn,
Thank you for your reply.
The UML2Operations.FilteredUsageCrossReferencer#handleCrossRefer ence is
transitively called by the ElementOperations#destroy, where the filter is
defined to exclude those non-changeable features.
I debugged the code before and like what you said, it seems that the
filter is not used during the list's creation. However, what confused me
is the following scenario:
Before I change anything, the filter looks like this:
FilteredUsageCrossReferencer.Filter filter = new
FilteredUsageCrossReferencer.Filter() {
public boolean accept(EStructuralFeature eStructuralFeature) {
return eStructuralFeature.isChangeable();} };
And in the method handleCrossReference, the created list for eObject is
empty since the following variable x is 0:
InternalEList filteredCrossReferences = new
FilteredECrossReferenceEList(eObject, filter);
int x = filteredCrossReferences.size();
However, if I change Filter#accept such that it always returns true, the
size of the created list for the same object would become 2.
So which part of code makes the difference?
Thanks and have a nice day,
Sunny
|
|
|
Re: A question about the code [message #476783 is a reply to message #476779] |
Tue, 18 December 2007 04:31 |
Kenn Hussey Messages: 1620 Registered: July 2009 |
Senior Member |
|
|
Sunny,
The size of the list is computed based on which features are "included". I
believe it iterates and increments a counter until there are no more
elements left, and elements in features that are not "included" (i.e. not
changeable in this case) are skipped.
Kenn
"Sunny" <sunfire001@gmail.com> wrote in message
news:9dc3ea40a8936bf6a901e68acce4b4a9$1@www.eclipse.org...
> Kenn,
>
> Thank you for your reply.
> The UML2Operations.FilteredUsageCrossReferencer#handleCrossRefer ence is
> transitively called by the ElementOperations#destroy, where the filter is
> defined to exclude those non-changeable features.
>
> I debugged the code before and like what you said, it seems that the
> filter is not used during the list's creation. However, what confused me
> is the following scenario:
>
> Before I change anything, the filter looks like this:
>
> FilteredUsageCrossReferencer.Filter filter = new
> FilteredUsageCrossReferencer.Filter() {
>
> public boolean accept(EStructuralFeature eStructuralFeature) {
> return eStructuralFeature.isChangeable();} };
>
> And in the method handleCrossReference, the created list for eObject is
> empty since the following variable x is 0:
>
> InternalEList filteredCrossReferences = new
> FilteredECrossReferenceEList(eObject, filter);
> int x = filteredCrossReferences.size();
>
> However, if I change Filter#accept such that it always returns true, the
> size of the created list for the same object would become 2.
>
> So which part of code makes the difference?
>
> Thanks and have a nice day,
>
> Sunny
>
|
|
| | | | |
Re: A question about the code [message #625752 is a reply to message #476771] |
Mon, 17 December 2007 19:32 |
Sunfire Messages: 71 Registered: July 2009 |
Member |
|
|
Kenn,
Thank you for your reply.
The UML2Operations.FilteredUsageCrossReferencer#handleCrossRefer ence is
transitively called by the ElementOperations#destroy, where the filter is
defined to exclude those non-changeable features.
I debugged the code before and like what you said, it seems that the
filter is not used during the list's creation. However, what confused me
is the following scenario:
Before I change anything, the filter looks like this:
FilteredUsageCrossReferencer.Filter filter = new
FilteredUsageCrossReferencer.Filter() {
public boolean accept(EStructuralFeature eStructuralFeature) {
return eStructuralFeature.isChangeable();} };
And in the method handleCrossReference, the created list for eObject is
empty since the following variable x is 0:
InternalEList filteredCrossReferences = new
FilteredECrossReferenceEList(eObject, filter);
int x = filteredCrossReferences.size();
However, if I change Filter#accept such that it always returns true, the
size of the created list for the same object would become 2.
So which part of code makes the difference?
Thanks and have a nice day,
Sunny
|
|
|
Re: A question about the code [message #625758 is a reply to message #476779] |
Tue, 18 December 2007 04:31 |
Kenn Hussey Messages: 1620 Registered: July 2009 |
Senior Member |
|
|
Sunny,
The size of the list is computed based on which features are "included". I
believe it iterates and increments a counter until there are no more
elements left, and elements in features that are not "included" (i.e. not
changeable in this case) are skipped.
Kenn
"Sunny" <sunfire001@gmail.com> wrote in message
news:9dc3ea40a8936bf6a901e68acce4b4a9$1@www.eclipse.org...
> Kenn,
>
> Thank you for your reply.
> The UML2Operations.FilteredUsageCrossReferencer#handleCrossRefer ence is
> transitively called by the ElementOperations#destroy, where the filter is
> defined to exclude those non-changeable features.
>
> I debugged the code before and like what you said, it seems that the
> filter is not used during the list's creation. However, what confused me
> is the following scenario:
>
> Before I change anything, the filter looks like this:
>
> FilteredUsageCrossReferencer.Filter filter = new
> FilteredUsageCrossReferencer.Filter() {
>
> public boolean accept(EStructuralFeature eStructuralFeature) {
> return eStructuralFeature.isChangeable();} };
>
> And in the method handleCrossReference, the created list for eObject is
> empty since the following variable x is 0:
>
> InternalEList filteredCrossReferences = new
> FilteredECrossReferenceEList(eObject, filter);
> int x = filteredCrossReferences.size();
>
> However, if I change Filter#accept such that it always returns true, the
> size of the created list for the same object would become 2.
>
> So which part of code makes the difference?
>
> Thanks and have a nice day,
>
> Sunny
>
|
|
| | | |
Goto Forum:
Current Time: Thu Mar 28 22:31:53 GMT 2024
Powered by FUDForum. Page generated in 0.02952 seconds
|