org.mmbase.module.core
Class VirtualNode

Package class diagram package VirtualNode
java.lang.Object
  extended by org.mmbase.module.core.MMObjectNode
      extended by org.mmbase.module.core.VirtualNode
All Implemented Interfaces:
Serializable, Cloneable, PublicCloneable<MMObjectNode>, SizeMeasurable
Direct Known Subclasses:
ClusterNode, ResultNode, TypeRel.VirtualTypeRelNode

public class VirtualNode
extends MMObjectNode

VirtualNode is a representation of a virtual objectnode. Virtual Object nodes are nodes that are not stored in a databasetable. Note that a temporary node is not virtual. This class captures a number of methods that would normally require datbase access, such as obtaining relations or determining age of a node.

Version:
$Id: VirtualNode.java 45150 2011-02-10 09:18:12Z michiel $
Author:
Pierre van Rooden
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.mmbase.module.core.MMObjectNode
aliases, initializing, isNew, oldBuilder, parent, sequence, VALUE_SHORTED, values
 
Constructor Summary
VirtualNode(Map<String,Object> values)
          Alternate constructor, to create a node with the values given.
VirtualNode(MMObjectBuilder parent)
          Main constructor.
 
Method Summary
protected  boolean checkFieldExistance(String fieldName)
          Overrides to no throw exception on non-existing fields
 boolean commit()
          commit : commits the node to the database or other storage system.
 int getAge()
          Returns the node's age A virtual node is always new (0)
 int getOType()
          Retrieve an object's object type.
 int getRelationCount()
          Returns the number of relations of this node.
 int getRelationCount(String wantedtype)
          Return the number of relations of this node, filtered on a specified type.
 Enumeration<MMObjectNode> getRelations()
          Return the relations of this node.
 boolean hasRelations()
          Returns whether this node has relations.
 int insert(String userName)
          Insert is not implemented on a virtual node.
 boolean isVirtual()
          Determines whether the node is virtual.
 
Methods inherited from class org.mmbase.module.core.MMObjectNode
cancel, checkSerializable, clearChanged, clone, commit, compareTo, createParameters, defaultEquals, defaultToString, delPropertiesCache, delRelationsCache, delRelationsCache, equals, finish, getAllRelations, getBooleanValue, getBuilder, getByteSize, getByteSize, getByteValue, getChanged, getContext, getDateValue, getDBState, getDBType, getDoubleValue, getFloatValue, getFunction, getFunctions, getFunctionValue, getGUIIndicator, getInputStreamValue, getIntegerValue, getIntValue, getListValue, getLongValue, getName, getNodeValue, getNumber, getOldBuilder, getOldValues, getPossibleContexts, getProperties, getProperty, getRelatedNodes, getRelatedNodes, getRelatedNodes, getRelatedNodes, getRelationNodes, getRelations, getRelations, getSize, getStringValue, getValue, getValues, getXMLValue, hashCode, insert, isChanged, isNew, isNull, putProperty, remove, removeRelations, retrieveValue, sendFieldChangeSignal, setAlias, setBuilder, setContext, setSize, setValue, start, storeValue, testValidData, toString, toXML, useAliases
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VirtualNode

public VirtualNode(MMObjectBuilder parent)
Main constructor.

Parameters:
parent - the node's parent

VirtualNode

public VirtualNode(Map<String,Object> values)
Alternate constructor, to create a node with the values given.

Method Detail

isVirtual

public boolean isVirtual()
Description copied from class: MMObjectNode
Determines whether the node is virtual. A virtual node is not persistent (that is, stored in a database table).

Overrides:
isVirtual in class MMObjectNode

checkFieldExistance

protected boolean checkFieldExistance(String fieldName)
Overrides to no throw exception on non-existing fields

Overrides:
checkFieldExistance in class MMObjectNode
Returns:
true if field exists and may be used.

commit

public boolean commit()
commit : commits the node to the database or other storage system. Generally, commiting a virtual node has no effect, so the basic implementation returns false.

Overrides:
commit in class MMObjectNode
Returns:
false

insert

public int insert(String userName)
Insert is not implemented on a virtual node.

Overrides:
insert in class MMObjectNode
Parameters:
userName - the name of the user who inserts the node. This value is ignored
Returns:
nothing, throws an exception
Throws:
UnsupportedOperationException

hasRelations

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

Overrides:
hasRelations in class MMObjectNode
Returns:
false

getRelations

public Enumeration<MMObjectNode> 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 A virtual node never has relations.

Overrides:
getRelations in class MMObjectNode
Returns:
empty Enumeration

getRelationCount

public int getRelationCount()
Returns the number of relations of this node. A virtual node never has relations.

Overrides:
getRelationCount in class MMObjectNode
Returns:
0, because Virtual nodes have no relations.

getRelationCount

public int getRelationCount(String wantedtype)
Return the number of relations of this node, filtered on a specified type. A virtual node never has relations.

Overrides:
getRelationCount in class MMObjectNode
Parameters:
wantedtype - the 'type' of related nodes (NOT the relations!).
Returns:
0, because Virtual nodes have no relations.

getAge

public int getAge()
Returns the node's age A virtual node is always new (0)

Overrides:
getAge in class MMObjectNode
Returns:
the age in days (0)

getOType

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

Overrides:
getOType in class MMObjectNode
Returns:
the object type number of the node


MMBase2 Core 2.0-SNAPSHOT - 2013-03-30T06:36