Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » how to model an iterator?
how to model an iterator? [message #427087] Sat, 31 January 2009 14:33 Go to next message
Andre Dietisheim is currently offline Andre DietisheimFriend
Messages: 131
Registered: July 2009
Senior Member
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 #427091 is a reply to message #427087] Sat, 31 January 2009 20:24 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
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é


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: how to model an iterator? [message #427093 is a reply to message #427091] Sat, 31 January 2009 23:53 Go to previous message
Andre Dietisheim is currently offline Andre DietisheimFriend
Messages: 131
Registered: July 2009
Senior Member
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é
Previous Topic:Working with XML files with EMF?
Next Topic:Tracking the modification of a resource given by it’s URI
Goto Forum:
  


Current Time: Tue Apr 23 15:14:38 GMT 2024

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

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

Back to the top