org.mmbase.bridge.implementation
Class BasicNode

java.lang.Object
  |
  +--org.mmbase.bridge.implementation.BasicNode
All Implemented Interfaces:
Node
Direct Known Subclasses:
BasicRelation

public class BasicNode
extends java.lang.Object
implements Node

Author:
Rob Vermeulen, Pierre van Rooden

Field Summary
protected  java.lang.String account
          The account this node is edited under.
static int ACTION_COMMIT
           
static int ACTION_CREATE
           
static int ACTION_DELETE
           
static int ACTION_EDIT
           
static int ACTION_LINK
           
protected  BasicCloud cloud
          Reference to the Cloud.
protected  boolean isnew
          Determines whether this node was created for insert.
protected  MMBase mmb
          Reference to MMBase root.
protected  NodeManager nodeManager
          Reference to the NodeManager
protected  MMObjectNode noderef
          Reference to actual MMObjectNode object.
protected  int temporaryNodeId
          Temporary node ID.
 
Method Summary
 void cancel()
          Cancel changes to a node This fails if the current node is not in edit mode.
 void commit()
          Commit the node to the database.
 int countRelatedNodes(java.lang.String type)
          Returns the number of related nodes that have a specific node manager.
 int countRelations()
          Returns the number of relations this node has with other nodes.
 int countRelations(java.lang.String type)
          Returns the number of relation nodes attached to this node that have a specific relation manager.
 void createAlias(java.lang.String aliasName)
          Create an alias for this node.
 Relation createRelation(Node destinationNode, RelationManager relationManager)
          Adds a relation between this node and a specified node to the cloud.
 void delete()
          Removes the Node.
 void delete(boolean deleteRelations)
          Removes the Node.
 void deleteAlias(java.lang.String aliasName)
          Delete an alias for this node.
 void deleteRelations()
          Removes all relation nodes attached to this node.
 void deleteRelations(java.lang.String type)
          Removes all relation nodes with a certain relation manager that are attached to this node.
protected  void edit(int action)
          Edit this node.
 boolean equals(java.lang.Object o)
          Compares two objects, and returns true if they are equal.
 java.util.List getAliases()
          Returns all aliases for this node.
 boolean getBooleanValue(java.lang.String attribute)
          Returns the value of the specified field as a boolean.
 byte[] getByteValue(java.lang.String attribute)
          Returns the value of the specified field as a byte array.
 Cloud getCloud()
          Returns the cloud this node belongs to.
 java.lang.String getContext()
          get the Context of the current Node
 double getDoubleValue(java.lang.String attribute)
          Returns the value of the specified field as a double.
 float getFloatValue(java.lang.String attribute)
          Returns the value of the specified field as a float.
 int getIntValue(java.lang.String attribute)
          Returns the value of the specified field as an int.
 long getLongValue(java.lang.String attribute)
          Returns the value of the specified field as a long.
protected  MMObjectNode getNode()
           
 NodeManager getNodeManager()
          Returns the node manager for this node.
 Node getNodeValue(java.lang.String attribute)
          Returns the value of the specified field as a Node.
 int getNumber()
          Returns the unique number for this node.
 StringList getPossibleContexts()
          get the Contextes which can be set to this specific node
 NodeList getRelatedNodes()
          Returns all related nodes.
 NodeList getRelatedNodes(java.lang.String type)
          Returns all related nodes that have a specific node manager.
 RelationList getRelations()
          Returns all relation nodes attached to this node.
 RelationList getRelations(java.lang.String type)
          Returns all relation nodes attached to this node that have a specific relation manager.
 java.lang.String getStringValue(java.lang.String attribute)
          Returns the value of the specified field as a String.
 java.lang.Object getValue(java.lang.String attribute)
          Returns the value of the specified field as an object.
 int hashCode()
          Returns the object's hashCode.
 boolean hasRelations()
          Checks whether this node has any relations.
 boolean mayChangeContext()
          Check context-change rights on this node.
 boolean mayDelete()
          Check delete rights on this node.
 boolean mayLink()
          Check link rights on this node.
 boolean mayWrite()
          Check write rights on this node.
 void setBooleanValue(java.lang.String attribute, boolean value)
           
 void setByteValue(java.lang.String attribute, byte[] value)
          Sets the value of the specified field using a byte array.
 void setContext(java.lang.String context)
          set the Context of the current Node
 void setDoubleValue(java.lang.String attribute, double value)
          Sets the value of the specified field using a double.
 void setFloatValue(java.lang.String attribute, float value)
          Sets the value of the specified field using a float.
 void setIntValue(java.lang.String attribute, int value)
          Sets the value of the specified field using an int.
 void setLongValue(java.lang.String attribute, long value)
          Sets the value of the specified field using a long.
 void setStringValue(java.lang.String attribute, java.lang.String value)
          Sets the value of the specified field using a String.
 void setValue(java.lang.String attribute, java.lang.Object value)
          Sets the value of the specified field using an object.
 java.lang.String toString()
          Converts the node to a string
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ACTION_CREATE

