r9929 - in helma/helma/trunk/src/helma/objectmodel: . db

[email protected] Fri, 18 Sep 2009 22:40:37 +0200 (CEST)
Newsgroups gmane.comp.java.helma.cvs
Message-ID <20090918204037.0B3D43D0E3@mia>
Author: hannes
Date: 2009-09-18 22:40:36 +0200 (Fri, 18 Sep 2009)
New Revision: 9929

Modified:
   helma/helma/trunk/src/helma/objectmodel/INode.java
   helma/helma/trunk/src/helma/objectmodel/TransientNode.java
   helma/helma/trunk/src/helma/objectmodel/db/Node.java
Log:
Rename __fullname__ internal HopObject property to __path__, fill in/trim some comments.

Details at http://dev.helma.org/trac/helma/changeset/9929

Modified: helma/helma/trunk/src/helma/objectmodel/INode.java
===================================================================
--- helma/helma/trunk/src/helma/objectmodel/INode.java	2009-09-18 19:58:10 UTC (rev 9928)
+++ helma/helma/trunk/src/helma/objectmodel/INode.java	2009-09-18 20:40:36 UTC (rev 9929)
@@ -27,364 +27,234 @@
  */
 public interface INode extends INodeState, IPathElement {
     /**
-     *  id-related methods
+     * Get the node's ID.
      */
     public String getID();
 
     /**
-     *
-     *
-     * @return ...
+     * Get the node's name.
      */
     public String getName();
 
     /**
-     *
-     *
-     * @param dbmap ...
+     * Set the node's {@link DbMapping}.
      */
     public void setDbMapping(DbMapping dbmap);
 
     /**
-     *
-     *
-     * @return ...
+     * Get the node's {@link DbMapping}.
      */
     public DbMapping getDbMapping();
 
     /**
-     *
-     *
-     * @return ...
+     * Get the node's state flag.
+     * @return one of the constants defined in the {@link INodeState} interface.
      */
     public int getState();
 
     /**
-     *
-     *
-     * @param s ...
+     * Set the node's state flag.
+     * @param s one of the constants defined in the {@link INodeState} interface.
      */
     public void setState(int s);
 
     /**
-     *
-     *
-     * @param name ...
+     * Set the node's name.
      */
     public void setName(String name);
 
     /**
-     *
-     *
-     * @return ...
+     * Get the node's last modification timestamp.
      */
     public long lastModified();
 
     /**
-     *
-     *
-     * @return ...
+     * Get the node's creation timestamp.
      */
     public long created();
 
     /**
-     *
-     *
-     * @return ...
+     * Returns true if this node is an unnamed node.
      */
-    public boolean isAnonymous(); // is this a named node, or an anonymous node in a collection?
+    public boolean isAnonymous();
 
     /**
-     *
-     *
-     * @return ...
+     * Return the node's prototype name.
      */
     public String getPrototype();
 
     /**
-     *
-     *
-     * @param prototype ...
+     * Set the node's prototype name.
      */
     public void setPrototype(String prototype);
 
     /**
-     *
-     *
-     * @return ...
+     * Get the cache node associated with this node.
      */
     public INode getCacheNode();
 
     /**
-     *
+     * Clear the cache node associated with this node.
      */
     public void clearCacheNode();
 
     /**
-     *
-     *
-     * @return ...
+     * Get the node's path.
      */
-    public String getFullName();
+    public String getPath();
 
     /**
-     *
-     *
-     * @param root ...
-     *
-     * @return ...
+     * Get the node's parent node.
      */
-    public String getFullName(INode root);
-
-    /**
-     *  node-related methods
-     */
     public INode getParent();
 
     /**
-     *
-     *
-     * @param rel ...
+     * Set an explicit select clause for the node's subnodes
      */
-    public void setSubnodeRelation(String rel);
+    public void setSubnodeRelation(String clause);
 
     /**
-     *
-     *
-     * @return ...
+     * Get the node's explicit subnode select clause if one was set, or null
      */
     public String getSubnodeRelation();
 
     /**
-     *
-     *
-     * @return ...
+     * Get the number the node's direct child nodes.
      */
     public int numberOfNodes();
 
     /**
-     *
-     *
-     * @param node ...
-     *
-     * @return ...
+     * Add a child node to this node.
      */
     public INode addNode(INode node);
 
     /**
-     *
-     *
-     * @param node ...
-     * @param where ...
-     *
-     * @return ...
+     * Add a child node to this node at the given position
      */
     public INode addNode(INode node, int where);
 
     /**
-     *
-     *
-     * @param name ...
-     *
-     * @return ...
+     * Create a new named property with a node value
      */
     public INode createNode(String name);
 
     /**
-     *
-     *
-     * @param name ...
-     * @param where ...
-     *
-     * @return ...
+     * Create a new unnamed child node at the given position.
      */
     public INode createNode(String name, int where);
 
     /**
-     *
-     *
-     * @return ...
+     * Get an enumeration of this node's unnamed child nodes
      */
     public Enumeration getSubnodes();
 
     /**
-     *
-     *
-     * @param name ...
-     *
-     * @return ...
+     * Get a named child node with the given name or id.
      */
     public INode getSubnode(String name);
 
     /**
-     *
-     *
-     * @param index ...
-     *
-     * @return ...
+     * GEt an unnamed child node at the given position
      */
     public INode getSubnodeAt(int index);
 
     /**
-     *
-     *
-     * @param node ...
-     *
-     * @return ...
+     * Returns the position of the child or -1.
      */
     public int contains(INode node);
 
     /**
-     *
-     *
-     * @return ...
+     * Remove this node from the database.
      */
     public boolean remove();
 
     /**
-     *
-     *
-     * @param node ...
+     * Remove the given node from this node's child nodes.
      */
     public void removeNode(INode node);
 
     /**
-     *  property-related methods
+     *  Get an enumeration over the node's properties.
      */
     public Enumeration properties();
 
     /**
-     *
-     *
-     * @param name ...
-     *
-     * @return ...
+     * Get a property with the given name.
      */
     public IProperty get(String name);
 
     /**
-     *
-     *
-     * @param name ...
-     *
-     * @return ...
+     * Get a string property with the given name.
      */
     public String getString(String name);
 
     /**
-     *
-     *
-     * @param name ...
-     *
-     * @return ...
+     * Get a boolean property with the given name.
      */
     public boolean getBoolean(String name);
 
     /**
-     *
-     *
-     * @param name ...
-     *
-     * @return ...
+     * Get a date property with the given name.
      */
     public Date getDate(String name);
 
     /**
-     *
-     *
-     * @param name ...
-     *
-     * @return ...
+     * Get an integer property with the given name.
      */
     public long getInteger(String name);
 
     /**
-     *
-     *
-     * @param name ...
-     *
-     * @return ...
+     * Get a float property with the given name.
      */
     public double getFloat(String name);
 
     /**
-     *
-     *
-     * @param name ...
-     *
-     * @return ...
+     * Get a node property with the given name.
      */
     public INode getNode(String name);
 
     /**
-     *
-     *
-     * @param name ...
-     *
-     * @return ...
+     * Get a Java object property with the given name.
      */
     public Object getJavaObject(String name);
 
     /**
-     *
-     *
-     * @param name ...
-     * @param value ...
+     * Set the property with the given name to the given string value.
      */
     public void setString(String name, String value);
 
     /**
-     *
-     *
-     * @param name ...
-     * @param value ...
+     * Set the property with the given name to the given boolean value.
      */
     public void setBoolean(String name, boolean value);
 
     /**
-     *
-     *
-     * @param name ...
-     * @param value ...
+     * Set the property with the given name to the given date value.
      */
     public void setDate(String name, Date value);
 
     /**
-     *
-     *
-     * @param name ...
-     * @param value ...
+     * Set the property with the given name to the given integer value.
      */
     public void setInteger(String name, long value);
 
     /**
-     *
-     *
-     * @param name ...
-     * @param value ...
+     * Set the property with the given name to the given float value.
      */
     public void setFloat(String name, double value);
 
     /**
-     *
-     *
-     * @param name ...
-     * @param value ...
+     * Set the property with the given name to the given node value.
      */
     public void setNode(String name, INode value);
 
     /**
-     *
-     *
-     * @param name ...
-     * @param value ...
+     * Set the property with the given name to the given Java object value.
      */
     public void setJavaObject(String name, Object value);
 
     /**
-     *
-     *
-     * @param name ...
+     * Unset the property with the given name..
      */
     public void unset(String name);
 }

