## helma.objectmodel.db
Class Node

    java.lang.Object
      helma.objectmodel.db.Node

All Implemented Interfaces:
  IPathElement, INode, INodeState, java.io.Serializable

    public final class Node

extends java.lang.Object
implements INode, java.io.Serializable

An implementation of INode that can be stored in the internal database or an external relational database.

See Also:
  Serialized Form

Field Summary
`protected boolean` `anonymous`
`protected long` `created`
`protected long` `lastmodified`
`protected NodeHandle` `parentHandle`
`protected short` `version`

Fields inherited from interface helma.objectmodel.INodeState
`CLEAN, DELETED, INVALID, MODIFIED, NEW, TRANSIENT, VIRTUAL`

Constructor Summary
`protected` `Node()` Creates an empty, uninitialized Node.
`protected` `Node(long timestamp)` Creates an empty, uninitialized Node with the given create and modify time.
`` `Node(Node home, java.lang.String propname, WrappedNodeManager nmgr, java.lang.String prototype)` Constructor used for virtual nodes.
`` `Node(java.lang.String name, java.lang.String id, java.lang.String prototype, WrappedNodeManager nmgr)` Creates a new Node with the given name.
`` `Node(java.lang.String name, java.lang.String id, java.lang.String prototype, WrappedNodeManager nmgr, long created, long lastmodified)` Constructor used to create a Node with a given name from a embedded database.
`` `Node(java.lang.String name, java.lang.String prototype, WrappedNodeManager nmgr)` Creates a new Node with the given name.