public static final int ACTION_CREATE

ACTION_EDIT

public static final int ACTION_EDIT

ACTION_DELETE

public static final int ACTION_DELETE

ACTION_LINK

public static final int ACTION_LINK

ACTION_COMMIT

public static final int ACTION_COMMIT

nodeManager

protected NodeManager nodeManager
Reference to the NodeManager

cloud

protected BasicCloud cloud
Reference to the Cloud.

mmb

protected MMBase mmb
Reference to MMBase root.

noderef

protected MMObjectNode noderef
Reference to actual MMObjectNode object.

temporaryNodeId

protected int temporaryNodeId
Temporary node ID. this is necessary since there is otherwise no sure (and quick) way to determine whether a node is in 'edit' mode (i.e. has a temporary node).

account

protected java.lang.String account
The account this node is edited under. This is needed to check whether people have not switched users during an edit.

isnew

protected boolean isnew
Determines whether this node was created for insert.
Method Detail

getNode

protected MMObjectNode getNode()

getCloud

public Cloud getCloud()
Description copied from interface: Node
Returns the cloud this node belongs to.
Specified by:
getCloud in interface Node

getNodeManager

public NodeManager getNodeManager()
Description copied from interface: Node
Returns the node manager for this node.
Specified by:
getNodeManager in interface Node

getNumber

public int getNumber()
Description copied from interface: Node
Returns the unique number for this node. Every node has a unique number wich can be used to refer to it. In addition to this number a node can have one or more aliases.
Specified by:
getNumber in interface Node
Following copied from interface: org.mmbase.bridge.Node
Returns:
the unique number for this node
See Also:
Node.createAlias(String alias)

edit

protected void edit(int action)
Edit this node. Check whether edits are allowed and prepare a node for edits if needed. The type of edit is determined by the action specified, and one of:
ACTION_CREATE (create a node),
ACTION_EDIT (edit node, or change aliasses),
ACTION_DELETE (delete node),
ACTION_LINK (add a relation),
ACTION_COMMIT (commit a node after changes)
Parameters:
action - The action to perform.

setValue

public void setValue(java.lang.String attribute,
                     java.lang.Object value)
Description copied from interface: Node
Sets the value of the specified field using an object. For example a field of type int can be set using an Integer. This change will not be visible to the cloud until the commit method is called.
Specified by:
setValue in interface Node
Following copied from interface: org.mmbase.bridge.Node
Parameters:
fieldname - the name of the field to be updated
value - the new value for the given field

setBooleanValue

public void setBooleanValue(java.lang.String attribute,
                            boolean value)

setIntValue

public void setIntValue(java.lang.String attribute,
                        int value)
Description copied from interface: Node
Sets the value of the specified field using an int. This change will not be visible to the cloud until the commit method is called.
Specified by:
setIntValue in interface Node
Following copied from interface: org.mmbase.bridge.Node
Parameters:
fieldname - the name of the field to be updated
value - the new value for the given field

setFloatValue

public void setFloatValue(java.lang.String attribute,
                          float value)
Description copied from interface: Node
Sets the value of the specified field using a float. This change will not be visible to the cloud until the commit method is called.
Specified by:
setFloatValue in interface Node
Following copied from interface: org.mmbase.bridge.Node
Parameters:
fieldname - the name of the field to be updated
value - the new value for the given field

setDoubleValue

public void setDoubleValue(java.lang.String attribute,
                           double value)
Description copied from interface: Node
Sets the value of the specified field using a double. This change will not be visible to the cloud until the commit method is called.
Specified by:
setDoubleValue in interface Node
Following copied from interface: org.mmbase.bridge.Node
Parameters:
fieldname - the name of the field to be updated
value - the new value for the given field

