From: Jeff M. <je...@mk...> - 2002-02-28 12:21:15
|
If you look at the documentation http://java.sun.com/j2se/1.3/docs/api/java/io/Serializable.html it details this. Basically java uses two private methods. private void writeObject(java.io.ObjectOutputStream out) throws IOException and private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException; to handle serialization. You can implement you own versions of these methods on an object so that the jvm uses these to serialize/deserialize the object. This mean that when you do o = new ObjectOutputStream(new FileOutputStream(filename)); o.writeObject(myClass); java uses your o.writeObject to write the object to disk. You can then use any format you wish to describe the object. If you represent you object as a byte array you should be able to read this array into pyhon and populate a python object using this data. On Wed, 2002-02-27 at 21:47, Nicolas Bill Russell wrote: > > Really? Could you please explain in detail. :) > o = new ObjectOutputStream(new FileOutputStream(filename)); > o.writeObject(myClass); (?) > Isn't the syntax of Python classes different from Java? > Thanks, > Bill Nicolas > Jeff Martin <je...@mk...> wrote: You could try implementing the readObject and writeObject methods on > your java object. This would allow you to control the format into which > they are serialized so you can interpret in in python. > > > On Tue, 2002-02-26 at 21:31, Nicolas Bill Russell wrote: > > > > The reason why I want to use Jython is that I need to access serialized Java objects. > > I've designed a system that uses objects as the main storage media rather than databases. I used Java for the frontend of my system (Swing GUIs and object serialization) and is planning to use Python (Jython) for client-side processing of Java objects. > > Is there any other (simpler) way to access Java objects using Python? > > Thanks, > > Bill Russell Gagalac-Nicolas > > > > > > > > --------------------------------- > > Do You Yahoo!? > > Get personalised at My Yahoo!. > -- > > > > --------------------------------- > Do You Yahoo!? > Get personalised at My Yahoo!. -- |