public abstract class AbstractNode extends Object implements Node
NodeCLOUD_COMMITNODE_KEY| Constructor and Description |
|---|
AbstractNode() |
| 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 |
checkWrite()
Throws exception if may not write current node
|
void |
commit()
Commit the node to the database.
|
int |
compareTo(Node o)
Compares this node to the passed object.
|
int |
countRelatedNodes(NodeManager otherNodeManager,
String role,
String direction) |
int |
countRelatedNodes(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(String type)
Returns the number of relation nodes attached to this node that have a
specific relation 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.
|
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(String aliasName)
Delete an alias for this node.
|
void |
deleteRelations()
Removes all relation nodes attached to this node.
|
void |
deleteRelations(String type)
Removes all relation nodes with a certain relation manager that are
attached to this node.
|
boolean |
equals(Object o)
Compares two nodes, and returns true if they are equal.
|
StringList |
getAliases()
Returns all aliases for this node.
|
boolean |
getBooleanValue(String fieldName)
Returns the value of the specified field as a
boolean. |
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.
|
String |
getContext()
Get the security context of the current Node
|
Date |
getDateValue(String fieldName) |
BigDecimal |
getDecimalValue(String fieldName) |
double |
getDoubleValue(String fieldName)
Returns the value of the specified field as a
double. |
FieldValue |
getFieldValue(Field field)
Returns the value of the specified field as a
FieldValue object. |
FieldValue |
getFieldValue(String fieldName)
Returns the value of the specified field as a
FieldValue object. |
float |
getFloatValue(String fieldName)
Returns the value of the specified field as a
float. |
<R> Function<R> |
getFunction(String functionName)
Returns a Fuction object.
|
protected Map<String,Function<?>> |
getFunctionMap()
Wraps
getFunctions() in a Map |
Collection<Function<?>> |
getFunctions()
This default implementation is based on
Node.getNodeManager().Node.getFunctions(). |
FieldValue |
getFunctionValue(String functionName,
List<?> parameters)
Returns the value of the specified function on the node.
|
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 Function<?> |
getNodeFunction(String functionName)
Based on
getFunctions(). |
Node |
getNodeValue(String fieldName)
Returns the value of the specified field as a
Node. |
int |
getNumber()
Returns the unique number for this node.
|
Object |
getObjectValue(String fieldName)
Returns the field's value as an object.
|
StringList |
getPossibleContexts()
Contacts the security implementation to find out to which other possible contexts the
context of this node may be set.
|
NodeList |
getRelatedNodes()
Returns all related nodes.
|
NodeList |
getRelatedNodes(NodeManager nodeManager)
Returns all related nodes that have a specific node manager.
|
NodeList |
getRelatedNodes(NodeManager nodeManager,
String role,
String searchDir)
Returns all related nodes that have a specific node manager and role.
|
NodeList |
getRelatedNodes(String type)
Returns all related nodes that have a specific node manager.
|
NodeList |
getRelatedNodes(String type,
String role,
String searchDir)
Returns all related nodes that have a specific node manager and role.
|
RelationList |
getRelations()
Returns all relation nodes attached to this node.
|
RelationList |
getRelations(String role)
Returns all relation nodes attached to this node that have a specific
role
|
RelationList |
getRelations(String role,
NodeManager nodeManager)
Returns all relation nodes attached to this node that have a specific
role, or refer a node from a specific nodemanager
|
RelationList |
getRelations(String role,
NodeManager nodeManager,
String searchDir) |
RelationList |
getRelations(String role,
String nodeManager)
Returns all relation nodes attached to this node that have a specific
role, or refer a node from a specific nodemanager
|
String |
getStringValue(String fieldName)
Returns the value of the specified field as a
String. |
Object |
getValue(String fieldName)
Returns the value of the specified field as an object.
|
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. |
Element |
getXMLValue(String fieldName,
Document tree)
Returns the value of the specified field as a
dom.Element
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()
Checks whether this node has any relations.
|
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()
Whether this Node is new (not yet committed).
|
boolean |
isNodeManager()
Determine whether this Node is a NodeManager.
|
boolean |
isNull(String fieldName)
Whether the value for the specified field is
null. |
boolean |
isRelation()
Determine whether this Node is a Relation.
|
boolean |
isRelationManager()
Determine whether this Node is a RelationManager.
|
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.
|
protected Object |
processNull(int type,
Field field) |
void |
setBooleanValue(String fieldName,
boolean value)
Sets the value of the specified field using an
boolean. |
void |
setByteValue(String fieldName,
byte[] value)
Sets the value of the specified field using a
byte array. |
void |
setContext(String context)
Sets the security context of this Node (AKA the 'owner' field)
|
void |
setDateValue(String fieldName,
Date value)
Sets the value of the specified field using a
Date. |
void |
setDecimalValue(String fieldName,
BigDecimal value)
Sets the value of the specified field using a
BigDecimal. |
void |
setDoubleValue(String fieldName,
double value)
Sets the value of the specified field using a
double. |
void |
setFloatValue(String fieldName,
float value)
Sets the value of the specified field using a
float. |
void |
setInputStreamValue(String fieldName,
InputStream value,
long size)
Sets the value of the specified field using a
java.io.InputStream. |
void |
setIntValue(String fieldName,
int value)
Sets the value of the specified field using an
int. |
void |
setListValue(String fieldName,
List value)
Sets the value of the specified field using a
List. |
void |
setLongValue(String fieldName,
long value)
Sets the value of the specified field using a
long. |
void |
setNodeManager(NodeManager nm)
Sets the node manager of this node.
|
void |
setNodeValue(String fieldName,
Node value)
Sets the value of the specified field using an
Node. |
void |
setObjectValue(String fieldName,
Object value)
Sets the value of the specified field using an object, but without dispatching to the right
type first.
|
protected abstract void |
setSize(String fieldName,
long size) |
void |
setStringValue(String fieldName,
String value)
Sets the value of the specified field using a
String. |
void |
setValue(String fieldName,
Object value)
Setting value with default method (depending on field's type)
|
protected abstract void |
setValueWithoutChecks(String fieldName,
Object value) |
void |
setValueWithoutProcess(String fieldName,
Object value)
Like setObjectValue, but without processing, this is called by the other set-values.
|
void |
setXMLValue(String fieldName,
Document value)
Set's the value of the specified field as a
dom.Element |
NodeManager |
toNodeManager()
Returns this as a NodeManager.
|
protected Integer |
toNodeNumber(Object v)
A method to convert an object to an node number.
|
Relation |
toRelation()
Returns this as a Relation.
|
RelationManager |
toRelationManager()
Returns this as a RelationManager.
|
Collection<String> |
validate()
Validates a node by checking the values from it's fields against the constraints of
each field's datatype.
|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitgetCloud, getNodeManager, getSize, getValueWithoutProcess, toStringpublic boolean isRelation()
NodeisRelation in interface Nodetrue if this Node is a Relation.public Relation toRelation()
NodetoRelation in interface NodeRelation objectpublic boolean isNodeManager()
NodeisNodeManager in interface Nodetrue if this Node is a NodeManager.public NodeManager toNodeManager()
NodetoNodeManager in interface NodeNodeManager objectpublic boolean isRelationManager()
NodeisRelationManager in interface Nodetrue if this Node is a RelationManager.public RelationManager toRelationManager()
NodetoRelationManager in interface NodeNodeManager objectpublic boolean isNull(String fieldName)
Nodenull. This avoids acquiring the
complete value if you only want to check if for emptiness.public int getNumber()
NodegetNumber in interface NodeNode.createAlias(String alias)public final void setValue(String fieldName, Object value)
protected void checkWrite()
public void setValueWithoutProcess(String fieldName, Object value)
setValueWithoutProcess in interface NodefieldName - name of fieldvalue - new value of the fieldpublic final void setObjectValue(String fieldName, Object value)
NodesetObjectValue in interface NodefieldName - the name of the field to be updatedvalue - the new value for the given fieldpublic final void setBooleanValue(String fieldName, boolean value)
Nodeboolean.
This change will not be visible to the cloud until the commit method is
called.setBooleanValue in interface NodefieldName - the name of the field to be updatedvalue - the new value for the given fieldpublic final void setDateValue(String fieldName, Date value)
NodeDate.
This change will not be visible to the cloud until the commit method is
called.setDateValue in interface NodefieldName - the name of the field to be updatedvalue - the new value for the given fieldpublic final void setDecimalValue(String fieldName, BigDecimal value)
NodeBigDecimal.
This change will not be visible to the cloud until the commit method is
called.setDecimalValue in interface NodefieldName - the name of the field to be updatedvalue - the new value for the given fieldpublic final void setListValue(String fieldName, List value)
NodeList.
This change will not be visible to the cloud until the commit method is
called.setListValue in interface NodefieldName - the name of the field to be updatedvalue - the new value for the given field
// not yet workingprotected Integer toNodeNumber(Object v)
public final void setNodeValue(String fieldName, Node value)
NodeNode.
This change will not be visible to the cloud until the commit method is
called.setNodeValue in interface NodefieldName - the name of the field to be updatedvalue - the new value for the given fieldpublic final void setIntValue(String fieldName, int value)
Nodeint.
This change will not be visible to the cloud until the commit method is
called.setIntValue in interface NodefieldName - the name of the field to be updatedvalue - the new value for the given fieldpublic final void setLongValue(String fieldName, long value)
Nodelong.
This change will not be visible to the cloud until the commit method is
called.setLongValue in interface NodefieldName - the name of the field to be updatedvalue - the new value for the given fieldpublic final void setFloatValue(String fieldName, float value)
Nodefloat.
This change will not be visible to the cloud until the commit method is
called.setFloatValue in interface NodefieldName - the name of the field to be updatedvalue - the new value for the given fieldpublic final void setDoubleValue(String fieldName, double value)
Nodedouble.
This change will not be visible to the cloud until the commit method is
called.setDoubleValue in interface NodefieldName - the name of the field to be updatedvalue - the new value for the given fieldpublic final void setByteValue(String fieldName, byte[] value)
Nodebyte array.
This change will not be visible to the cloud until the commit method is
called.setByteValue in interface NodefieldName - the name of the field to be updatedvalue - the new value for the given fieldprotected abstract void setSize(String fieldName, long size)
public final void setInputStreamValue(String fieldName, InputStream value, long size)
Nodejava.io.InputStream.setInputStreamValue in interface NodefieldName - the name of the field to be updatedvalue - the new value for the given fieldsize - size of input streampublic final void setStringValue(String fieldName, String value)
NodeString.
This change will not be visible to the cloud until the commit method is
called.setStringValue in interface NodefieldName - the name of the field to be updatedvalue - the new value for the given fieldpublic final void setXMLValue(String fieldName, Document value)
Nodedom.ElementsetXMLValue in interface NodefieldName - the name of the field to be returnedvalue - the DOM Document to has to be set, if not correct doc-type,
system will try to convert it to the wanted type.public final Object getValue(String fieldName)
Nodeint is returned as an Integer.
The object type may vary and is dependent on how data was stored in a field.
I.e. It may be possible for an Integer field to return it's value as a String
if it was stored that way in the first place.public final Object getObjectValue(String fieldName)
NodegetObjectValue in interface NodefieldName - name of the 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 NodefieldName - the name of the field to be returnedpublic Date getDateValue(String fieldName)
getDateValue in interface NodefieldName - the name of the field to be returnedpublic BigDecimal getDecimalValue(String fieldName)
getDecimalValue in interface NodefieldName - the name of the field to be returnedpublic List getListValue(String fieldName)
getListValue in interface NodefieldName - the name of the field to be returnedpublic 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 NodefieldName - 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 NodefieldName - 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 NodefieldName - 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 NodefieldName - 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 NodefieldName - 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 NodefieldName - 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 NodefieldName - 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 NodefieldName - the name of the field to be returnednullpublic 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 NodefieldName - the name of the field to be returnedCloud.getList(String, String, String, String, String, String, String, boolean)public final FieldValue getFieldValue(String fieldName) throws NotFoundException
NodeFieldValue object.getFieldValue in interface NodefieldName - the name of the field whose value to returnNotFoundException - is the field does not exist and MMBase 'in development'
(i.e. strict mode)public final FieldValue getFieldValue(Field field)
NodeFieldValue object.getFieldValue in interface Nodefield - the Field object whose value to returnpublic final Element getXMLValue(String fieldName, Document tree)
Nodedom.Element
If the node value is not itself a Document, the method attempts to
attempts to convert the String value into an XML.
This method fails (throws a IllegalArgumentException) if the Field is not of type TYPE_XML.
If the value cannot be converted, this method returns nullgetXMLValue in interface NodefieldName - the name of the field to be returnedtree - the DOM Document to which the Element is added
(as the document root element)nullpublic Collection<String> validate()
NodeNode.commit() method, after commit processors are run.
Note that because commit processors may make necessary changes to field values, it is possible for
validate() to fail when used outside the commit process if the constraints are set too strict.public final void delete()
Nodepublic final void deleteRelations()
NodedeleteRelations in interface Nodepublic final RelationList getRelations()
NodegetRelations in interface Nodepublic final RelationList getRelations(String role)
NodegetRelations in interface Noderole - the name of the role the returned
relation nodes should havepublic final RelationList getRelations(String role, NodeManager nodeManager)
NodegetRelations in interface Noderole - the name of the role the returned
relation nodes should havenodeManager - the nodemanager for the nodes the returned
relation nodes should have a relation to (can be null)public final int countRelations()
NodecountRelations in interface Nodepublic final int countRelations(String type)
NodecountRelations in interface Nodetype - relation managerpublic final NodeList getRelatedNodes()
NodegetRelatedNodes in interface Nodepublic final NodeList getRelatedNodes(String type)
NodegetRelatedNodes in interface Nodetype - the name of the node manager the returned nodes
should havepublic final NodeList getRelatedNodes(NodeManager nodeManager)
NodegetRelatedNodes in interface NodenodeManager - the node manager the returned nodes should have, can be nullpublic final NodeList getRelatedNodes(String type, String role, String searchDir)
NodegetRelatedNodes in interface Nodetype - the name of the node manager the returned nodes
should haverole - the role of the relationsearchDir - the direction of the relationpublic Relation createRelation(Node destinationNode, RelationManager relationManager)
NodecreateRelation in interface NodedestinationNode - the node to which you want to relate this noderelationManager - the relation manager you want to usepublic final int compareTo(Node o)
compareTo in interface Comparable<Node>o - the object to compare it withpublic boolean isNew()
Nodepublic boolean isChanged(String fieldName)
Nodepublic boolean isChanged()
Nodepublic Set<String> getChanged()
NodegetChanged in interface Nodepublic void commit()
Nodepublic void cancel()
Nodepublic void delete(boolean deleteRelations)
Nodepublic void deleteRelations(String type) throws NotFoundException
NodedeleteRelations in interface Nodetype - the name of the relation manager the removed
relation nodes should haveNotFoundExceptionpublic RelationList getRelations(String role, NodeManager nodeManager, String searchDir) throws NotFoundException
getRelations in interface Noderole - forward role of a relationnodeManager - node manager on the other side of the relationsearchDir - the direction of the relationNotFoundExceptionpublic RelationList getRelations(String role, String nodeManager) throws NotFoundException
NodegetRelations in interface Noderole - the name of the role the returned
relation nodes should havenodeManager - the name of the nodemanager for the nodes the returned
relation nodes should have a relation toNotFoundExceptionpublic boolean hasRelations()
NodehasRelations in interface Nodetrue if the node has relationspublic int countRelatedNodes(NodeManager otherNodeManager, String role, String direction)
countRelatedNodes in interface NodeotherNodeManager - the node manager the nodes should haverole - the role of the relationdirection - the direction of the relationpublic int countRelatedNodes(String type)
NodecountRelatedNodes in interface Nodetype - the name of the node manager the counted nodes
should havepublic NodeList getRelatedNodes(NodeManager nodeManager, String role, String searchDir)
NodegetRelatedNodes in interface NodenodeManager - the node manager the returned nodes should haverole - the role of the relationsearchDir - the direction of the relationpublic StringList getAliases()
NodegetAliases in interface Nodepublic void createAlias(String aliasName)
NodecreateAlias in interface NodealiasName - the alias to be created for this nodepublic void deleteAlias(String aliasName)
NodedeleteAlias in interface NodealiasName - the alias to be removed for this nodepublic void setContext(String context)
NodesetContext in interface Nodecontext - The security context to which this node should belong,public String getContext()
NodegetContext in interface Nodepublic StringList getPossibleContexts()
NodegetPossibleContexts in interface Nodepublic boolean mayWrite()
Nodepublic boolean mayDelete()
Nodepublic boolean mayChangeContext()
NodemayChangeContext in interface Nodepublic final boolean equals(Object o)
equals in class Objecto - the object to compare it withObject.equals(java.lang.Object)public Parameters createParameters(String functionName)
NodecreateParameters in interface NodefunctionName - name of the functionParameters object.protected FieldValue createFunctionValue(Object result)
public FieldValue getFunctionValue(String functionName, List<?> parameters)
NodegetFunctionValue in interface NodefunctionName - name of the functionparameters - list with parameters for the fucntionprotected final Map<String,Function<?>> getFunctionMap()
getFunctions() in a Mappublic Collection<Function<?>> getFunctions()
Node.getNodeManager().Node.getFunctions().getFunctions in interface NodeFunction objects.protected Function<?> getNodeFunction(String functionName)
getFunctions().public <R> Function<R> getFunction(String functionName)
NodeFunction object.
You need to explixitly cast the result to this object, since not all bridge
implementations (i.e. the RMMCI) support this class.getFunction in interface NodefunctionName - name of the functionFunction object.public void setNodeManager(NodeManager nm)
NodesetNodeManager in interface NodeMMBase 1.9-SNAPSHOT - ${javadoctimestamp}