| java.lang.Object helma.objectmodel.db.Node
Node | final public class Node implements INode,Serializable(Code) | | An implementation of INode that can be stored in the internal database or
an external relational database.
|
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. | public | Node(String name, String id, String prototype, WrappedNodeManager nmgr) Creates a new Node with the given name. | 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. | public | Node(Node home, String propname, WrappedNodeManager nmgr, String prototype) Constructor used for virtual nodes. | public | Node(String name, String prototype, WrappedNodeManager nmgr) Creates a new Node with the given name. |
Method Summary | |
public INode | addNode(INode elem) | 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. | synchronized void | checkWriteLock() Get the write lock on this node, throwing a ConcurrencyException if the
lock is already held by another thread. | public synchronized void | clearCacheNode() Reset the cache node for this node. | synchronized void | clearWriteLock() Clear the write lock on this node. | public int | contains(INode n) Check if the given node is contained in this node's child list. | public INode | createNode() | public INode | createNode(int where) Parameters: where - ... | public INode | createNode(String nm) Parameters: nm - ... | public INode | createNode(String nm, int where) Parameters: nm - ... Parameters: where - ... | public SubnodeList | createSubnodeList() Retrieve an empty subnodelist. | public long | created() | protected void | deepRemoveNode() Delete the node from the db. | public void | dump() | public IProperty | get(String propname) Parameters: propname - ... | public boolean | getBoolean(String propname) Parameters: propname - ... | public synchronized INode | getCacheNode() Get the cache node for this node. | public Node | getCachedParent() Get parent, using cached info if it exists. | public IPathElement | getChildElement(String name) | public Date | getDate(String propname) Parameters: propname - ... | public DbMapping | getDbMapping() | public String | getElementName() Get something to identify this node within a URL. | public double | getFloat(String propname) Parameters: propname - ... | public String | getFullName() | public String | getFullName(INode root) Parameters: root - ... | protected Node | getGroupbySubnode(String sid, boolean create) Parameters: sid - ... Parameters: create - ... | public NodeHandle | getHandle() | public String | getID() Get the ID of this Node. | public long | getInteger(String propname) Parameters: propname - ... | public Object | getJavaObject(String propname) Parameters: propname - ... | public Key | getKey() | long | getLastSubnodeChange(Relation subRel) | public String | getName() | public INode | getNode(String propname) Parameters: propname - ... | public Node | getNonVirtualParent() This method walks down node path to the first non-virtual node and return it. | public INode | getParent() Get parent, retrieving it if necessary. | public IPathElement | getParentElement() | public String | getParentInfo() | public Hashtable | getPropMap() | protected Property | getProperty(String propname) Parameters: propname - ... | public String | getPrototype() | public int | getState() | public String | getString(String propname) Parameters: propname - ... | public INode | getSubnode(String subid) Parameters: subid - ... | public INode | getSubnodeAt(int index) Parameters: index - ... | public SubnodeList | getSubnodeList() | public synchronized String | getSubnodeRelation() | public Enumeration | getSubnodes() | public int | hashCode() We overwrite hashCode to make it dependant from the prototype. | public synchronized void | init(DbMapping dbm, String id, String name, String prototype, Hashtable propMap, WrappedNodeManager nmgr) Initializer used for nodes being instanced from an embedded or relational database. | public void | invalidate() | public void | invalidateNode(String key) | public boolean | isAnonymous() | public boolean | isNullNode() Instances of this class may be used to mark an entry in the object cache as null. | public boolean | isParentOf(Node n) Check if the given node is contained in this node's child list. | public boolean | isRelational() Tell whether this node is stored inside a relational db. | public long | lastModified() | public void | loadNodes() Make sure the subnode index is loaded for subnodes stored in a relational data source. | void | markAs(int s) Set this node's state, registering it with the transactor if necessary. | public void | markSubnodesChanged() | void | notifyPropertyChange(String propname) Notify the node's parent that its child collection needs to be reloaded
in case the changed property has an affect on collection order or content. | public int | numberOfNodes() Count the subnodes of this node. | public void | persist() Public method to make a node persistent. | public void | prefetchChildren(int startIndex, int length) | public void | prefetchChildren(Key[] keys) | public Enumeration | properties() Get all properties of this node. | void | registerSubnodeChange() Register this node as parent node with the transactor so that
setLastSubnodeChange is called when the transaction completes. | protected void | releaseNode(Node node) "Locally" remove a subnode from the subnodes table. | public boolean | remove() | public void | removeNode(INode node) | protected void | set(String propname, Object value, int type) | public void | setBoolean(String propname, boolean value) | public void | setDate(String propname, Date value) | public void | setDbMapping(DbMapping dbmap) | public void | setFloat(String propname, double value) | public void | setInteger(String propname, long value) | public void | setJavaObject(String propname, Object value) | public void | setName(String name) | public void | setNode(String propname, INode value) | public void | setParent(Node parent) Set this node's parent node. | public void | setParentHandle(NodeHandle parent) Set this node's parent node to the node referred to by the NodeHandle. | public synchronized void | setPropMap(Hashtable propMap) | public void | setPrototype(String proto) | public void | setState(int s) | public void | setString(String propname, String value) | public synchronized void | setSubnodeRelation(String rel) | public synchronized void | setSubnodes(SubnodeList subnodes) | public void | setWrappedNodeManager(WrappedNodeManager nmgr) | public String | toString() Return a string representation for this node. | public void | unset(String propname) Remove a property. | 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. |
anonymous | protected boolean anonymous(Code) | | |
created | protected long created(Code) | | |
lastNameCheck | transient long lastNameCheck(Code) | | |
lastParentSet | transient long lastParentSet(Code) | | |
lastSubnodeChange | transient long lastSubnodeChange(Code) | | |
lastSubnodeCount | transient long lastSubnodeCount(Code) | | |
lastSubnodeFetch | transient long lastSubnodeFetch(Code) | | |
lastmodified | protected long lastmodified(Code) | | |
serialVersionUID | final static long serialVersionUID(Code) | | |
subnodeCount | transient int subnodeCount(Code) | | |
version | protected short version(Code) | | |
Node | protected Node()(Code) | | 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)(Code) | | 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(String name, String id, String prototype, WrappedNodeManager nmgr)(Code) | | 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.
|
addNode | public INode addNode(INode elem, int where)(Code) | | 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.
Parameters: elem - the node to add to this Nodes subnode-list Parameters: where - the index-position where this node has to be added the added node itselve |
checkWriteLock | synchronized void checkWriteLock()(Code) | | Get the write lock on this node, throwing a ConcurrencyException if the
lock is already held by another thread.
|
clearCacheNode | public synchronized void clearCacheNode()(Code) | | Reset the cache node for this node.
|
clearWriteLock | synchronized void clearWriteLock()(Code) | | Clear the write lock on this node.
|
contains | public int contains(INode n)(Code) | | 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.
Parameters: n - a node the node's index position in the child list, or -1 |
createNode | public INode createNode(int where)(Code) | | Parameters: where - ... ... |
createNode | public INode createNode(String nm, int where)(Code) | | Parameters: nm - ... Parameters: where - ... ... |
createSubnodeList | public SubnodeList createSubnodeList()(Code) | | Retrieve an empty subnodelist. This empty List is an instance of the Class
used for this Nodes subnode-list
List an empty List of the type used by this Node |
created | public long created()(Code) | | ... |
deepRemoveNode | protected void deepRemoveNode()(Code) | | 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.
|
getBoolean | public boolean getBoolean(String propname)(Code) | | Parameters: propname - ... ... |
getCacheNode | public synchronized INode getCacheNode()(Code) | | Get the cache node for this node. This can be
used to store transient cache data per node from Javascript.
|
getCachedParent | public Node getCachedParent()(Code) | | Get parent, using cached info if it exists.
|
getChildElement | public IPathElement getChildElement(String name)(Code) | | This implements the getChildElement() method of the IPathElement interface
|
getElementName | public String getElementName()(Code) | | Get something to identify this node within a URL. This is the ID for anonymous nodes
and a property value for named properties.
|
getFloat | public double getFloat(String propname)(Code) | | Parameters: propname - ... ... |
getGroupbySubnode | protected Node getGroupbySubnode(String sid, boolean create)(Code) | | Parameters: sid - ... Parameters: create - ... ... |
getID | public String getID()(Code) | | Get the ID of this Node. This is the primary database key and used as part of the
key for the internal node cache.
|
getInteger | public long getInteger(String propname)(Code) | | Parameters: propname - ... ... |
getJavaObject | public Object getJavaObject(String propname)(Code) | | Parameters: propname - ... ... |
getLastSubnodeChange | long getLastSubnodeChange(Relation subRel)(Code) | | Compute a serial number indicating the last change in subnode collection
Parameters: subRel - the subnode relation a serial number that increases with each subnode change |
getName | public String getName()(Code) | | Return this node' name, which may or may not have some meaning
|
getNonVirtualParent | public Node getNonVirtualParent()(Code) | | 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.
|
getParent | public INode getParent()(Code) | | Get parent, retrieving it if necessary.
|
getParentElement | public IPathElement getParentElement()(Code) | | This implements the getParentElement() method of the IPathElement interface
|
getState | public int getState()(Code) | | Gets this node's stateas defined in the INode interface
this node's state |
getSubnodeAt | public INode getSubnodeAt(int index)(Code) | | Parameters: index - ... ... |
getSubnodeList | public SubnodeList getSubnodeList()(Code) | | Return this Node's subnode list
the subnode list |
getSubnodeRelation | public synchronized String getSubnodeRelation()(Code) | | ... |
hashCode | public int hashCode()(Code) | | 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 ;-)
|
invalidate | public void invalidate()(Code) | | Mark node as invalid so it is re-fetched from the database
|
invalidateNode | public void invalidateNode(String key)(Code) | | Check for a child mapping and evict the object specified by key from the cache
|
isAnonymous | public boolean isAnonymous()(Code) | | Returns true if this node is accessed by id from its aprent, false if it
is accessed by name
|
isNullNode | public boolean isNullNode()(Code) | | 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.
|
isParentOf | public boolean isParentOf(Node n)(Code) | | 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 true if the given node is contained in this node's child list |
isRelational | public boolean isRelational()(Code) | | 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
|
lastModified | public long lastModified()(Code) | | ... |
loadNodes | public void loadNodes()(Code) | | 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.
|
markAs | void markAs(int s)(Code) | | Set this node's state, registering it with the transactor if necessary.
|
markSubnodesChanged | public void markSubnodesChanged()(Code) | | Called by the transactor on registered parent nodes to mark the
child index as changed
|
notifyPropertyChange | void notifyPropertyChange(String propname)(Code) | | Notify the node's parent that its child collection needs to be reloaded
in case the changed property has an affect on collection order or content.
Parameters: propname - the name of the property being changed |
numberOfNodes | public int numberOfNodes()(Code) | | 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.
|
persist | public void persist()(Code) | | Public method to make a node persistent.
|
prefetchChildren | public void prefetchChildren(int startIndex, int length) throws Exception(Code) | | Parameters: startIndex - ... Parameters: length - ... throws: Exception - ... |
registerSubnodeChange | void registerSubnodeChange()(Code) | | Register this node as parent node with the transactor so that
setLastSubnodeChange is called when the transaction completes.
|
releaseNode | protected void releaseNode(Node node)(Code) | | "Locally" remove a subnode from the subnodes table.
The logical stuff necessary for keeping data consistent is done in
Node.removeNode(INode) .
|
remove | public boolean remove()(Code) | | ... |
removeNode | public void removeNode(INode node)(Code) | | Parameters: node - ... |
set | protected void set(String propname, Object value, int type)(Code) | | Directly set a property on this node
Parameters: propname - ... Parameters: value - ... |
setBoolean | public void setBoolean(String propname, boolean value)(Code) | | Parameters: propname - ... Parameters: value - ... |
setDate | public void setDate(String propname, Date value)(Code) | | Parameters: propname - ... Parameters: value - ... |
setDbMapping | public void setDbMapping(DbMapping dbmap)(Code) | | Parameters: dbmap - ... |
setFloat | public void setFloat(String propname, double value)(Code) | | Parameters: propname - ... Parameters: value - ... |
setInteger | public void setInteger(String propname, long value)(Code) | | Parameters: propname - ... Parameters: value - ... |
setJavaObject | public void setJavaObject(String propname, Object value)(Code) | | Parameters: propname - ... Parameters: value - ... |
setName | public void setName(String name)(Code) | | Parameters: name - ... |
setNode | public void setNode(String propname, INode value)(Code) | | Parameters: propname - ... Parameters: value - ... |
setParent | public void setParent(Node parent)(Code) | | Set this node's parent node.
|
setParentHandle | public void setParentHandle(NodeHandle parent)(Code) | | Set this node's parent node to the node referred to by the NodeHandle.
|
setPropMap | public synchronized void setPropMap(Hashtable propMap)(Code) | | used by Xml deserialization
|
setPrototype | public void setPrototype(String proto)(Code) | | Parameters: proto - ... |
setState | public void setState(int s)(Code) | | Sets this node's state as defined in the INode interface
Parameters: s - this node's new state |
setString | public void setString(String propname, String value)(Code) | | Parameters: propname - ... Parameters: value - ... |
setSubnodeRelation | public synchronized void setSubnodeRelation(String rel)(Code) | | Parameters: rel - ... |
setSubnodes | public synchronized void setSubnodes(SubnodeList subnodes)(Code) | | used by Xml deserialization
|
toString | public String toString()(Code) | | Return a string representation for this node. This tries to call the
javascript implemented toString() if it is defined.
a string representing this node. |
unset | public void unset(String propname)(Code) | | Remove a property. Note that this works only for explicitly set properties, not for those
specified via property relation.
|
updateSubnodes | public int updateSubnodes()(Code) | | 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)
the number of loaded nodes within this collection update |
|
|