From ec3f04cab32d2ffe44883f03b5246a7929b22130 Mon Sep 17 00:00:00 2001 From: hns Date: Fri, 18 Sep 2009 20:40:36 +0000 Subject: [PATCH] Rename __fullname__ internal HopObject property to __path__, fill in/trim some comments. --- src/helma/objectmodel/INode.java | 232 +++++------------------ src/helma/objectmodel/TransientNode.java | 4 +- src/helma/objectmodel/db/Node.java | 120 ++++-------- 3 files changed, 91 insertions(+), 265 deletions(-) diff --git a/src/helma/objectmodel/INode.java b/src/helma/objectmodel/INode.java index 57336925..c5ab4fe5 100644 --- a/src/helma/objectmodel/INode.java +++ b/src/helma/objectmodel/INode.java @@ -27,364 +27,234 @@ import java.util.*; */ 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 ... - */ - public String getFullName(INode root); - - /** - * node-related methods + * Get the node's parent node. */ 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); } diff --git a/src/helma/objectmodel/TransientNode.java b/src/helma/objectmodel/TransientNode.java index ab96f818..c0c41e68 100644 --- a/src/helma/objectmodel/TransientNode.java +++ b/src/helma/objectmodel/TransientNode.java @@ -108,7 +108,7 @@ public class TransientNode implements INode, Serializable { // state always is TRANSIENT on this kind of node } - public String getFullName() { + public String getPath() { return getFullName(null); } @@ -159,7 +159,7 @@ public class TransientNode implements INode, Serializable { } 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() { diff --git a/src/helma/objectmodel/db/Node.java b/src/helma/objectmodel/db/Node.java index fb8d4a09..e181524b 100644 --- a/src/helma/objectmodel/db/Node.java +++ b/src/helma/objectmodel/db/Node.java @@ -439,28 +439,15 @@ public final class Node implements INode { } /** - * - * - * @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 @@ public final class Node implements INode { 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 @@ public final class Node implements INode { } /** - * - * - * @param proto ... + * Set the node's prototype name. */ public void setPrototype(String proto) { this.prototype = proto; @@ -509,27 +491,21 @@ public final class Node implements INode { } /** - * - * - * @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 @@ public final class Node implements INode { } /** - * - * - * @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 @@ public final class Node implements INode { } /** - * - * - * @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 @@ public final class Node implements INode { } /** - * - * - * @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 @@ public final class Node implements INode { } 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;