Modified: helma/helma/trunk/src/helma/objectmodel/TransientNode.java
===================================================================
--- helma/helma/trunk/src/helma/objectmodel/TransientNode.java	2009-09-18 19:58:10 UTC (rev 9928)
+++ helma/helma/trunk/src/helma/objectmodel/TransientNode.java	2009-09-18 20:40:36 UTC (rev 9929)
@@ -108,7 +108,7 @@
         // state always is TRANSIENT on this kind of node
     }
 
-    public String getFullName() {
+    public String getPath() {
         return getFullName(null);
     }
 
@@ -159,7 +159,7 @@
     }
 
     public void setSubnodeRelation(String rel) {
-        throw new RuntimeException("Can't set subnode relation for non-persistent Node.");
+        throw new UnsupportedOperationException("Can't set subnode relation for non-persistent Node.");
     }
 
     public String getSubnodeRelation() {

Modified: helma/helma/trunk/src/helma/objectmodel/db/Node.java
===================================================================
--- helma/helma/trunk/src/helma/objectmodel/db/Node.java	2009-09-18 19:58:10 UTC (rev 9928)
+++ helma/helma/trunk/src/helma/objectmodel/db/Node.java	2009-09-18 20:40:36 UTC (rev 9929)
@@ -439,28 +439,15 @@
     }
 
     /**
-     *
-     *
-     * @return ...
+     * Get the node's path
      */
