I am considering to use autobeans for state serialization, i.e. a
hierachy of graphical objects sharing subsets of common properties.
Each has its specifics (specific properties, e.g. specific fields that
should be serialized), but'd like best to find a common state
serialization for them.
The basic idea is to create an autobean for the most general type
which defines all common methods, e.g.
public interface BasicObjectSerialization{
getX();
getY();
}
public class BasicObject implements BasicObjectSerialization{
getX(){return this.x};
getY(){return this.y};
}
For serialization, the object is wrapped into BasicObjectSerialization
and that autobean is then encoded.
Restoration is done by passing the autobean to a
BasicObject.restore(BasicObjectSerialization state) method which does
the restoration after the BasicObject has been instantiated.
Now, what to do with each object's specifics (i.e. those of the
subtypes)? As an example, consider the class
public class SpecialObject extends BasicObject{
getColor(){return this.color};
}
I basically see two approaches:
1) Add a method
String BasicObject.getCustomState()
which encodes the the specifics to string. This must be done
separately for each subtype of BasicObject.
- Pros:
* Definitely seems to work.
- Cons:
* It is necessesary to provide some kind of extra (de-)
serialization in each subtype with spcifics
* Overall complicated and a lot of manual things to do.
2) Create an hierachy autobeans :
public interface SpecialObjectSerialization extends
BasicObjectSerialization{
getColor();
}
- Pros:
* Put everything in an object tree and serialize once. Would make
things simple and clean
- Cons:
* It seems polymorphism is not possible with autobeans. E.g. if I
have a list of ObjectSerializations, how to get the 'specifics' of the
subtypes encoded (e.g. color)? All my attempts failed so far.
Now some questions:
Related to 2): is polymorphism indeed impossible with autobeans so
that I lose subtype specifics when serialzing lists of objects with
different subypes (but a common supertype of course)?
Related to 1): Can the extra serialization necessary in each
subtype be avoided somehow?
Ideas?
Thanks,
panam
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
No comments:
Post a Comment