Skip to main content



      Home
Home » Modeling » EMF » how to model an iterator?
how to model an iterator? [message #427087] Sat, 31 January 2009 09:33 Go to next message
Eclipse UserFriend
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 15:24 Go to previous messageGo to next message
Eclipse UserFriend
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é
Re: how to model an iterator? [message #427093 is a reply to message #427091] Sat, 31 January 2009 18:53 Go to previous message
Eclipse UserFriend
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: Sat Jul 19 19:54:34 EDT 2025

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

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

Back to the top