Package helma.objectmodel.db
Class Node
java.lang.Object
helma.objectmodel.db.Node
- All Implemented Interfaces:
IPathElement
,INode
,INodeState
An implementation of INode that can be stored in the internal database or
an external relational database.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
protected long
protected long
protected NodeHandle
protected short
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Node
(long timestamp) Creates an empty, uninitialized Node with the given create and modify time.Node
(Node home, String propname, WrappedNodeManager nmgr, String prototype) Constructor used for virtual nodes.protected
Node
(WrappedNodeManager nmgr) Creates an empty, uninitialized Node.Node
(String name, String prototype, WrappedNodeManager nmgr) Creates a new Node with the given name.Node
(String name, String id, String prototype, WrappedNodeManager nmgr) Creates a new Node with the given name.Node
(String name, String id, String prototype, WrappedNodeManager nmgr, long created, long lastmodified) Constructor used to create a Node with a given name from a embedded database. -
Method Summary
Modifier and TypeMethodDescriptionINode-relatedAdd 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
Reset the cache node for this node.int
Check if the given node is contained in this node's child list.long
created()
Get the node's creation timestamp.createNode
(int where) createNode
(String nm) Create a new named property with a node valuecreateNode
(String nm, int where) Create a new unnamed child node at the given position.Create an empty subnode list.protected void
Delete the node from the db.void
dump()
Get a property with the given name.boolean
getBoolean
(String propname) Get a boolean property with the given name.Get parent, using cached info if it exists.Get the cache node for this node.getChildElement
(String name) This implements the getChildElement() method of the IPathElement interfaceGet a date property with the given name.Get the node'sDbMapping
.Get something to identify this node within a URL.double
Get a float property with the given name.protected Node
getGroupbySubnode
(Node node, boolean create) Get or create a group name for a given content node.protected Node
getGroupbySubnode
(String groupname, boolean create) Get or create a group name for a given group name.Get the node's handle.getID()
Get the ID of this Node.long
getInteger
(String propname) Get an integer property with the given name.getJavaObject
(String propname) Get a Java object property with the given name.getKey()
Get the node's key.getName()
Return this node' name, which may or may not have some meaningGet a node property with the given name.This method walks down node path to the first non-virtual node and return it.Get parent, retrieving it if necessary.This implements the getParentElement() method of the IPathElement interfacegetPath()
Get the node's pathprotected Property
getProperty
(String propname) Return the node's prototype name.int
getState()
Gets this node's stateas defined in the INode interfaceGet a string property with the given name.getSubnode
(String subid) Get a named child node with the given id.getSubnodeAt
(int index) Get a node at a given position.Return this Node's subnode listGet the node's explicit subnode select clause if one was set, or nullEnumerate through the subnodes of this node.int
hashCode()
We overwrite hashCode to make it dependant from the prototype.void
Initializer used for nodes being instanced from an embedded or relational database.void
Mark node as invalid so it is re-fetched from the databasevoid
invalidateNode
(String key) Check for a child mapping and evict the object specified by key from the cacheboolean
Returns true if this node is accessed by id from its aprent, false if it is accessed by nameboolean
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
Tell whether this node is stored inside a relational db.long
Get the node's last modification timestamp.void
Make sure the subnode index is loaded for subnodes stored in a relational data source.void
Called by the transactor on registered parent nodes to mark the child index as changedint
Count the subnodes of this node.void
persist()
Public method to make a node persistent.void
prefetchChildren
(int startIndex, int length) Get all properties of this node.protected void
releaseNode
(Node node) "Locally" remove a subnode from the subnodes table.boolean
remove()
Remove this node from the database.void
removeNode
(INode node) Remove the given node from this node's child nodes.protected void
Directly set a property on this nodevoid
setBoolean
(String propname, boolean value) Set the property with the given name to the given boolean value.void
Set the property with the given name to the given date value.void
setDbMapping
(DbMapping dbmap) Set the node'sDbMapping
.void
Set the property with the given name to the given float value.void
setInteger
(String propname, long value) Set the property with the given name to the given integer value.void
setJavaObject
(String propname, Object value) Set the property with the given name to the given Java object value.void
Set the node's name.void
Set the property with the given name to the given node value.void
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
(Hashtable propMap) used by Xml deserializationvoid
setPrototype
(String proto) Set the node's prototype name.void
setState
(int s) Sets this node's state as defined in the INode interfacevoid
Set the property with the given name to the given string value.void
setSubnodeRelation
(String rel) Set an explicit select clause for the node's subnodestoString()
Return a string representation for this node.void
Remove a property.
-
Field Details
-
parentHandle
-
created
protected long created -
lastmodified
protected long lastmodified -
anonymous
protected boolean anonymous -
version
protected short version
-
-
Constructor Details
-
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
Creates an empty, uninitialized Node. The init() method must be called on the Node before it can do anything useful. -
Node
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(String name, String id, String prototype, WrappedNodeManager nmgr, long created, long lastmodified) Constructor used to create a Node with a given name from a embedded database. -
Node
Constructor used for virtual nodes. -
Node
Creates a new Node with the given name. This is used for ordinary transient nodes.
-
-
Method Details
-
init
Initializer used for nodes being instanced from an embedded or relational database. -
setPropMap
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 -
setState
public void setState(int s) Sets this node's state as defined in the INode interface -
invalidate
public void invalidate()Mark node as invalid so it is re-fetched from the database -
invalidateNode
Check for a child mapping and evict the object specified by key from the cache -
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. -
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 interfaceINode
-
getName
Return this node' name, which may or may not have some meaning -
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 interfaceIPathElement
-
getPath
Get the node's path -
getPrototype
Return the node's prototype name.- Specified by:
getPrototype
in interfaceINode
- Specified by:
getPrototype
in interfaceIPathElement
-
setPrototype
Set the node's prototype name.- Specified by:
setPrototype
in interfaceINode
-
setDbMapping
Set the node'sDbMapping
.- Specified by:
setDbMapping
in interfaceINode
-
getDbMapping
Get the node'sDbMapping
.- Specified by:
getDbMapping
in interfaceINode
-
getKey
Get the node's key. -
getHandle
Get the node's handle. -
setSubnodeRelation
Set an explicit select clause for the node's subnodes- Specified by:
setSubnodeRelation
in interfaceINode
-
getSubnodeRelation
Get the node's explicit subnode select clause if one was set, or null- Specified by:
getSubnodeRelation
in interfaceINode
-
setName
Set the node's name. -
setParent
Set this node's parent node. -
setParentHandle
Set this node's parent node to the node referred to by the NodeHandle. -
getParent
Get parent, retrieving it if necessary. -
getCachedParent
Get parent, using cached info if it exists. -
addNode
INode-related -
addNode
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. -
createNode
- Returns:
- ...
-
createNode
- Parameters:
where
- ...- Returns:
- ...
-
createNode
Description copied from interface:INode
Create a new named property with a node value- Specified by:
createNode
in interfaceINode
- Parameters:
nm
- ...- Returns:
- ...
-
createNode
Description copied from interface:INode
Create a new unnamed child node at the given position.- Specified by:
createNode
in interfaceINode
- Parameters:
nm
- ...where
- ...- Returns:
- ...
-
getChildElement
This implements the getChildElement() method of the IPathElement interface- Specified by:
getChildElement
in interfaceIPathElement
-
getParentElement
This implements the getParentElement() method of the IPathElement interface- Specified by:
getParentElement
in interfaceIPathElement
-
getSubnode
Get a named child node with the given id.- Specified by:
getSubnode
in interfaceINode
-
getSubnodeAt
Get a node at a given position. This causes the subnode list to be loaded in case it isn't up to date.- Specified by:
getSubnodeAt
in interfaceINode
- Parameters:
index
- the subnode index- Returns:
- the node at the given index
-
getGroupbySubnode
Get or create a group name for a given content node.- Parameters:
node
- the content nodecreate
- whether the node should be created if it doesn't exist- Returns:
- the group node, or null
-
getGroupbySubnode
Get or create a group name for a given group name.- Parameters:
groupname
- the group namecreate
- whether the node should be created if it doesn't exist- Returns:
- the group node, or null
-
remove
public boolean remove()Description copied from interface:INode
Remove this node from the database. -
removeNode
Description copied from interface:INode
Remove the given node from this node's child nodes.- Specified by:
removeNode
in interfaceINode
- Parameters:
node
- ...
-
releaseNode
"Locally" remove a subnode from the subnodes table. The logical stuff necessary for keeping data consistent is done inremoveNode(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
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. -
isParentOf
Check if the given node is contained in this node's child list. This is similar tocontains(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 interfaceINode
-
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
Create an empty subnode list.- Returns:
- List an empty List of the type used by this Node
-
prefetchChildren
public void prefetchChildren(int startIndex, int length) - Parameters:
startIndex
- ...length
- ...- Throws:
Exception
- ...
-
getSubnodes
Enumerate through the subnodes of this node.- Specified by:
getSubnodes
in interfaceINode
- Returns:
- an enumeration of this node's subnodes
-
getSubnodeList
Return this Node's subnode list- Returns:
- the subnode list
-
properties
Get all properties of this node.- Specified by:
properties
in interfaceINode
-
getPropMap
- Returns:
- ...
-
get
Description copied from interface:INode
Get a property with the given name. -
getParentInfo
- Returns:
- ...
-
getProperty
- Parameters:
propname
- ...- Returns:
- ...
-
getString
Description copied from interface:INode
Get a string property with the given name. -
getInteger
Description copied from interface:INode
Get an integer property with the given name.- Specified by:
getInteger
in interfaceINode
- Parameters:
propname
- ...- Returns:
- ...
-
getFloat
Description copied from interface:INode
Get a float property with the given name. -
getDate
Description copied from interface:INode
Get a date property with the given name. -
getBoolean
Description copied from interface:INode
Get a boolean property with the given name.- Specified by:
getBoolean
in interfaceINode
- Parameters:
propname
- ...- Returns:
- ...
-
getNode
Description copied from interface:INode
Get a node property with the given name. -
getJavaObject
Description copied from interface:INode
Get a Java object property with the given name.- Specified by:
getJavaObject
in interfaceINode
- Parameters:
propname
- ...- Returns:
- ...
-
set
Directly set a property on this node- Parameters:
propname
- ...value
- ...
-
setString
Description copied from interface:INode
Set the property with the given name to the given string value. -
setInteger
Description copied from interface:INode
Set the property with the given name to the given integer value.- Specified by:
setInteger
in interfaceINode
- Parameters:
propname
- ...value
- ...
-
setFloat
Description copied from interface:INode
Set the property with the given name to the given float value. -
setBoolean
Description copied from interface:INode
Set the property with the given name to the given boolean value.- Specified by:
setBoolean
in interfaceINode
- Parameters:
propname
- ...value
- ...
-
setDate
Description copied from interface:INode
Set the property with the given name to the given date value. -
setJavaObject
Description copied from interface:INode
Set the property with the given name to the given Java object value.- Specified by:
setJavaObject
in interfaceINode
- Parameters:
propname
- ...value
- ...
-
setNode
Description copied from interface:INode
Set the property with the given name to the given node value. -
unset
Remove a property. Note that this works only for explicitly set properties, not for those specified via property relation. -
lastModified
public long lastModified()Description copied from interface:INode
Get the node's last modification timestamp.- Specified by:
lastModified
in interfaceINode
- Returns:
- ...
-
created
public long created()Description copied from interface:INode
Get the node's creation timestamp. -
toString
Return a string representation for this node. This tries to call the javascript implemented toString() if it is defined. -
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
Get the cache node for this node. This can be used to store transient cache data per node from Javascript.- Specified by:
getCacheNode
in interfaceINode
-
clearCacheNode
public void clearCacheNode()Reset the cache node for this node.- Specified by:
clearCacheNode
in interfaceINode
-
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 ;-) -
dump
public void dump()
-