From 157f7bba7fe26bbc4a38ddfcf0592456c494794c Mon Sep 17 00:00:00 2001 From: hns Date: Sat, 4 Aug 2001 11:40:24 +0000 Subject: [PATCH] Completely rewrite getSubnode(). Aded isNullNode method --- src/helma/objectmodel/db/Node.java | 81 +++++++++++++++++------------- 1 file changed, 45 insertions(+), 36 deletions(-) diff --git a/src/helma/objectmodel/db/Node.java b/src/helma/objectmodel/db/Node.java index a8c497ce..1b963042 100644 --- a/src/helma/objectmodel/db/Node.java +++ b/src/helma/objectmodel/db/Node.java @@ -23,7 +23,7 @@ import com.workingdogs.village.*; * an external relational database. */ -public class Node implements INode, Serializable { +public final class Node implements INode, Serializable { // The handle to the node's parent protected NodeHandle parentHandle; @@ -127,10 +127,11 @@ public class Node implements INode, Serializable { static final long serialVersionUID = -3740339688506633675L; /** - * This constructor is only used for instances of the NullNode subclass. Do not use for ordinary Nodes!< + * This constructor is only used for instances of the NullNode subclass. Do not use for ordinary Nodes. */ Node () { created = lastmodified = System.currentTimeMillis (); + nmgr = null; } /** @@ -838,51 +839,52 @@ public class Node implements INode, Serializable { links.add (fromHandle); } - public INode getSubnode (String path) { - StringTokenizer st = new StringTokenizer (path, "/"); - Node retval = this, runner; - - while (st.hasMoreTokens () && retval != null) { - runner = retval; - String next = st.nextToken().trim().toLowerCase (); - - if ("".equals (next)) { - retval = this; - } else { - runner.loadNodes (); - Relation srel = null; - DbMapping smap = null; - if (runner.dbmap != null) { - srel = runner.dbmap.getSubnodeRelation (); - smap = runner.dbmap.getSubnodeMapping (); - } + public INode getSubnode (String subid) { + // System.err.println ("GETSUBNODE : "+this+" > "+subid); + Node retval = null; + if ("".equals (subid)) { + return this; + } else if (subid != null) { + loadNodes (); + if (subnodes == null || subnodes.size() == 0) + return null; // check if there is a group-by relation - NodeHandle nhandle = null; - if (srel != null && srel.groupby != null) + NodeHandle nhandle = null; + int l = subnodes.size (); + for (int i=0; i