setByteValue

public void setByteValue(java.lang.String attribute,
                         byte[] value)
Description copied from interface: Node
Sets the value of the specified field using a byte array. This change will not be visible to the cloud until the commit method is called.
Specified by:
setByteValue in interface Node
Following copied from interface: org.mmbase.bridge.Node
Parameters:
fieldname - the name of the field to be updated
value - the new value for the given field

setLongValue

public void setLongValue(java.lang.String attribute,
                         long value)
Description copied from interface: Node
Sets the value of the specified field using a long. This change will not be visible to the cloud until the commit method is called.
Specified by:
setLongValue in interface Node
Following copied from interface: org.mmbase.bridge.Node
Parameters:
fieldname - the name of the field to be updated
value - the new value for the given field

setStringValue

public void setStringValue(java.lang.String attribute,
                           java.lang.String value)
Description copied from interface: Node
Sets the value of the specified field using a String. This change will not be visible to the cloud until the commit method is called.
Specified by:
setStringValue in interface Node
Following copied from interface: org.mmbase.bridge.Node
Parameters:
fieldname - the name of the field to be updated
value - the new value for the given field

getValue

public java.lang.Object getValue(java.lang.String attribute)
Description copied from interface: Node
Returns the value of the specified field as an object. For example a field of type int is returned as an Integer.
Specified by:
getValue in interface Node
Following copied from interface: org.mmbase.bridge.Node
Parameters:
fieldname - the name of the field to be returned
Returns:
the value of the specified field

getBooleanValue

public boolean getBooleanValue(java.lang.String attribute)
Description copied from interface: Node
Returns the value of the specified field as a boolean.
Specified by:
getBooleanValue in interface Node
Following copied from interface: org.mmbase.bridge.Node
Parameters:
fieldname - the name of the field to be returned
Returns:
the value of the specified field

getNodeValue

