Hello, i'm building a j2me application where i have the data model using POJO's and Vectors.
My objective is to persist and restore the object tree automaticly.
At first, for every class i wanted to persist i had 2 methods, one to convert all of the object properties to byte[] data and another to reconstruct the object from byte[] data, ensuring the read/write order for input/output datastreams.
But that was a lot of work and hard code to maintain, so i implemented the persistable object properties using an OrderedHashTable (an hashtable extended class that garantees the same order in adding/enumerating elements for appropriate din.readUTF()/din.readBlahBlah()).
A few bugs apart i can now have a detatched data model, in wich the properties can be only objects (Strings, Booleans, Vectors, etc), all of wich are recursively persisted and restored.
My doubt is that this all seems too complicated and the devices have limitations of course. For a simple app like a 'todo list' a recordstore of String objects works perfectly but whats the best approach when theres a complex datastructure to maintain.
Example:
i have a Blog object, that has a Vector of Entries; an Entry has another properties, etc

Reply With Quote

