public class BasicNode extends AbstractNode implements Node, SizeMeasurable
Node,
MMObjectNodeVirtualNode. They probably should share an ancestor (AbstractBasicNode or so) (MMB-1870)| Modifier and Type | Field and Description |
|---|---|
protected BasicCloud |
cloud
Reference to the Cloud.
|
protected BasicNodeManager |
nodeManager
Reference to the NodeManager
|
protected MMObjectNode |
noderef
Reference to actual MMObjectNode object.
|
protected MMObjectNode |
originalNoderef |
protected int |
temporaryNodeId
Temporary node ID.
|
CLOUD_COMMITNODE_KEY| Constructor and Description |
|---|
BasicNode(BasicCloud cloud) |
BasicNode(MMObjectNode node,
BasicCloud cloud)
Instantiates a node, linking it to a specified cloud
The NodeManager for the node is requested from the Cloud.
|
BasicNode(MMObjectNode node,
BasicCloud cloud,
int id)
Instantiates a new node (for insert), using a specified nodeManager.
|
BasicNode(MMObjectNode node,
BasicNodeManager nodeManager)
Instantiates a node, linking it to a specified node manager.
|
| Modifier and Type | Method and Description |
|---|---|
void |
cancel()
Cancel changes to a node
This fails if the current node is not in edit mode.
|
protected void |
checkAccount() |
protected void |
checkCommit() |
protected void |
checkCreate() |
protected void |
checkDelete() |
protected void |
checkWrite()
Throws exception if may not write current node
|
void |
commit()
Commit the node to the database.
|
int |
countRelatedNodes(NodeManager otherNodeManager,
String role,
String direction) |
int |
countRelatedNodes(String type)
Returns the number of related nodes that have a specific node manager.
|
void |
createAlias(String aliasName)
Create an alias for this node.
|
protected FieldValue |
createFunctionValue(Object result) |
Parameters |
createParameters(String functionName)
Creates a parameter list for a function.
|
void |
delete(boolean deleteRelations)
Removes the Node.
|
void |
deleteAlias(String aliasName)
Delete an alias for this node.
|
void |
deleteRelations(String type)
Removes all relation nodes with a certain relation manager that are
attached to this node.
|
protected void |
finalize()
Reverse the buffers, when changed and not stored...
|
StringList |
getAliases()
Returns all aliases for this node.
|
boolean |
getBooleanValue(String fieldName)
Returns the value of the specified field as a
boolean. |
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)
Returns the value of the specified field as a
byte array. |
Set<String> |
getChanged()
A Set of Strings containing the names of all changed fields.
|
Cloud |
getCloud()
Returns the cloud this node belongs to.
|
String |
getContext()
Get the security context of the current Node
|
Date |
getDateValue(String fieldName) |
double |
getDoubleValue(String fieldName)
Returns the value of the specified field as a
double. |
float |
getFloatValue(String fieldName)
Returns the value of the specified field as a
float. |
Collection<Function<?>> |
getFunctions()
This default implementation is based on
Node.getNodeManager().Node.getFunctions(). |
InputStream |
getInputStreamValue(String fieldName)
Returns the value of the specified field as a
java.io.InputStream This is
especially useful for large byte-array fields. |
int |
getIntValue(String fieldName)
Returns the value of the specified field as an
int. |
List |
getListValue(String fieldName) |
long |
getLongValue(String fieldName)
Returns the value of the specified field as a
long. |
protected MMObjectNode |
getNode()
Obtains a reference to the underlying MMObjectNode.
|
protected Function<?> |
getNodeFunction(String functionName)
Based on
AbstractNode.getFunctions(). |
NodeManager |
getNodeManager()
Returns the node manager for this node.
|
Node |
getNodeValue(String fieldName)
Returns the value of the specified field as a
Node. |
int |
getNumber()
Returns the unique number for this node.
|
StringList |
getPossibleContexts()
Contacts the security implementation to find out to which other possible contexts the
context of this node may be set.
|
protected NodeList |
getRelatedNodes(NodeManager otherManager,
String role)
Get related nodes for this node
|
NodeList |
getRelatedNodes(NodeManager otherManager,
String role,
String searchDir)
Returns all related nodes that have a specific node manager and role.
|
RelationList |
getRelations(String role,
NodeManager nodeManager,
String searchDir)
Returns a list of relations of the given node.
|
RelationList |
getRelations(String role,
String otherNodeManager)
Returns all relation nodes attached to this node that have a specific
role, or refer a node from a specific nodemanager
|
long |
getSize(String fieldName)
Returns the 'size' (e.g.
|
String |
getStringValue(String fieldName)
Returns the value of the specified field as a
String. |
Object |
getValueWithoutProcess(String fieldName)
Like getObjectValue, but skips any processing that MMBase would normally perform on a field.
|
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. |
boolean |
hasRelations()
Checks whether this node has any relations.
|
protected void |
init()
Initializes state in case of a transaction.
|
protected void |
invalidateNode()
Invalidates the reference to the underlying MMObjectNode,
replacing it with a virtual node that only inherits the number field.
|
boolean |
isChanged()
Whether field values were changed since the last commit.
|
boolean |
isChanged(String fieldName)
Whether a certain field's value was changed since the last commit.
|
boolean |
isNew()
Returns whether this is a new (not yet committed) node.
|
boolean |
isNull(String fieldName)
Whether the value for the specified field is
null. |
boolean |
mayChangeContext()
Check context-change rights on this node.
|
boolean |
mayDelete()
Check delete rights on this node.
|
boolean |
mayWrite()
Check write rights on this node.
|
void |
setContext(String context)
Sets the security context of this Node (AKA the 'owner' field)
|
protected void |
setNode(MMObjectNode n)
Sets the reference to the underlying MMObjectNode.
|
protected void |
setNodeManager(MMObjectNode node)
Set nodemanager for node
|
void |
setNodeManager(NodeManager nm)
Sets the node manager of this node.
|
protected void |
setSize(String fieldName,
long size) |
protected void |
setValueWithoutChecks(String fieldName,
Object value)
Protected method to be able to set rnumber when creating a relation.
|
protected Integer |
toNodeNumber(Object v)
A method to convert an object to an node number.
|
String |
toString()
Converts the node to a string
|
compareTo, countRelations, countRelations, createRelation, delete, deleteRelations, equals, getDecimalValue, getFieldValue, getFieldValue, getFunction, getFunctionMap, getFunctionValue, getObjectValue, getRelatedNodes, getRelatedNodes, getRelatedNodes, getRelatedNodes, getRelations, getRelations, getRelations, getValue, getXMLValue, hashCode, isNodeManager, isRelation, isRelationManager, processNull, setBooleanValue, setByteValue, setDateValue, setDecimalValue, setDoubleValue, setFloatValue, setInputStreamValue, setIntValue, setListValue, setLongValue, setNodeValue, setObjectValue, setStringValue, setValue, setValueWithoutProcess, setXMLValue, toNodeManager, toRelation, toRelationManager, validatecountRelations, countRelations, createRelation, delete, deleteRelations, getDecimalValue, getFieldValue, getFieldValue, getFunction, getFunctionValue, getObjectValue, getRelatedNodes, getRelatedNodes, getRelatedNodes, getRelatedNodes, getRelations, getRelations, getRelations, getValue, getXMLValue, isNodeManager, isRelation, isRelationManager, setBooleanValue, setByteValue, setDateValue, setDecimalValue, setDoubleValue, setFloatValue, setInputStreamValue, setIntValue, setListValue, setLongValue, setNodeValue, setObjectValue, setStringValue, setValue, setValueWithoutProcess, setXMLValue, toNodeManager, toRelation, toRelationManager, validatecompareToprotected BasicNodeManager nodeManager
protected final BasicCloud cloud
protected MMObjectNode noderef
protected MMObjectNode originalNoderef
protected int temporaryNodeId
BasicNode(BasicCloud cloud)
BasicNode(MMObjectNode node, BasicNodeManager nodeManager)
node - the MMObjectNode to base the node onnodeManager - the NodeManager to use for administrating this NodeIllegalArgumentException - If node is nullBasicNode(MMObjectNode node, BasicCloud cloud)
node - the MMObjectNode to base the node oncloud - the cloud to which this node belongsIllegalArgumentException - If node is nullBasicNode(MMObjectNode node, BasicCloud cloud, int id)
node - a temporary MMObjectNode that is the base for the nodecloud - the cloud to create the node inid - the id of the node in the temporary cloudprotected void setNodeManager(MMObjectNode node)
node - node to derive nodemanager from.protected void init()
public int getByteSize()
SizeMeasurablegetByteSize in interface SizeMeasurablepublic int getByteSize(SizeOf sizeof)
SizeMeasurablegetByteSize in interface SizeMeasurableprotected final MMObjectNode getNode()
NotFoundException - if no node was specified.protected void invalidateNode()
protected void setNode(MMObjectNode n)
n - the node to set a reference to.IllegalArgumentException - is n is nullpublic Cloud getCloud()
Nodepublic NodeManager getNodeManager()
NodegetNodeManager in interface Nodepublic void setNodeManager(NodeManager nm)
NodesetNodeManager in interface NodesetNodeManager in class AbstractNodepublic int getNumber()
NodegetNumber in interface NodegetNumber in class AbstractNodeNode.createAlias(String alias)public boolean isNew()
isNew in interface NodeisNew in class AbstractNodepublic boolean isChanged(String fieldName)
NodeisChanged in interface NodeisChanged in class AbstractNodefieldName - the name of the fieldtrue when field's value was changedpublic boolean isChanged()
NodeisChanged in interface NodeisChanged in class AbstractNodetrue when changedpublic Set<String> getChanged()
NodegetChanged in interface NodegetChanged in class AbstractNodeprotected void checkAccount()
protected void checkDelete()
protected void checkWrite()
AbstractNodecheckWrite in class AbstractNodeprotected void checkCreate()
protected void checkCommit()
protected void setValueWithoutChecks(String fieldName, Object value)
setValueWithoutChecks in class AbstractNodefieldName - name of fieldvalue - new value of fieldprotected Integer toNodeNumber(Object v)
AbstractNodetoNodeNumber in class AbstractNodeprotected void setSize(String fieldName, long size)
setSize in class AbstractNodepublic boolean isNull(String fieldName)
Nodenull. This avoids acquiring the
complete value if you only want to check if for emptiness.isNull in interface NodeisNull in class AbstractNodefieldName - the name of the fieldtrue when value is nullpublic long getSize(String fieldName)
Nodepublic Object getValueWithoutProcess(String fieldName)
getValueWithoutProcess in interface NodefieldName - name of fieldpublic boolean getBooleanValue(String fieldName)
Nodeboolean.
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 considered 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.getBooleanValue in interface NodegetBooleanValue in class AbstractNodefieldName - the name of the field to be returnedpublic Date getDateValue(String fieldName)
getDateValue in interface NodegetDateValue in class AbstractNodefieldName - the name of the field to be returnedpublic List getListValue(String fieldName)
getListValue in interface NodegetListValue in class AbstractNodefieldName - the name of the field to be returnedpublic Node getNodeValue(String fieldName)
NodeNode.
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.null.
null lets the
Node return a reference to itself, regardless of the actual value of the
number field or status of the Node.getNodeValue in interface NodegetNodeValue in class AbstractNodefieldName - the name of the field to be returnedCloud.getList(String, String, String, String, String, String, String, boolean)public int getIntValue(String fieldName)
Nodeint.
Numeric fields are simply converted. Double and float values may be truncated.
For Node values, the numeric key is returned.
Long values return -1 of the value is too large.
Boolean fields return 0 if false, and 1 if true.
String fields are parsed.
If a parsed string contains an error, ot the field value is not of a type that can be converted
(i.e. a byte array), this function returns -1getIntValue in interface NodegetIntValue in class AbstractNodefieldName - the name of the field to be returnedpublic float getFloatValue(String fieldName)
Nodefloat.
This function attempts to convert the value to a float.
Numeric fields are simply converted.
Boolean fields return 0.0 if false, and 1.0 if true.
String fields are parsed.
If a parsed string contains an error, ot the field value is not of a type that can be converted
(i.e. a byte array), this function returns -1.0.getFloatValue in interface NodegetFloatValue in class AbstractNodefieldName - the name of the field to be returnedpublic long getLongValue(String fieldName)
Nodelong.
This function attempts to convert the value to a long.
Numeric fields are simply converted. Double and float values may be truncated.
Boolean fields return 0 if false, and 1 if true.
String fields are parsed.
If a parsed string contains an error, ot the field value is not of a type that can be converted
(i.e. a byte array), this function returns -1getLongValue in interface NodegetLongValue in class AbstractNodefieldName - the name of the field to be returnedpublic double getDoubleValue(String fieldName)
Nodedouble.
This function attempts to convert the value to a double.
Numeric fields are simply converted. Double may be truncated.
Boolean fields return 0.0 if false, and 1.0 if true.
String fields are parsed.
If a parsed string contains an error, ot the field value is not of a type that can be converted
(i.e. a byte array), this function returns -1.0.getDoubleValue in interface NodegetDoubleValue in class AbstractNodefieldName - the name of the field to be returnedpublic byte[] getByteValue(String fieldName)
Nodebyte array.
This function returns either the value of a byte field, or the byte value of a string
(converted using the default encoding, i.e. UTF8)
Other types of values return an empty byte-array.getByteValue in interface NodegetByteValue in class AbstractNodefieldName - the name of the field to be returnedpublic InputStream getInputStreamValue(String fieldName)
Nodejava.io.InputStream This is
especially useful for large byte-array fields. By this you can avoid them to be completely
stored in memory.getInputStreamValue in interface NodegetInputStreamValue in class AbstractNodefieldName - the name of the fieldpublic String getStringValue(String fieldName)
NodeString.
Byte arrays are converted to string using the default encoding (UTF8).
Node values return a string representation of their numeric key.
For other values the result is calling the toString() method on the actual object.getStringValue in interface NodegetStringValue in class AbstractNodefieldName - the name of the field to be returnedpublic Document getXMLValue(String fieldName)
Nodedom.Document
If the node value is not itself a Document, the method attempts to
attempts to convert the String value into an XML.
This included the empty string, but not the 'null' value.
If the value is null, this method returns nullgetXMLValue in interface NodegetXMLValue in class AbstractNodefieldName - the name of the field to be returnednullpublic void commit()
BasicCloud.afterCommit(BasicNode)commit in interface Nodecommit in class AbstractNodepublic void cancel()
Nodecancel in interface Nodecancel in class AbstractNodepublic void delete(boolean deleteRelations)
Nodedelete in interface Nodedelete in class AbstractNodedeleteRelations - a boolean. If true, then first all
existing relations with this node will be removed.public String toString()
Nodepublic void deleteRelations(String type) throws NotFoundException
NodedeleteRelations in interface NodedeleteRelations in class AbstractNodetype - the name of the relation manager the removed
relation nodes should haveNotFoundExceptionpublic RelationList getRelations(String role, String otherNodeManager) throws NotFoundException
NodegetRelations in interface NodegetRelations in class AbstractNoderole - the name of the role the returned
relation nodes should haveotherNodeManager - the name of the nodemanager for the nodes the returned
relation nodes should have a relation toNotFoundExceptionpublic RelationList getRelations(String role, NodeManager nodeManager, String searchDir) throws NotFoundException
getRelations in interface NodegetRelations in class AbstractNoderole - role of the relationnodeManager - node manager on the other side of the relationsearchDir - direction of the relationNotFoundException - See Queries.createRelationNodesQuery(Node, NodeManager, String, String)
Should perhaps be implemented with thatpublic boolean hasRelations()
NodehasRelations in interface NodehasRelations in class AbstractNodetrue if the node has relationspublic int countRelatedNodes(NodeManager otherNodeManager, String role, String direction)
countRelatedNodes in interface NodecountRelatedNodes in class AbstractNodeotherNodeManager - the node manager the nodes should haverole - the role of the relationdirection - the direction of the relationprotected NodeList getRelatedNodes(NodeManager otherManager, String role)
otherManager - nodemanager on the other side of the relationrole - name of the relationpublic NodeList getRelatedNodes(NodeManager otherManager, String role, String searchDir)
NodegetRelatedNodes in interface NodegetRelatedNodes in class AbstractNodeotherManager - node manager on the other side of the relationrole - role of the relationsearchDir - direction of the relationShould perhaps be implemented with that.public int countRelatedNodes(String type)
NodecountRelatedNodes in interface NodecountRelatedNodes in class AbstractNodetype - the name of the node manager the counted nodes
should havepublic StringList getAliases()
NodegetAliases in interface NodegetAliases in class AbstractNodepublic void createAlias(String aliasName)
NodecreateAlias in interface NodecreateAlias in class AbstractNodealiasName - the alias to be created for this nodepublic void deleteAlias(String aliasName)
NodedeleteAlias in interface NodedeleteAlias in class AbstractNodealiasName - the alias to be removed for this nodepublic void setContext(String context)
NodesetContext in interface NodesetContext in class AbstractNodecontext - The security context to which this node should belong,public String getContext()
NodegetContext in interface NodegetContext in class AbstractNodepublic StringList getPossibleContexts()
NodegetPossibleContexts in interface NodegetPossibleContexts in class AbstractNodepublic boolean mayWrite()
NodemayWrite in interface NodemayWrite in class AbstractNodepublic boolean mayDelete()
NodemayDelete in interface NodemayDelete in class AbstractNodepublic boolean mayChangeContext()
NodemayChangeContext in interface NodemayChangeContext in class AbstractNodeprotected void finalize()
public Collection<Function<?>> getFunctions()
AbstractNodeNode.getNodeManager().Node.getFunctions().getFunctions in interface NodegetFunctions in class AbstractNodeFunction objects.protected Function<?> getNodeFunction(String functionName)
AbstractNodeAbstractNode.getFunctions().getNodeFunction in class AbstractNodepublic Parameters createParameters(String functionName)
NodecreateParameters in interface NodecreateParameters in class AbstractNodefunctionName - name of the functionParameters object.protected FieldValue createFunctionValue(Object result)
createFunctionValue in class AbstractNodeMMBase 1.9-SNAPSHOT - ${javadoctimestamp}