public Node getNodeValue(java.lang.String attribute)
Description copied from interface: Node
Returns the value of the specified field as a Node. If the value is not itself a Node, this call attempts to convert the original field value to a Node, by trying to retrieve a Node using the field value as a Node number or alias.
For instance, getNodeValue("destination"), when run on a OAlias object, returns the referenced destination node (instead of teh number, which is what it normally holds).
Mosty, this call is used in cluster nodes (nodes retrived by using the Cloud.getList method. A cluster node returns one of its compound nodes when an appropriate nodemanager name (name from the nodepath) is specified. I.e. getNodeValue("people") will return the people-node in the cluster. If this fails, the method returns null.
Notes: the behavior of getNodeValue when called on a field that is not intended to be a node reference is currently undefined and is not encouraged.
Calling this method with field "number" or null lets the Node return a reference to itself, regardless of the actual value of the number field or status of the Node.
Specified by:
getNodeValue in interface Node
Following copied from interface: org.mmbase.bridge.Node
Parameters:
fieldname - the name of the field to be returned
Returns:
the value of the specified field
See Also:
Cloud.getList(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, boolean)

getIntValue

public int getIntValue(java.lang.String attribute)
Description copied from interface: Node
Returns the value of the specified field as an int.
Specified by:
getIntValue in interface Node
Following copied from interface: org.mmbase.bridge.Node
Parameters:
fieldname - the name of the field to be returned
Returns:
the value of the specified field

getFloatValue

public float getFloatValue(java.lang.String attribute)
Description copied from interface: Node
Returns the value of the specified field as a float.
Specified by:
getFloatValue in interface Node
Following copied from interface: org.mmbase.bridge.Node
Parameters:
fieldname - the name of the field to be returned
Returns:
the value of the specified field

getLongValue

public long getLongValue(java.lang.String attribute)
Description copied from interface: Node
Returns the value of the specified field as a long.
Specified by:
getLongValue in interface Node
Following copied from interface: org.mmbase.bridge.Node
Parameters:
fieldname - the name of the field to be returned
Returns:
the value of the specified field

getDoubleValue

public double getDoubleValue(java.lang.String attribute)
Description copied from interface: Node
Returns the value of the specified field as a double.
Specified by:
getDoubleValue in interface Node
Following copied from interface: org.mmbase.bridge.Node
Parameters:
fieldname - the name of the field to be returned
Returns:
the value of the specified field

getByteValue

public byte[] getByteValue(java.lang.String attribute)
Description copied from interface: Node
Returns the value of the specified field as a byte array.
Specified by:
getByteValue in interface Node
Following copied from interface: org.mmbase.bridge.Node
Parameters:
fieldname - the name of the field to be returned
Returns:
the value of the specified field

getStringValue

public java.lang.String getStringValue(java.lang.String attribute)
Description copied from interface: Node
Returns the value of the specified field as a String.
Specified by:
getStringValue in interface Node
Following copied from interface: org.mmbase.bridge.Node
Parameters:
fieldname - the name of the field to be returned
Returns:
the value of the specified field

commit

public void commit()
Description copied from interface: Node
Commit the node to the database. Makes this node and/or the changes made to this node visible to the cloud. If this method is called for the first time on this node it will make this node visible to the cloud, otherwise the modifications made to this node using the set methods will be made visible to the cloud. This action fails if the current node is not in edit mode. If the node is in a transaction, nothing happens - actual committing occurs through the transaction.
Specified by:
commit in interface Node

cancel

public void cancel()
Description copied from interface: Node
Cancel changes to a node This fails if the current node is not in edit mode. If the node is in a transaction, nothing happens - actual committing occurs through the transaction.
Specified by:
cancel in interface Node

delete

public void delete()
Description copied from interface: Node
Removes the Node. Throws an exception if still has relations. Like delete(false).
Specified by:
delete in interface Node

delete

public void delete(boolean deleteRelations)
Description copied from interface: Node
Removes the Node.
Specified by:
delete in interface Node
Following copied from interface: org.mmbase.bridge.Node
Parameters:
deleteRelations - a boolean. If true, then first all existing relations with this node will be removed.

toString

public java.lang.String toString()
Description copied from interface: Node
Converts the node to a string
Specified by:
toString in interface Node
Overrides:
toString in class java.lang.Object

deleteRelations

public void deleteRelations()
Description copied from interface: Node
Removes all relation nodes attached to this node.
Specified by:
deleteRelations in interface Node

deleteRelations

public void deleteRelations(java.lang.String type)
Description copied from interface: Node
Removes all relation nodes with a certain relation manager that are attached to this node.
Specified by:
deleteRelations in interface Node
Following copied from interface: org.mmbase.bridge.Node
Parameters:
relationManager - the name of the relation manager the removed relation nodes should have

getRelations

public RelationList getRelations()
Description copied from interface: Node
Returns all relation nodes attached to this node.
Specified by:
getRelations in interface Node
Following copied from interface: org.mmbase.bridge.Node
Returns:
a list of relation nodes

getRelations

public RelationList getRelations(java.lang.String type)
Description copied from interface: Node
Returns all relation nodes attached to this node that have a specific relation manager.
Specified by:
getRelations in interface Node
Following copied from interface: org.mmbase.bridge.Node
Parameters:
relationManager - the name of the relation manager the returned relation nodes should have
Returns:
a list of relation nodes

hasRelations

public boolean hasRelations()
Description copied from interface: Node
Checks whether this node has any relations.
Specified by:
hasRelations in interface Node
Following copied from interface: org.mmbase.bridge.Node
Returns:
true if the node has relations

countRelations

public int countRelations()
Description copied from interface: Node
Returns the number of relations this node has with other nodes.
Specified by:
countRelations in interface Node
Following copied from interface: org.mmbase.bridge.Node
Returns:
the number of relations this node has with other nodes

countRelations

public int countRelations(java.lang.String type)
Description copied from interface: Node
Returns the number of relation nodes attached to this node that have a specific relation manager.
Specified by:
countRelations in interface Node
Following copied from interface: org.mmbase.bridge.Node
Returns:
the number of relation nodes attached to this node that have a specific relation manager

getRelatedNodes

public NodeList getRelatedNodes()
Description copied from interface: Node
Returns all related nodes. The returned nodes are not the nodes directly attached to this node (the relation nodes) but the nodes attached to the relation nodes of this node.
Specified by:
getRelatedNodes in interface Node
Following copied from interface: org.mmbase.bridge.Node
Returns:
a list of all related nodes

getRelatedNodes

public NodeList getRelatedNodes(java.lang.String type)
Description copied from interface: Node
Returns all related nodes that have a specific node manager. The returned nodes are not the nodes directly attached to this node (the relation nodes) but the nodes attached to the relation nodes of this node.
Specified by:
getRelatedNodes in interface Node
Following copied from interface: org.mmbase.bridge.Node
Parameters:
nodeManager - the name of the node manager the returned nodes should have
Returns:
a list of related nodes

countRelatedNodes

public int countRelatedNodes(java.lang.String type)
Description copied from interface: Node
Returns the number of related nodes that have a specific node manager. The counted nodes are not the nodes directly attached to this node (the relation nodes) but the nodes attached to the relation nodes of this node.
Specified by:
countRelatedNodes in interface Node
Following copied from interface: org.mmbase.bridge.Node
Parameters:
nodeManager - the name of the node manager the counted nodes should have
Returns:
the number of related nodes that have a specific node manager

getAliases

public java.util.List getAliases()
Description copied from interface: Node
Returns all aliases for this node.
Specified by:
getAliases in interface Node
Following copied from interface: org.mmbase.bridge.Node
Returns:
a list of alias names for this node

createAlias

public void createAlias(java.lang.String aliasName)
Description copied from interface: Node
Create an alias for this node. An alias can be used to refer to a node in addition to his number.
Specified by:
createAlias in interface Node
Following copied from interface: org.mmbase.bridge.Node
Parameters:
alias - the alias to be created for this node
Throws:
BridgeException - if the alias allready exists

deleteAlias

public void deleteAlias(java.lang.String aliasName)
Description copied from interface: Node
Delete an alias for this node.
Specified by:
deleteAlias in interface Node
Following copied from interface: org.mmbase.bridge.Node
Parameters:
alias - the alias to be removed for this node

createRelation

public Relation createRelation(Node destinationNode,
                               RelationManager relationManager)
Description copied from interface: Node
Adds a relation between this node and a specified node to the cloud.
Specified by:
createRelation in interface Node
Following copied from interface: org.mmbase.bridge.Node
Parameters:
destinationNode - the node to which you want to relate this node
relationManager - the relation manager you want to use
Returns:
the added relation
Throws:
BridgeException - if the relation manager is not the right one for this type of relation

equals

public boolean equals(java.lang.Object o)
Compares two objects, and returns true if they are equal. This effectively means that both objects are nodes, and they both refer to the same objectnode
Overrides:
equals in class java.lang.Object
Parameters:
o - the object to compare it with

hashCode

public int hashCode()
Returns the object's hashCode. This effectively returns th objectnode's number
Overrides:
hashCode in class java.lang.Object

setContext

public void setContext(java.lang.String context)
set the Context of the current Node
Specified by:
setContext in interface Node
Parameters:
context - The context to which the current node should belong,
Throws:
BridgeException - Dunno?
java.lang.SecurityException - When not the approperate rights (change context)

getContext

public java.lang.String getContext()
get the Context of the current Node
Specified by:
getContext in interface Node
Returns:
the current context of the node
Throws:
BridgeException - Dunno?
java.lang.SecurityException - When not the approperate rights (read rights)

getPossibleContexts

public StringList getPossibleContexts()
get the Contextes which can be set to this specific node
Specified by:
getPossibleContexts in interface Node
Returns:
the contextes from which can be chosen
Throws:
BridgeException - Dunno?
java.lang.SecurityException - When not the approperate rights (read rights)

mayWrite

public boolean mayWrite()
Description copied from interface: Node
Check write rights on this node.
Specified by:
mayWrite in interface Node
Following copied from interface: org.mmbase.bridge.Node
Returns:
whether the node may be changed by the current user

mayDelete

public boolean mayDelete()
Description copied from interface: Node
Check delete rights on this node.
Specified by:
mayDelete in interface Node
Following copied from interface: org.mmbase.bridge.Node
Returns:
whether the node may be deleted by the current user

mayLink

public boolean mayLink()
Description copied from interface: Node
Check link rights on this node.
Specified by:
mayLink in interface Node
Following copied from interface: org.mmbase.bridge.Node
Returns:
whether the current user may link to this node

mayChangeContext

public boolean mayChangeContext()
Description copied from interface: Node
Check context-change rights on this node.
Specified by:
mayChangeContext in interface Node
Following copied from interface: org.mmbase.bridge.Node
Returns:
whether the current user may change the context of this node


MMBase 2001