From 1c33b76e854d75b4840809fa692a16883e77e65e Mon Sep 17 00:00:00 2001 From: hns Date: Sun, 5 Aug 2001 19:25:20 +0000 Subject: [PATCH] deserialization now works with the old pre 1.2 format. fixed forward property references that point to a secondary key. --- src/helma/objectmodel/db/Node.java | 61 ++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 11 deletions(-) diff --git a/src/helma/objectmodel/db/Node.java b/src/helma/objectmodel/db/Node.java index 1b963042..da43745e 100644 --- a/src/helma/objectmodel/db/Node.java +++ b/src/helma/objectmodel/db/Node.java @@ -44,17 +44,20 @@ public final class Node implements INode, Serializable { // anonymous node in a subnode collection? protected boolean anonymous = false; + // the serialization version this object was read from (see readObject()) + protected short version = 0; + private void readObject (ObjectInputStream in) throws IOException { try { // as a general rule of thumb, if a string can bu null use read/writeObject, // if not it's save to use read/writeUTF. // version indicates the serialization version - int version = in.readShort (); + version = in.readShort (); + String rawParentID = null; id = in.readUTF (); name = in.readUTF (); if (version < 5) - throw new IOException ("Unsupported Data Format (pre 1.2)"); - // parentHandle = new NodeHandle (new Key (null, (String) in.readObject ())); + rawParentID = (String) in.readObject (); else parentHandle = (NodeHandle) in.readObject (); created = in.readLong (); @@ -73,6 +76,29 @@ public final class Node implements INode, Serializable { prototype = in.readUTF (); else if (version >= 3) prototype = (String) in.readObject (); + // if the input version is < 5, we have to do some conversion to make this object work + if (version < 5) { + if (rawParentID != null) + parentHandle = new NodeHandle (new DbKey (null, rawParentID)); + if (subnodes != null) { + for (int i=0; i