-    public String getFullName() {
-        return getFullName(null);
-    }
-
-    /**
-     *
-     *
-     * @param root ...
-     *
-     * @return ...
-     */
-    public String getFullName(INode root) {
+    public String getPath() {
         String divider = null;
         StringBuffer b = new StringBuffer();
         INode p = this;
         int loopWatch = 0;
 
-        while ((p != null) && (p.getParent() != null) && (p != root)) {
+        while (p != null && p.getParent() != null) {
             if (divider != null) {
                 b.insert(0, divider);
             } else {
@@ -478,14 +465,11 @@
                 break;
             }
         }
-
         return b.toString();
     }
 
     /**
-     *
-     *
-     * @return ...
+     * Return the node's prototype name.
      */
     public String getPrototype() {
         // if prototype is null, it's a vanilla HopObject.
@@ -497,9 +481,7 @@
     }
 
     /**
-     *
-     *
-     * @param proto ...
+     * Set the node's prototype name.
      */
     public void setPrototype(String proto) {
         this.prototype = proto;
@@ -509,27 +491,21 @@
     }
 
     /**
-     *
-     *
-     * @param dbmap ...
+     * Set the node's {@link DbMapping}.
      */
     public void setDbMapping(DbMapping dbmap) {
         this.dbmap = dbmap;
     }
 
     /**
-     *
-     *
-     * @return ...
+     * Get the node's {@link DbMapping}.
      */
     public DbMapping getDbMapping() {
         return dbmap;
     }
 
     /**
-     *
-     *
-     * @return ...
+     * Get the node's key.
      */
     public Key getKey() {
         if (primaryKey == null && state == TRANSIENT) {
@@ -548,22 +524,17 @@
     }
 
     /**
-     *
-     *
-     * @return ...
+     * Get the node's handle.
      */
     public NodeHandle getHandle() {
         if (handle == null) {
             handle = new NodeHandle(this);
         }
-
         return handle;
     }
 
     /**
-     *
-     *
-     * @param rel ...
+     * Set an explicit select clause for the node's subnodes
      */
     public synchronized void setSubnodeRelation(String rel) {
         if ((rel == null && this.subnodeRelation == null) ||
@@ -582,18 +553,14 @@
     }
 
     /**
-     *
-     *
-     * @return ...
+     * Get the node's explicit subnode select clause if one was set, or null
      */
     public synchronized String getSubnodeRelation() {
         return subnodeRelation;
     }
 
     /**
-     *
-     *
-     * @param name ...
+     * Set the node's name.
      */
     public void setName(String name) {
         if ((name == null) || (name.length() == 0)) {
@@ -1025,11 +992,7 @@
     }
 
     /**
-     *
-     *
-     * @param subid ...
-     *
-     * @return ...
+     * Get a named child node with the given id.
      */
     public INode getSubnode(String subid) {
         if (subid == null || subid.length() == 0) {
@@ -1037,45 +1000,38 @@
         }
 
         Node retval = null;
+        loadNodes();
+        if (subnodes == null || subnodes.size() == 0) {
+            return null;
+        }
 
-        if (subid != null) {
-            loadNodes();
+        NodeHandle nhandle = null;
+        int l = subnodes.size();
 
-            if ((subnodes == null) || (subnodes.size() == 0)) {
-                return null;
-            }
-
-            NodeHandle nhandle = null;
-            int l = subnodes.size();
-
-            for (int i = 0; i < l; i++)
-                try {
-                    NodeHandle shandle = subnodes.get(i);
-
-                    if (subid.equals(shandle.getID())) {
-                        // System.err.println ("FOUND SUBNODE: "+shandle);
-                        nhandle = shandle;
-
-                        break;
-                    }
-                } catch (Exception x) {
+        for (int i = 0; i < l; i++) {
+            try {
+                NodeHandle shandle = subnodes.get(i);
+                if (subid.equals(shandle.getID())) {
+                    nhandle = shandle;
                     break;
                 }
-
-            if (nhandle != null) {
-                retval = nhandle.getNode(nmgr);
+            } catch (Exception x) {
+                break;
             }
+        }
 
-            // This would be an alternative way to do it, without loading the subnodes,
-            // but it currently isn't supported by NodeManager.
-            //    if (dbmap != null && dbmap.getSubnodeRelation () != null)
-            //         retval = nmgr.getNode (this, subid, dbmap.getSubnodeRelation ());
+        if (nhandle != null) {
+            retval = nhandle.getNode(nmgr);
+        }
 
-            if ((retval != null) && (retval.parentHandle == null) &&
-                    !nmgr.isRootNode(retval)) {
-                retval.setParent(this);
-                retval.anonymous = true;
-            }
+        // This would be a better way to do it, without loading the subnodes,
+        // but it currently isn't supported by NodeManager.
+        //    if (dbmap != null && dbmap.getSubnodeRelation () != null)
+        //         retval = nmgr.getNode (this, subid, dbmap.getSubnodeRelation ());
+
+        if (retval != null && retval.parentHandle == null && !nmgr.isRootNode(retval)) {
+            retval.setParent(this);
+            retval.anonymous = true;
         }
 
         return retval;