how to model an iterator? [message #427087] |
Sat, 31 January 2009 09:33  |
Eclipse User |
|
|
|
Hi Ed, Hi all!
I tried to model an iterator using EMF, but I'm currently stuck with my
current understanding. I'd greatly appreciate any hints!
My custom iterator iterates over vocables that are stored in several
boxes. (my app is a vocables learning system where you put all vocables
in box1, move the ones you know to box2, etc). I wanted to implement it
on behalf of ecore as I'd like to persist it's state. As far as I
understand ecore for now, serialization and deserialisation needs
getters and setters for each attribute that shall be persisted. On the
other hand, I wanted to have a nice iterator API where users of my class
just get hasNext() and next() exposed.
Seems like I need to implement my iterator with POJO an persist its
state in a Ecore class? Do I miss something?
Cheers + Thanks!
André
|
|
|
|
Re: how to model an iterator? [message #427093 is a reply to message #427091] |
Sat, 31 January 2009 18:53  |
Eclipse User |
|
|
|
Hi ed,
oh, of course! looks like I didn't see the forest while watching all
those trees :-) I obstinately tried to eliminate those setters and
getters instead of hiding'em beind an interace.
Thanks!!
André
Ed Merks wrote:
> André,
>
> Comments below.
>
>
> André Dietisheim wrote:
>> Hi Ed, Hi all!
>>
>> I tried to model an iterator using EMF, but I'm currently stuck with
>> my current understanding. I'd greatly appreciate any hints!
>>
>> My custom iterator iterates over vocables that are stored in several
>> boxes. (my app is a vocables learning system where you put all
>> vocables in box1, move the ones you know to box2, etc). I wanted to
>> implement it on behalf of ecore as I'd like to persist it's state. As
>> far as I understand ecore for now, serialization and deserialisation
>> needs getters and setters for each attribute that shall be persisted.
>> On the other hand, I wanted to have a nice iterator API where users of
>> my class just get hasNext() and next() exposed.
>> Seems like I need to implement my iterator with POJO an persist its
>> state in a Ecore class? Do I miss something?
> Probably I miss something. Certainly you can model an iterator as an
> EClass with isInterface true and with instance type name set to
> java.util.Iterator; it can even have a type argument. Then you can have
> other EClasses that have this as their ESuperType. These other classes
> will generate interfaces with getters and setters like normal but the
> client who seems then as an iterator can see them as just an iterator
> instance and doesn't have to know about the subclasses/interfaces it
> also implements...
>>
>> Cheers + Thanks!
>> André
|
|
|
Powered by
FUDForum. Page generated in 0.03515 seconds