Method Summary
`INode` `addNode(INode elem)` INode-related
`INode` `addNode(INode elem, int where)` Add a node to this Node's subnodes, making the added node persistent if it hasn't been before and this Node is already persistent.
`void` `clearCacheNode()` Reset the cache node for this node.
`int` `contains(INode n)` Check if the given node is contained in this node's child list.
`long` `created()`
`INode` `createNode()`
`INode` `createNode(int where)`
`INode` `createNode(java.lang.String nm)`
`INode` `createNode(java.lang.String nm, int where)`
`SubnodeList` `createSubnodeList()` Retrieve an empty subnodelist.
`protected void` `deepRemoveNode()` Delete the node from the db.
`void` `dump()`
`IProperty` `get(java.lang.String propname)`
`boolean` `getBoolean(java.lang.String propname)`
`Node` `getCachedParent()` Get parent, using cached info if it exists.
`INode` `getCacheNode()` Get the cache node for this node.
`IPathElement` `getChildElement(java.lang.String name)` This implements the getChildElement() method of the IPathElement interface
`java.util.Date` `getDate(java.lang.String propname)`
`DbMapping` `getDbMapping()`
`java.lang.String` `getElementName()` Get something to identify this node within a URL.
`double` `getFloat(java.lang.String propname)`
`java.lang.String` `getFullName()`
`java.lang.String` `getFullName(INode root)`
`protected Node` `getGroupbySubnode(Node node, boolean create)`
`protected Node` `getGroupbySubnode(java.lang.String sid, boolean create)`
`NodeHandle` `getHandle()`
`java.lang.String` `getID()` Get the ID of this Node.
`long` `getInteger(java.lang.String propname)`
`java.lang.Object` `getJavaObject(java.lang.String propname)`
`Key` `getKey()`
`java.lang.String` `getName()` Return this node' name, which may or may not have some meaning
`INode` `getNode(java.lang.String propname)`
`Node` `getNonVirtualParent()` This method walks down node path to the first non-virtual node and return it.
`INode` `getParent()` Get parent, retrieving it if necessary.
`IPathElement` `getParentElement()` This implements the getParentElement() method of the IPathElement interface
`java.lang.String` `getParentInfo()`
`protected Property` `getProperty(java.lang.String propname)`
`java.util.Hashtable` `getPropMap()`
`java.lang.String` `getPrototype()` Get the name of the prototype to be used for this object.
`int` `getState()` Gets this node's stateas defined in the INode interface
`java.lang.String` `getString(java.lang.String propname)`
`INode` `getSubnode(java.lang.String subid)`
`INode` `getSubnodeAt(int index)`
`SubnodeList` `getSubnodeList()` Return this Node's subnode list
`java.lang.String` `getSubnodeRelation()`
`java.util.Enumeration` `getSubnodes()`
`int` `hashCode()` We overwrite hashCode to make it dependant from the prototype.
`void` `init(DbMapping dbm, java.lang.String id, java.lang.String name, java.lang.String prototype, java.util.Hashtable propMap, WrappedNodeManager nmgr)` Initializer used for nodes being instanced from an embedded or relational database.
`void` `invalidate()` Mark node as invalid so it is re-fetched from the database
`void` `invalidateNode(java.lang.String key)` Check for a child mapping and evict the object specified by key from the cache
`boolean` `isAnonymous()` Returns true if this node is accessed by id from its aprent, false if it is accessed by name
`boolean` `isNullNode()` Instances of this class may be used to mark an entry in the object cache as null.
`boolean` `isParentOf(Node n)` Check if the given node is contained in this node's child list.
`boolean` `isRelational()` Tell whether this node is stored inside a relational db.
`long` `lastModified()`
`void` `loadNodes()` Make sure the subnode index is loaded for subnodes stored in a relational data source.
`void` `markSubnodesChanged()` Called by the transactor on registered parent nodes to mark the child index as changed
`int` `numberOfNodes()` Count the subnodes of this node.
`void` `persist()` Public method to make a node persistent.
`void` `prefetchChildren(int startIndex, int length)`
`void` `prefetchChildren(Key[] keys)`
`java.util.Enumeration` `properties()` Get all properties of this node.
`protected void` `releaseNode(Node node)` "Locally" remove a subnode from the subnodes table.
`boolean` `remove()`
`void` `removeNode(INode node)`
`protected void` `set(java.lang.String propname, java.lang.Object value, int type)` Directly set a property on this node
`void` `setBoolean(java.lang.String propname, boolean value)`
`void` `setDate(java.lang.String propname, java.util.Date value)`
`void` `setDbMapping(DbMapping dbmap)`
`void` `setFloat(java.lang.String propname, double value)`
`void` `setInteger(java.lang.String propname, long value)`
`void` `setJavaObject(java.lang.String propname, java.lang.Object value)`
`void` `setName(java.lang.String name)`
`void` `setNode(java.lang.String propname, INode value)`
`void` `setParent(Node parent)` Set this node's parent node.
`void` `setParentHandle(NodeHandle parent)` Set this node's parent node to the node referred to by the NodeHandle.
`void` `setPropMap(java.util.Hashtable propMap)` used by Xml deserialization
`void` `setPrototype(java.lang.String proto)`
`void` `setState(int s)` Sets this node's state as defined in the INode interface
`void` `setString(java.lang.String propname, java.lang.String value)`
`void` `setSubnodeRelation(java.lang.String rel)`
`void` `setSubnodes(SubnodeList subnodes)` used by Xml deserialization
`void` `setWrappedNodeManager(WrappedNodeManager nmgr)`
`java.lang.String` `toString()` Return a string representation for this node.
`void` `unset(java.lang.String propname)` Remove a property.
`int` `updateSubnodes()` This method get's called from the JavaScript environment (HopObject.updateSubnodes() or HopObject.collection.updateSubnodes())) The subnode-collection will be updated with a selectstatement getting all Nodes having a higher id than the highest id currently contained within this Node's subnoderelation.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait`

Field Detail

### parentHandle

    protected NodeHandle parentHandle

### created

    protected long created

### lastmodified

    protected long lastmodified

### anonymous

    protected boolean anonymous

### version

    protected short version

Constructor Detail

### Node

    protected Node()

  Creates an empty, uninitialized Node. The init() method must be called on the Node before it can do anything useful.

### Node

    protected Node(long timestamp)

  Creates an empty, uninitialized Node with the given create and modify time. This is used for null-node references in the node cache.

  Parameters:
    `timestamp` -

### Node

    public Node(java.lang.String name,
                java.lang.String id,
                java.lang.String prototype,
                WrappedNodeManager nmgr)

  Creates a new Node with the given name. Used by NodeManager for creating "root nodes" outside of a Transaction context, which is why we can immediately mark it as CLEAN. Also used by embedded database to re-create an existing Node.

### Node

    public Node(java.lang.String name,
                java.lang.String id,
                java.lang.String prototype,
                WrappedNodeManager nmgr,
                long created,
                long lastmodified)

  Constructor used to create a Node with a given name from a embedded database.

### Node

    public Node(Node home,
                java.lang.String propname,
                WrappedNodeManager nmgr,
                java.lang.String prototype)

  Constructor used for virtual nodes.

### Node

    public Node(java.lang.String name,
                java.lang.String prototype,
                WrappedNodeManager nmgr)

  Creates a new Node with the given name. This is used for ordinary transient nodes.

Method Detail

### init

    public void init(DbMapping dbm,
                     java.lang.String id,
                     java.lang.String name,
                     java.lang.String prototype,
                     java.util.Hashtable propMap,
                     WrappedNodeManager nmgr)

  Initializer used for nodes being instanced from an embedded or relational database.

### setPropMap

    public void setPropMap(java.util.Hashtable propMap)

  used by Xml deserialization

### setSubnodes

    public void setSubnodes(SubnodeList subnodes)

  used by Xml deserialization

### markSubnodesChanged

    public void markSubnodesChanged()

  Called by the transactor on registered parent nodes to mark the child index as changed

### getState

    public int getState()

  Gets this node's stateas defined in the INode interface

  Specified by:
    `getState` in interface `INode`
  Returns:
    this node's state

### setState

    public void setState(int s)

  Sets this node's state as defined in the INode interface

  Specified by:
    `setState` in interface `INode`
  Parameters:
    `s` - this node's new state

### invalidate

    public void invalidate()

  Mark node as invalid so it is re-fetched from the database

### invalidateNode

    public void invalidateNode(java.lang.String key)

  Check for a child mapping and evict the object specified by key from the cache

### getID

    public java.lang.String getID()

  Get the ID of this Node. This is the primary database key and used as part of the key for the internal node cache.

  Specified by:
    `getID` in interface `INode`

### isAnonymous

    public boolean isAnonymous()

  Returns true if this node is accessed by id from its aprent, false if it is accessed by name

  Specified by:
    `isAnonymous` in interface `INode`
  Returns:
    ...

### getName

    public java.lang.String getName()

  Return this node' name, which may or may not have some meaning

  Specified by:
    `getName` in interface `INode`
  Returns:
    ...

### getElementName

    public java.lang.String getElementName()

  Get something to identify this node within a URL. This is the ID for anonymous nodes and a property value for named properties.

  Specified by:
    `getElementName` in interface `IPathElement`

### getFullName

    public java.lang.String getFullName()

  Specified by:
    `getFullName` in interface `INode`
  Returns:
    ...

### getFullName

    public java.lang.String getFullName(INode root)

  Specified by:
    `getFullName` in interface `INode`
  Parameters:
    `root` - ...
  Returns:
    ...

### getPrototype

    public java.lang.String getPrototype()

  Description copied from interface: `IPathElement`
  Get the name of the prototype to be used for this object. This will determine which scripts, actions and skins can be called on it within the Helma scripting and rendering framework.

  Specified by:
    `getPrototype` in interface `IPathElement`
  Specified by:
    `getPrototype` in interface `INode`
  Returns:
    ...

### setPrototype

    public void setPrototype(java.lang.String proto)

  Specified by:
    `setPrototype` in interface `INode`
  Parameters:
    `proto` - ...

### setDbMapping

    public void setDbMapping(DbMapping dbmap)

  Specified by:
    `setDbMapping` in interface `INode`
  Parameters:
    `dbmap` - ...

### getDbMapping

    public DbMapping getDbMapping()

  Specified by:
    `getDbMapping` in interface `INode`
  Returns:
    ...

### setWrappedNodeManager

    public void setWrappedNodeManager(WrappedNodeManager nmgr)

  Parameters:
    `nmgr` -

### getKey

    public Key getKey()

  Returns:
    ...

### getHandle

    public NodeHandle getHandle()

  Returns:
    ...

### setSubnodeRelation

    public void setSubnodeRelation(java.lang.String rel)

  Specified by:
    `setSubnodeRelation` in interface `INode`
  Parameters:
    `rel` - ...

### getSubnodeRelation

    public java.lang.String getSubnodeRelation()

  Specified by:
    `getSubnodeRelation` in interface `INode`
  Returns:
    ...

### setName

    public void setName(java.lang.String name)

  Specified by:
    `setName` in interface `INode`
  Parameters:
    `name` - ...

### setParent

    public void setParent(Node parent)

  Set this node's parent node.

### setParentHandle

    public void setParentHandle(NodeHandle parent)

  Set this node's parent node to the node referred to by the NodeHandle.

### getParent

    public INode getParent()

  Get parent, retrieving it if necessary.

  Specified by:
    `getParent` in interface `INode`

### getCachedParent

    public Node getCachedParent()

  Get parent, using cached info if it exists.

### addNode

    public INode addNode(INode elem)

  INode-related

  Specified by:
    `addNode` in interface `INode`
  Parameters:
    `elem` - ...
  Returns:
    ...

### addNode

    public INode addNode(INode elem,
                         int where)

  Add a node to this Node's subnodes, making the added node persistent if it hasn't been before and this Node is already persistent.

  Specified by:
    `addNode` in interface `INode`
  Parameters:
    `elem` - the node to add to this Nodes subnode-list
    `where` - the index-position where this node has to be added
  Returns:
    the added node itselve

### createNode

    public INode createNode()

  Returns:
    ...

### createNode

    public INode createNode(int where)

  Parameters:
    `where` - ...
  Returns:
    ...

### createNode

    public INode createNode(java.lang.String nm)

  Specified by:
    `createNode` in interface `INode`
  Parameters:
    `nm` - ...
  Returns:
    ...

### createNode

    public INode createNode(java.lang.String nm,
                            int where)

  Specified by:
    `createNode` in interface `INode`
  Parameters:
    `nm` - ...
    `where` - ...
  Returns:
    ...

### getChildElement

    public IPathElement getChildElement(java.lang.String name)

  This implements the getChildElement() method of the IPathElement interface

  Specified by:
    `getChildElement` in interface `IPathElement`

### getParentElement

    public IPathElement getParentElement()

  This implements the getParentElement() method of the IPathElement interface

  Specified by:
    `getParentElement` in interface `IPathElement`

### getSubnode

    public INode getSubnode(java.lang.String subid)

  Specified by:
    `getSubnode` in interface `INode`
  Parameters:
    `subid` - ...
  Returns:
    ...

### getSubnodeAt

    public INode getSubnodeAt(int index)

  Specified by:
    `getSubnodeAt` in interface `INode`
  Parameters:
    `index` - ...
  Returns:
    ...

### getGroupbySubnode

    protected Node getGroupbySubnode(Node node,
                                     boolean create)

### getGroupbySubnode

    protected Node getGroupbySubnode(java.lang.String sid,
                                     boolean create)

  Parameters:
    `sid` - ...
    `create` - ...
  Returns:
    ...

### remove

    public boolean remove()

  Specified by:
    `remove` in interface `INode`
  Returns:
    ...

### removeNode

    public void removeNode(INode node)

  Specified by:
    `removeNode` in interface `INode`
  Parameters:
    `node` - ...

### releaseNode

    protected void releaseNode(Node node)

  "Locally" remove a subnode from the subnodes table. The logical stuff necessary for keeping data consistent is done in `removeNode(INode)`.

### deepRemoveNode

    protected void deepRemoveNode()

  Delete the node from the db. This mainly tries to notify all nodes referring to this that it's going away. For nodes from the embedded db it also does a cascading delete, since it can tell which nodes are actual children and which are just linked in.

### contains

    public int contains(INode n)

  Check if the given node is contained in this node's child list. If it is contained return its index in the list, otherwise return -1.

  Specified by:
    `contains` in interface `INode`
  Parameters:
    `n` - a node
  Returns:
    the node's index position in the child list, or -1

### isParentOf

    public boolean isParentOf(Node n)

  Check if the given node is contained in this node's child list. This is similar to `contains(INode)` but does not load the child index for relational nodes.

  Parameters:
    `n` - a node
  Returns:
    true if the given node is contained in this node's child list

### numberOfNodes

    public int numberOfNodes()

  Count the subnodes of this node. If they're stored in a relational data source, we may actually load their IDs in order to do this.

  Specified by:
    `numberOfNodes` in interface `INode`
  Returns:
    ...

### loadNodes

    public void loadNodes()

  Make sure the subnode index is loaded for subnodes stored in a relational data source. Depending on the subnode.loadmode specified in the type.properties, we'll load just the ID index or the actual nodes.

### createSubnodeList

    public SubnodeList createSubnodeList()

  Retrieve an empty subnodelist. This empty List is an instance of the Class used for this Nodes subnode-list

  Returns:
    List an empty List of the type used by this Node

### prefetchChildren

    public void prefetchChildren(int startIndex,
                                 int length)
                          throws java.lang.Exception

  Parameters:
    `startIndex` - ...
    `length` - ...
  Throws:
    `java.lang.Exception` - ...

### prefetchChildren

    public void prefetchChildren(Key[] keys)
                          throws java.lang.Exception

  Throws:
    `java.lang.Exception`

### getSubnodes

    public java.util.Enumeration getSubnodes()

  Specified by:
    `getSubnodes` in interface `INode`
  Returns:
    ...

### getSubnodeList

    public SubnodeList getSubnodeList()

  Return this Node's subnode list

  Returns:
    the subnode list

### properties

    public java.util.Enumeration properties()

  Get all properties of this node.

  Specified by:
    `properties` in interface `INode`

### getPropMap

    public java.util.Hashtable getPropMap()

  Returns:
    ...

### get

    public IProperty get(java.lang.String propname)

  Specified by:
    `get` in interface `INode`
  Parameters:
    `propname` - ...
  Returns:
    ...

### getParentInfo

    public java.lang.String getParentInfo()

  Returns:
    ...

### getProperty

    protected Property getProperty(java.lang.String propname)

  Parameters:
    `propname` - ...
  Returns:
    ...

### getString

    public java.lang.String getString(java.lang.String propname)

  Specified by:
    `getString` in interface `INode`
  Parameters:
    `propname` - ...
  Returns:
    ...

### getInteger

    public long getInteger(java.lang.String propname)

  Specified by:
    `getInteger` in interface `INode`
  Parameters:
    `propname` - ...
  Returns:
    ...

### getFloat

    public double getFloat(java.lang.String propname)

  Specified by:
    `getFloat` in interface `INode`
  Parameters:
    `propname` - ...
  Returns:
    ...

### getDate

    public java.util.Date getDate(java.lang.String propname)

  Specified by:
    `getDate` in interface `INode`
  Parameters:
    `propname` - ...
  Returns:
    ...

### getBoolean

    public boolean getBoolean(java.lang.String propname)

  Specified by:
    `getBoolean` in interface `INode`
  Parameters:
    `propname` - ...
  Returns:
    ...

### getNode

    public INode getNode(java.lang.String propname)

  Specified by:
    `getNode` in interface `INode`
  Parameters:
    `propname` - ...
  Returns:
    ...

### getJavaObject

    public java.lang.Object getJavaObject(java.lang.String propname)

  Specified by:
    `getJavaObject` in interface `INode`
  Parameters:
    `propname` - ...
  Returns:
    ...

### set

    protected void set(java.lang.String propname,
                       java.lang.Object value,
                       int type)

  Directly set a property on this node

  Parameters:
    `propname` - ...
    `value` - ...

### setString

    public void setString(java.lang.String propname,
                          java.lang.String value)

  Specified by:
    `setString` in interface `INode`
  Parameters:
    `propname` - ...
    `value` - ...

### setInteger

    public void setInteger(java.lang.String propname,
                           long value)

  Specified by:
    `setInteger` in interface `INode`
  Parameters:
    `propname` - ...
    `value` - ...

### setFloat

    public void setFloat(java.lang.String propname,
                         double value)

  Specified by:
    `setFloat` in interface `INode`
  Parameters:
    `propname` - ...
    `value` - ...

### setBoolean

    public void setBoolean(java.lang.String propname,
                           boolean value)

  Specified by:
    `setBoolean` in interface `INode`
  Parameters:
    `propname` - ...
    `value` - ...

### setDate

    public void setDate(java.lang.String propname,
                        java.util.Date value)

  Specified by:
    `setDate` in interface `INode`
  Parameters:
    `propname` - ...
    `value` - ...

### setJavaObject

    public void setJavaObject(java.lang.String propname,
                              java.lang.Object value)

  Specified by:
    `setJavaObject` in interface `INode`
  Parameters:
    `propname` - ...
    `value` - ...

### setNode

    public void setNode(java.lang.String propname,
                        INode value)

  Specified by:
    `setNode` in interface `INode`
  Parameters:
    `propname` - ...
    `value` - ...

### unset

    public void unset(java.lang.String propname)

  Remove a property. Note that this works only for explicitly set properties, not for those specified via property relation.

  Specified by:
    `unset` in interface `INode`
  Parameters:
    `propname` - ...

### lastModified

    public long lastModified()

  Specified by:
    `lastModified` in interface `INode`
  Returns:
    ...

### created

    public long created()

  Specified by:
    `created` in interface `INode`
  Returns:
    ...

### toString

    public java.lang.String toString()

  Return a string representation for this node. This tries to call the javascript implemented toString() if it is defined.

  Overrides:
    `toString` in class `java.lang.Object`
  Returns:
    a string representing this node.

### isRelational

    public boolean isRelational()

  Tell whether this node is stored inside a relational db. This doesn't mean it actually is stored in a relational db, just that it would be, if the node was persistent

### persist

    public void persist()

  Public method to make a node persistent.

### getCacheNode

    public INode getCacheNode()

  Get the cache node for this node. This can be used to store transient cache data per node from Javascript.

  Specified by:
    `getCacheNode` in interface `INode`
  Returns:
    ...

### clearCacheNode

    public void clearCacheNode()

  Reset the cache node for this node.

  Specified by:
    `clearCacheNode` in interface `INode`

### getNonVirtualParent

    public Node getNonVirtualParent()

  This method walks down node path to the first non-virtual node and return it. limit max depth to 5, since there shouldn't be more then 2 layers of virtual nodes.

### isNullNode

    public boolean isNullNode()

  Instances of this class may be used to mark an entry in the object cache as null. This method tells the caller whether this is the case.

### hashCode

    public int hashCode()

  We overwrite hashCode to make it dependant from the prototype. That way, when the prototype changes, the node will automatically get a new ESNode wrapper, since they're cached in a hashtable. You gotta love these hash code tricks ;-)

  Overrides:
    `hashCode` in class `java.lang.Object`

### dump

    public void dump()

### updateSubnodes

    public int updateSubnodes()

  This method get's called from the JavaScript environment (HopObject.updateSubnodes() or HopObject.collection.updateSubnodes())) The subnode-collection will be updated with a selectstatement getting all Nodes having a higher id than the highest id currently contained within this Node's subnoderelation. If this subnodelist has a special order all nodes will be loaded honoring this order. Example: order by somefield1 asc, somefieled2 desc gives a where-clausel like the following: (somefiled1 > theHighestKnownValue value and somefield2 < theLowestKnownValue)

  Returns:
    the number of loaded nodes within this collection update

Copyright © 1998-1998-${year} Helma.org. All Rights Reserved.