org.mmbase.module.core
Class MMObjectNode

java.lang.Object
  extended byorg.mmbase.module.core.MMObjectNode
All Implemented Interfaces:
Serializable, SizeMeasurable
Direct Known Subclasses:
VirtualNode

public class MMObjectNode
extends Object
implements SizeMeasurable, Serializable

MMObjectNode is the core of the MMBase system. This class is what its all about, because the instances of this class hold the content we are using. All active Nodes with data and relations are MMObjectNodes and make up the object world that is MMBase (Creating, searching, removing is done by the node's parent, which is a class extended from MMObjectBuilder)

Version:
$Id: MMObjectNode.java,v 1.191 2006/07/05 09:56:45 michiel Exp $
Author:
Daniel Ockeloen, Pierre van Rooden, Eduard Witteveen, Michiel Meeuwissen, Ernst Bunders
See Also:
Serialized Form

Field Summary
protected  boolean initializing
          Determines whether the node is being initialized (typically when it is loaded from the database).
protected  boolean isNew
          If true, the node is a new node, which is not (yet) stored in storage.
protected  MMObjectBuilder parent
          Pointer to the parent builder that is responsible for this node.
 Hashtable properties
          Holds the 'extra' name-value pairs (the node's properties) which are retrieved from the 'properties' table.
protected static RelatedNodesCache relatedCache
          Results of getRelatedNodes
protected static RelationsCache relationsCache
          objectNumber -> List of all relation nodes
static Object VALUE_NULL
          Deprecated. Simply use null
static String VALUE_SHORTED
          Large fields (blobs) are loaded 'lazily', so only on explicit request.
protected  Map values
          Holds the name - value pairs of this node (the node's fields).
 
Constructor Summary
MMObjectNode(MMObjectBuilder parent)
          Default Main constructor, creates a node that is new and not (yet) in storage.
MMObjectNode(MMObjectBuilder parent, boolean isNew)
          Main constructor.
MMObjectNode(MMObjectBuilder parent, Map map)
          Creates an MMObject based on a given Map.
MMObjectNode(MMObjectNode node)
           
 
Method Summary
 void cancel()
          Undo changes made to the node.
protected  boolean checkFieldExistance(String fieldName)
           
 boolean clearChanged()
          Clear the 'signal' Vector with the changed keys since last commit/insert.
 boolean commit()
          Commit the node to the database or other storage system.
 boolean commit(UserContext user)
          Commit this node to the storage
 Parameters createParameters(String functionName)
           
 boolean defaultEquals(MMObjectNode n)
           
 void delPropertiesCache()
          Deletes the propertie cache for this node.
 void delRelationsCache()
          Delete the relation cache for this node.
 boolean equals(Object o)
           
 void finish()
          Finish the loading of a node
 int getAge()
          Return the age of the node, determined using the daymarks builder.
 Enumeration getAllRelations()
          Return all the relations of this node.
 boolean getBooleanValue(String fieldName)
          Get a value of a certain field.
 MMObjectBuilder getBuilder()
          Returns the actual builder of the node.
 int getByteSize()
          Determines the byte-size of this object
 int getByteSize(SizeOf sizeof)
          Determines the byte-size of this object using the given SizeOf instance.
 byte[] getByteValue(String fieldName)
          Get a binary value of a certain field.
 Set getChanged()
          Return the names of all persistent fields that were changed.
 String getContext(UserContext user)
          Returns the security context for this node
 Date getDateValue(String fieldName)
          Get a value of a certain field.
 int getDBState(String fieldName)
          Returns the DBState of a field.
 int getDBType(String fieldName)
          Returns the DBType of a field.
 double getDoubleValue(String fieldName)
          Get a value of a certain field.
 float getFloatValue(String fieldName)
          Get a value of a certain field.
 Function getFunction(String functionName)
           
 Collection getFunctions()
           
 Object getFunctionValue(String functionName, List parameters)
          XXX: return type of this method make it impossible to make MMObjectNode implements Node, perhaps it needs change
 String getGUIIndicator()
          Return the GUI indicator for this node.
 InputStream getInputStreamValue(String fieldName)
           
 Integer getIntegerValue(String fieldName)
          Get a value of a certain field.
 int getIntValue(String fieldName)
          Get a value of a certain field.
 List getListValue(String fieldName)
          Get a value of a certain field.
 long getLongValue(String fieldName)
          Get a value of a certain field.
 String getName()
          Return the buildername of this node
 MMObjectNode getNodeValue(String fieldName)
          Get a value of a certain field.
 int getNumber()
          Retrieve an object's number.
 Map getOldValues()
           
 int getOType()
          Retrieve an object's object type.
 Set getPossibleContexts(UserContext user)
          Returns the possible new security contexts for this node
 Hashtable getProperties()
          Return a the properties for this node.
 MMObjectNode getProperty(String key)
          Returns a specified property of this node.
 Vector getRelatedNodes()
          Get all related nodes.
 Vector getRelatedNodes(String type)
          Get the related nodes of a certain type.
 Vector getRelatedNodes(String type, int search_type)
          If you query from this_node_type(type) (typex, insrel, typey where typex == typey) { if the insrel table is directional, use the multirelations.SEARCH_BOTH if the insrel table is not directional, use the multirelations.SEARCH_SOURCE + multirelations.SEARCH_DESTINATION } Otherwise the SEARCH_BOTH will result in an OR on insrel which will never return in (huge) databases.
 Vector getRelatedNodes(String type, String role, int search_type)
          If you query from this_node_type(type) (typex, insrel, typey where typex == typey) { if the insrel table is directional, use the multirelations.SEARCH_BOTH if the insrel table is not directional, use the multirelations.SEARCH_SOURCE + multirelations.SEARCH_DESTINATION } Otherwise the SEARCH_BOTH will result in an OR on insrel which will never return in (huge) databases.
static int getRelationCacheHits()
          Deprecated. use RelationsCache.getCache().getHits()
static int getRelationCacheMiss()
          Deprecated. use RelationsCache.getCache().getMisses()
 int getRelationCount()
          Returns the number of relations of this node.
 int getRelationCount(String wt)
          Return the number of relations of this node, filtered on a specified type.
protected  List getRelationNodes()
           
 Enumeration getRelations()
          Return the relations of this node.
 Enumeration getRelations(int otype)
          Return the relations of this node, filtered on a specified type.
 Enumeration getRelations(String wantedtype)
          Return the relations of this node, filtered on a specified type.
 long getSize(String fieldName)
          Returns the size (in byte) of the given field.
 String getStringValue(String fieldName)
          Get a value of a certain field.
 Object getValue(String fieldName)
          Get a value of a certain field.
 Map getValues()
           
 Document getXMLValue(String fieldName)
          Returns the value of the specified field as a dom.Document If the node value is not itself a Document, the method attempts to attempts to convert the String value into an XML.
 int hashCode()
           
 boolean hasRelations()
          Returns whether this node has relations.
 int insert(String userName)
          Insert this node into the storage
 int insert(UserContext user)
          Insert this node into the database or other storage system.
 boolean isChanged()
          Tests whether one of the values of this node was changed since the last commit/insert.
 boolean isNew()
          If a node is still 'new' you must persistify it with insert(java.lang.String), and otherwise with commit().
 boolean isNull(String fieldName)
           
 boolean isVirtual()
          Determines whether the node is virtual.
 void putProperty(MMObjectNode node)
          Sets a specified property for this node.
 void remove(UserContext user)
          Remove this node from the storage
 void removeRelations()
          Remove the relations of the node.
 Object retrieveValue(String fieldName)
          Retrieves a value from the values hashtable.
 boolean sendFieldChangeSignal(String fieldName)
          Sends a field-changed signal.
 void setAlias(String alias)
          Sets the node's alias.
 void setContext(UserContext user, String context, boolean now)
          Sets the security context for this node
 void setSize(String fieldName, long size)
          Sets the size (in byte) of the given field.
 boolean setValue(String fieldName, boolean fieldValue)
          Sets a key/value pair in the main values of this node.
 boolean setValue(String fieldName, double fieldValue)
          Sets a key/value pair in the main values of this node.
 boolean setValue(String fieldName, int fieldValue)
          Sets a key/value pair in the main values of this node.
 boolean setValue(String fieldName, long fieldValue)
          Sets a key/value pair in the main values of this node.
 boolean setValue(String fieldName, Object fieldValue)
          Sets a key/value pair in the main values of this node.
 void start()
          Start the loading of a node
 void storeValue(String fieldName, Object fieldValue)
          Stores a value in the values hashtable.
 void testValidData()
          Tests whether the data in a node is valid (throws an exception if this is not the case).
 String toString()
          Returns the core of this node in a string.
protected  Document toXML(Object value, String fieldName)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

VALUE_NULL

public static final Object VALUE_NULL
Deprecated. Simply use null


VALUE_SHORTED

public static final String VALUE_SHORTED
Large fields (blobs) are loaded 'lazily', so only on explicit request. Until the first exlicit request this value is stored in such fields. It can be set back into the field with storeValue(java.lang.String, java.lang.Object), to unload the field again.

Since:
MMBase-1.7.4
See Also:
Constant Field Values

relatedCache

protected static final RelatedNodesCache relatedCache
Results of getRelatedNodes

Since:
1.7

relationsCache

protected static final RelationsCache relationsCache
objectNumber -> List of all relation nodes

Since:
MMBase-1.7

values

protected Map values
Holds the name - value pairs of this node (the node's fields). Most nodes will have a 'number' and an 'otype' field, and fields which will differ by builder. This collection should not be directly queried or changed - use the SetValue and getXXXValue methods instead. It should then be made private, and methods that change the map (storeValue) be made synchronized. Note: To avoid synchronisation conflicts, we can't really change the type until the property is made private.


initializing

protected boolean initializing
Determines whether the node is being initialized (typically when it is loaded from the database). Use start() to start initializing, use finish() to end.

Since:
MMBase-1.7

properties

public Hashtable properties
Holds the 'extra' name-value pairs (the node's properties) which are retrieved from the 'properties' table.

Warning: Scope will be changed to:
private

parent

protected MMObjectBuilder parent
Pointer to the parent builder that is responsible for this node. Note: this may on occasion (due to optimization) duffer for the node's original builder. Use getBuilder() instead.

Warning: Scope will be changed to:
private

isNew

protected boolean isNew
If true, the node is a new node, which is not (yet) stored in storage.

Constructor Detail

MMObjectNode

public MMObjectNode(MMObjectBuilder parent)
Default Main constructor, creates a node that is new and not (yet) in storage.

Parameters:
parent - the node's parent, an instance of the node's builder.
Throws:
IllegalArgumentException - If parent is null

MMObjectNode

public MMObjectNode(MMObjectBuilder parent,
                    boolean isNew)
Main constructor.

Parameters:
parent - the node's parent, an instance of the node's builder.
isNew - if the node is a newly created node
Throws:
IllegalArgumentException - If parent is null

MMObjectNode

public MMObjectNode(MMObjectNode node)
Since:
MMBase-1.8

MMObjectNode

public MMObjectNode(MMObjectBuilder parent,
                    Map map)
Creates an MMObject based on a given Map. This can e.g. be used to make an MMObjectNode of a bridge node (use NodeMap).

Since:
MMBase-1.8
Method Detail

getRelationCacheHits

public static int getRelationCacheHits()
Deprecated. use RelationsCache.getCache().getHits()


getRelationCacheMiss

public static int getRelationCacheMiss()
Deprecated. use RelationsCache.getCache().getMisses()


getBuilder

public MMObjectBuilder getBuilder()
Returns the actual builder of the node. Note that it is possible that, due to optimization, a node is currently associated with another (parent) builder, i.e. a posrel node may be associated with a insrel builder. This method returns the actual builder. The node may miss vital information (not retrieved from the database) to act as a node of such a builder - if you need actual status you need to reload it.

Returns:
the builder of this node
Since:
MMBase-1.6

start

public void start()
Start the loading of a node

Since:
MMBase-1.7

finish

public void finish()
Finish the loading of a node

Since:
MMBase-1.7

testValidData

public void testValidData()
                   throws InvalidDataException
Tests whether the data in a node is valid (throws an exception if this is not the case).

Throws:
InvalidDataException - If the data was unrecoverably invalid (the references did not point to existing objects)

commit

public boolean commit()
Commit the node to the database or other storage system. This can only be done on a existing (inserted) node. It will use the changed Vector as its base of what to commit/change.

Returns:
true if the commit was succesfull, false is it failed

cancel

public void cancel()
Undo changes made to the node.

Since:
MMBase-1.8

insert

public int insert(String userName)
Insert this node into the storage

Parameters:
userName - the name of the user who inserts the node. This value is ignored
Returns:
the new node key (number field), or -1 if the insert failed

insert

public int insert(UserContext user)
Insert this node into the database or other storage system.

Parameters:
user - the user who inserts the node. Used to set security-related information
Returns:
the new node key (number field), or -1 if the insert failed
Since:
MMBase-1.7

commit

public boolean commit(UserContext user)
Commit this node to the storage

Parameters:
user - the user who commits the node. Used to set security-related information
Returns:
true if succesful
Since:
MMBase-1.7

remove

public void remove(UserContext user)
Remove this node from the storage

Parameters:
user - the user who removes the node. Used to set security-related information
Since:
MMBase-1.7

setContext

public void setContext(UserContext user,
                       String context,
                       boolean now)
Sets the security context for this node

Parameters:
user - the user who changes the context of the node.
context - the new context
now - if true, the context is changed instantly, otherwise it is changed after the node is send to storage.
Since:
MMBase-1.7

getContext

public String getContext(UserContext user)
Returns the security context for this node

Parameters:
user - the user who requests the context of the node.
Since:
MMBase-1.7.1

getPossibleContexts

public Set getPossibleContexts(UserContext user)
Returns the possible new security contexts for this node

Parameters:
user - the user who requests the context of the node.
Since:
MMBase-1.7.1

toString

public String toString()
Returns the core of this node in a string. Used for debugging. For data exchange use toXML() and getDTD().

Returns:
the contents of the node as a string.

checkFieldExistance

protected boolean checkFieldExistance(String fieldName)
Returns:
true if field exists and may be used.
Since:
MMBase-1.8

storeValue

public void storeValue(String fieldName,
                       Object fieldValue)
Stores a value in the values hashtable. This is a low-level method that circumvents typechecking and the triggers of extended classes. You should normally call setValue(java.lang.String, java.lang.Object) to change fields.

Parameters:
fieldName - the name of the field to change
fieldValue - the value to assign
To Do:
This should become a synchronized method, once values becomes a private HashMap instead of a public Hashtable.

retrieveValue

public Object retrieveValue(String fieldName)
Retrieves a value from the values hashtable. This is a low-level method that circumvents typechecking and the triggers of extended classes. You should normally call getValue(java.lang.String) to load fields.

Parameters:
fieldName - the name of the field to change
Returns:
the value of the field

isVirtual

public boolean isVirtual()
Determines whether the node is virtual. A virtual node is not persistent (that is, stored in a database table).


isNew

public boolean isNew()
If a node is still 'new' you must persistify it with insert(java.lang.String), and otherwise with commit().

Since:
MMBase-1.8

toXML

protected Document toXML(Object value,
                         String fieldName)

setValue

public boolean setValue(String fieldName,
                        Object fieldValue)
Sets a key/value pair in the main values of this node. Note that if this node is a node in cache, the changes are immediately visible to everyone, even if the changes are not committed. The fieldName is added to the (public) 'changed' vector to track changes.

Parameters:
fieldName - the name of the field to change
fieldValue - the value to assign
Returns:
true When the field was changed, false otherwise.

setSize

public void setSize(String fieldName,
                    long size)
Sets the size (in byte) of the given field. This is meant for byte-array fields, which you fill using an InputStream.

Since:
MMBase-1.8
See Also:
getSize(String)

getSize

public long getSize(String fieldName)
Returns the size (in byte) of the given field. This is mainly targeted at fields of the type byte array. For other fields this method will return something reasonable, but it is as yet not well defined what...

Since:
MMBase-1.8

setValue

public boolean setValue(String fieldName,
                        boolean fieldValue)
Sets a key/value pair in the main values of this node. The value to set is of type boolean. Note that if this node is a node in cache, the changes are immediately visible to everyone, even if the changes are not committed. The fieldName is added to the (public) 'changed' vector to track changes.

Parameters:
fieldName - the name of the field to change
fieldValue - the value to assign
Returns:
always true

setValue

public boolean setValue(String fieldName,
                        int fieldValue)
Sets a key/value pair in the main values of this node. The value to set is of type int. Note that if this node is a node in cache, the changes are immediately visible to everyone, even if the changes are not committed. The fieldName is added to the (public) 'changed' vector to track changes.

Parameters:
fieldName - the name of the field to change
fieldValue - the value to assign
Returns:
always true

setValue

public boolean setValue(String fieldName,
                        long fieldValue)
Sets a key/value pair in the main values of this node. The value to set is of type int. Note that if this node is a node in cache, the changes are immediately visible to everyone, even if the changes are not committed. The fieldName is added to the (public) 'changed' vector to track changes.

Parameters:
fieldName - the name of the field to change
fieldValue - the value to assign
Returns:
always true

setValue

public boolean setValue(String fieldName,
                        double fieldValue)
Sets a key/value pair in the main values of this node. The value to set is of type double. Note that if this node is a node in cache, the changes are immediately visible to everyone, even if the changes are not committed. The fieldName is added to the (public) 'changed' vector to track changes.

Parameters:
fieldName - the name of the field to change
fieldValue - the value to assign
Returns:
always true

getNumber

public int getNumber()
Retrieve an object's number. In case of a new node that is not committed, this will return -1.

Returns:
the number of the node

getOType

public int getOType()
Retrieve an object's object type. This is a number (an index in the typedef builer), rather than a name.

Returns:
the object type number of the node

isNull

public boolean isNull(String fieldName)
Since:
MMBase-1.8

getValue

public Object getValue(String fieldName)
Get a value of a certain field.

Parameters:
fieldName - the name of the field who's data to return
Returns:
the field's value as an Object
Warning: Performance Issues
do not store byte values directly in node (?)

getStringValue

public String getStringValue(String fieldName)
Get a value of a certain field. The value is returned as a String. Non-string values are automatically converted to String. 'null' is converted to an empty string.

Parameters:
fieldName - the name of the field who's data to return
Returns:
the field's value as a String

getFunctionValue

public Object getFunctionValue(String functionName,
                               List parameters)
XXX: return type of this method make it impossible to make MMObjectNode implements Node, perhaps it needs change

Since:
MMBase-1.6
Warning: No Java Documentation Available.

createParameters

public Parameters createParameters(String functionName)
Since:
MMBase-1.8
Warning: No Java Documentation Available.

getFunction

public Function getFunction(String functionName)
Since:
MMBase-1.8
Warning: No Java Documentation Available.

getFunctions

public Collection getFunctions()
Since:
MMBase-1.8
Warning: No Java Documentation Available.

getXMLValue

public Document getXMLValue(String fieldName)
Returns the value of the specified field as a dom.Document If the node value is not itself a Document, the method attempts to attempts to convert the String value into an XML. If the value cannot be converted, this method returns null

Parameters:
fieldName - the name of the field to be returned
Returns:
the value of the specified field as a DOM Element or null
Throws:
IllegalArgumentException - if the value cannot be converted.
Since:
MMBase-1.6

getByteValue

public byte[] getByteValue(String fieldName)
Get a binary value of a certain field.

Parameters:
fieldName - the name of the field who's data to return
Returns:
the field's value as an byte [] (binary/blob field)
Warning: Performance Issues
do not store byte values directly in node (?)

getInputStreamValue

public InputStream getInputStreamValue(String fieldName)

getNodeValue

public MMObjectNode getNodeValue(String fieldName)
Get a value of a certain field. The value is returned as an MMObjectNode. If the field contains an Numeric value, the method tries to obtrain the object with that number. If it is a String, the method tries to obtain the object with that alias. The only other possible values are those created by certain virtual fields. All remaining situations return null.

Parameters:
fieldName - the name of the field who's data to return
Returns:
the field's value as an int

getIntValue

public int getIntValue(String fieldName)
Get a value of a certain field. The value is returned as an int value. Values of non-int, numeric fields are converted if possible. Booelan fields return 0 for false, 1 for true. String fields are parsed to a number, if possible. If a value is an MMObjectNode, its numberfield is returned. All remaining field values return -1.

Parameters:
fieldName - the name of the field who's data to return
Returns:
the field's value as an int

getBooleanValue

public boolean getBooleanValue(String fieldName)
Get a value of a certain field. The value is returned as an boolean value. If the actual value is numeric, this call returns true if the value is a positive, non-zero, value. In other words, values '0' and '-1' are concidered false. If the value is a string, this call returns true if the value is "true" or "yes" (case-insensitive). In all other cases (including calling byte fields), false is returned. Note that there is currently no basic MMBase boolean type, but some excecuteFunction calls may return a Boolean result.

Parameters:
fieldName - the name of the field who's data to return
Returns:
the field's value as an int

getIntegerValue

public Integer getIntegerValue(String fieldName)
Get a value of a certain field. The value is returned as an Integer value. Values of non-Integer, numeric fields are converted if possible. Boolean fields return 0 for false, 1 for true. String fields are parsed to a number, if possible. All remaining field values return -1.

Parameters:
fieldName - the name of the field who's data to return
Returns:
the field's value as an Integer

getLongValue

public long getLongValue(String fieldName)
Get a value of a certain field.

Parameters:
fieldName - the name of the field who's data to return
Returns:
the field's value as a long
See Also:
getValue(java.lang.String), Casting.toLong(java.lang.Object, long)

getFloatValue

public float getFloatValue(String fieldName)
Get a value of a certain field. The value is returned as a float value. Values of non-float, numeric fields are converted if possible. Boolean fields return 0 for false, 1 for true. String fields are parsed to a number, if possible. All remaining field values return -1.

Parameters:
fieldName - the name of the field who's data to return
Returns:
the field's value as a float

getDoubleValue

public double getDoubleValue(String fieldName)
Get a value of a certain field. The value is returned as a double value. Values of non-double, numeric fields are converted if possible. Boolean fields return 0 for false, 1 for true. String fields are parsed to a number, if possible. All remaining field values return -1.

Parameters:
fieldName - the name of the field who's data to return
Returns:
the field's value as a double

getDateValue

public Date getDateValue(String fieldName)
Get a value of a certain field. The value is returned as a Date value. Values of numeric fields are converted as if they were time in seconds since 1/1/1970. String fields are parsed to a date, if possible. All remaining field values return -1.

Parameters:
fieldName - the name of the field who's data to return
Returns:
the field's value as a Date
Since:
MMBase-1.8

getListValue

public List getListValue(String fieldName)
Get a value of a certain field. The value is returned as a List value. Strings are treated as comma-seperated value lists, and split into their component parts. Values of other fields are returned as Lists of one object.

Parameters:
fieldName - the name of the field who's data to return
Returns:
the field's value as a List
Since:
MMBase-1.8

getDBType

public int getDBType(String fieldName)
Returns the DBType of a field.

Parameters:
fieldName - the name of the field which' type to return
Returns:
the field's DBType

getDBState

public int getDBState(String fieldName)
Returns the DBState of a field.

Parameters:
fieldName - the name of the field who's state to return
Returns:
the field's DBState

getChanged

public Set getChanged()
Return the names of all persistent fields that were changed. Note that this is a direct reference. Changes (i.e. clearing the vector) will affect the node's status.

Returns:
A Set containing Strings. The set is modifiable, and synchronized. Don't modify it though.

isChanged

public boolean isChanged()
Tests whether one of the values of this node was changed since the last commit/insert.

Returns:
true if changes have been made, false otherwise

clearChanged

public boolean clearChanged()
Clear the 'signal' Vector with the changed keys since last commit/insert. Marks the node as 'unchanged'. Does not affect the values of the fields, nor does it commit the node.

Returns:
always true

delPropertiesCache

public void delPropertiesCache()
Deletes the propertie cache for this node. Forces a reload of the properties on next use.


getValues

public Map getValues()

getOldValues

public Map getOldValues()
Since:
MMBase-1.8

getProperties

public Hashtable getProperties()
Return a the properties for this node.

Returns:
the properties as a Hashtable

getProperty

public MMObjectNode getProperty(String key)
Returns a specified property of this node.

Parameters:
key - the name of the property to retrieve
Returns:
the property object as a MMObjectNode

putProperty

public void putProperty(MMObjectNode node)
Sets a specified property for this node. This method does not commit anything - it merely updates the node's propertylist.

Parameters:
node - the property object as a MMObjectNode

getGUIIndicator

public String getGUIIndicator()
Return the GUI indicator for this node. The GUI indicator is a string that represents the contents of this node. By default it is the string-representation of the first non-system field of the node. Individual builders can alter this behavior.

Returns:
the GUI iddicator as a String

getName

public String getName()
Return the buildername of this node

Returns:
the builder table name

delRelationsCache

public void delRelationsCache()
Delete the relation cache for this node. This means it will be reloaded from the database/storage on next use.


hasRelations

public boolean hasRelations()
Returns whether this node has relations. This includes unidirection relations which would otherwise not be counted.

Returns:
true if any relations exist, false otherwise.

getAllRelations

public Enumeration getAllRelations()
Return all the relations of this node. Use only to delete the relations of a node. Note that this returns the nodes describing the relation - not the nodes 'related to'.

Returns:
An Enumeration containing the nodes

getRelations

public Enumeration getRelations()
Return the relations of this node. Note that this returns the nodes describing the relation - not the nodes 'related to'. XXX: return type of this method makes it impossible to make MMObjectNode implements Node, perhaps it needs change

Returns:
An Enumeration containing the nodes

getRelationNodes

protected List getRelationNodes()
Since:
MMBase-1.7
Warning: Scope will be changed to:
public?

removeRelations

public void removeRelations()
Remove the relations of the node.


getRelationCount

public int getRelationCount()
Returns the number of relations of this node.

Returns:
An int indicating the number of nodes found

getRelations

public Enumeration getRelations(int otype)
Return the relations of this node, filtered on a specified type. Note that this returns the nodes describing the relation - not the nodes 'related to'.

Parameters:
otype - the 'type' of relations to return. The type identifies a relation (InsRel-derived) builder, not a reldef object.
Returns:
An Enumeration containing the nodes

getRelations

public Enumeration getRelations(String wantedtype)
Return the relations of this node, filtered on a specified type. Note that this returns the nodes describing the relation - not the nodes 'related to'.

Parameters:
wantedtype - the 'type' of relations to return. The type identifies a relation (InsRel-derived) builder, not a reldef object.
Returns:
An Enumeration containing the nodes

getRelationCount

public int getRelationCount(String wt)
Return the number of relations of this node, filtered on a specified type.

Parameters:
wt - the 'type' of related nodes (NOT the relations!).
Returns:
An int indicating the number of nodes found

getAge

public int getAge()
Return the age of the node, determined using the daymarks builder.

Returns:
the age in days, or 0 if unknown (daymarks builder not present)

sendFieldChangeSignal

public boolean sendFieldChangeSignal(String fieldName)
Sends a field-changed signal.

Parameters:
fieldName - the name of the changed field.
Returns:
always true

setAlias

public void setAlias(String alias)
Sets the node's alias. The code only sets a (memory) property, it does not actually add the alias to the database. Only works for uninserted Nodes. So this is actually only used for application import. No need to use this. Use MMObjectBuilder.createAlias(int, java.lang.String, java.lang.String).


getRelatedNodes

public Vector getRelatedNodes()
Get 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. XXX: return type of this method make it impossible to make MMObjectNode implements Node, perhaps it needs change

Returns:
a Vector containing MMObjectNodes

getRelatedNodes

public Vector getRelatedNodes(String type)
Get the related nodes of a certain type. 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 XXX: return type of this method make it impossible to make MMObjectNode implements Node, perhaps it needs change

Parameters:
type - the type of objects to be returned
Returns:
a Vector containing MMObjectNodes

getRelatedNodes

public Vector getRelatedNodes(String type,
                              int search_type)
If you query from this_node_type(type) (typex, insrel, typey where typex == typey) { if the insrel table is directional, use the multirelations.SEARCH_BOTH if the insrel table is not directional, use the multirelations.SEARCH_SOURCE + multirelations.SEARCH_DESTINATION } Otherwise the SEARCH_BOTH will result in an OR on insrel which will never return in (huge) databases.

Parameters:
type - the type of teh realted node to return
search_type - the type of directionality to use
Since:
MMBase-1.6.3

getRelatedNodes

public Vector getRelatedNodes(String type,
                              String role,
                              int search_type)
If you query from this_node_type(type) (typex, insrel, typey where typex == typey) { if the insrel table is directional, use the multirelations.SEARCH_BOTH if the insrel table is not directional, use the multirelations.SEARCH_SOURCE + multirelations.SEARCH_DESTINATION } Otherwise the SEARCH_BOTH will result in an OR on insrel which will never return in (huge) databases.

Parameters:
type - the type of teh realted node to return
role - the role of the relation (null if no role specified)
search_type - the type of directionality to use
Since:
MMBase-1.6.3

getByteSize

public int getByteSize()
Description copied from interface: SizeMeasurable
Determines the byte-size of this object

Specified by:
getByteSize in interface SizeMeasurable

getByteSize

public int getByteSize(SizeOf sizeof)
Description copied from interface: SizeMeasurable
Determines the byte-size of this object using the given SizeOf instance. A SizeOf instance stores a Set already counted objects. So this method is typically called by SizeOf itself (recursion).

Specified by:
getByteSize in interface SizeMeasurable

hashCode

public int hashCode()
Since:
MMBase-1.6.2

equals

public boolean equals(Object o)
Since:
MMBase-1.6.2

defaultEquals

public boolean defaultEquals(MMObjectNode n)
Since:
MMBase-1.6.2


MMBase build 1.8.1.20060716