|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mmbase.bridge.util.AbstractNode
org.mmbase.bridge.implementation.BasicNode
public class BasicNode
Basic implementation of Node. Wraps MMObjectNodes, adds security.
Node,
MMObjectNodeVirtualNode. They probably should share an ancestor (AbstractBasicNode or so) (MMB-1870)| Field Summary | |
|---|---|
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. |
| Fields inherited from interface org.mmbase.bridge.Node |
|---|
CLOUD_COMMITNODE_KEY |
| Constructor Summary | |
|---|---|
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. |
|
| Method Summary | |
|---|---|
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 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 |
| Methods inherited from class java.lang.Object |
|---|
clone, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.lang.Comparable |
|---|
compareTo |
| Field Detail |
|---|
protected BasicNodeManager nodeManager
protected final BasicCloud cloud
protected MMObjectNode noderef
protected MMObjectNode originalNoderef
protected int temporaryNodeId
| Constructor Detail |
|---|
BasicNode(BasicCloud cloud)
BasicNode(MMObjectNode node,
BasicNodeManager nodeManager)
node - the MMObjectNode to base the node onnodeManager - the NodeManager to use for administrating this Node
IllegalArgumentException - If node is null
BasicNode(MMObjectNode node,
BasicCloud cloud)
node - the MMObjectNode to base the node oncloud - the cloud to which this node belongs
IllegalArgumentException - If node is null
BasicNode(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 cloud| Method Detail |
|---|
protected void setNodeManager(MMObjectNode node)
node - node to derive nodemanager from.protected void init()
public int getByteSize()
SizeMeasurable
getByteSize in interface SizeMeasurablepublic int getByteSize(SizeOf sizeof)
SizeMeasurable
getByteSize 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()
Node
getCloud in interface Nodepublic NodeManager getNodeManager()
Node
getNodeManager in interface Nodepublic void setNodeManager(NodeManager nm)
Node
setNodeManager in interface NodesetNodeManager in class AbstractNodepublic int getNumber()
Node
getNumber in interface NodegetNumber in class AbstractNodeNode.createAlias(String alias)public boolean isNew()
isNew in interface NodeisNew in class AbstractNodepublic boolean isChanged(String fieldName)
Node
isChanged in interface NodeisChanged in class AbstractNodefieldName - the name of the field
true when field's value was changedpublic boolean isChanged()
Node
isChanged in interface NodeisChanged in class AbstractNodetrue when changedpublic Set<String> getChanged()
Node
getChanged in interface NodegetChanged in class AbstractNodeprotected void checkAccount()
protected void checkDelete()
protected void checkWrite()
AbstractNode
checkWrite 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)
AbstractNode
toNodeNumber in class AbstractNode
protected 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 field
true when value is nullpublic long getSize(String fieldName)
Node
getSize in interface NodefieldName - the name of the field
public Object getValueWithoutProcess(String fieldName)
getValueWithoutProcess in interface NodefieldName - name of field
public 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 returned
public Date getDateValue(String fieldName)
getDateValue in interface NodegetDateValue in class AbstractNodefieldName - the name of the field to be returned
public List getListValue(String fieldName)
getListValue in interface NodegetListValue in class AbstractNodefieldName - the name of the field to be returned
public 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 returned
Cloud.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 -1
getIntValue in interface NodegetIntValue in class AbstractNodefieldName - the name of the field to be returned
public 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 returned
public 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 -1
getLongValue in interface NodegetLongValue in class AbstractNodefieldName - the name of the field to be returned
public 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 returned
public 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 returned
public 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 field
public 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 returned
public 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 null
getXMLValue in interface NodegetXMLValue in class AbstractNodefieldName - the name of the field to be returned
nullpublic void commit()
BasicCloud.afterCommit(BasicNode)
commit in interface Nodecommit in class AbstractNodepublic void cancel()
Node
cancel in interface Nodecancel in class AbstractNodepublic void delete(boolean deleteRelations)
Node
delete in interface Nodedelete in class AbstractNodedeleteRelations - a boolean. If true, then first all
existing relations with this node will be removed.public String toString()
Node
toString in interface NodetoString in class Object
public void deleteRelations(String type)
throws NotFoundException
Node
deleteRelations in interface NodedeleteRelations in class AbstractNodetype - the name of the relation manager the removed
relation nodes should have
NotFoundException
public RelationList getRelations(String role,
String otherNodeManager)
throws NotFoundException
Node
getRelations 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 to
NotFoundException
public 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 relation
NotFoundException - See Queries.createRelationNodesQuery(Node, NodeManager, String, String)
Should perhaps be implemented with thatpublic boolean hasRelations()
Node
hasRelations in interface NodehasRelations in class AbstractNodetrue if the node has relations
public 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 relation
protected NodeList getRelatedNodes(NodeManager otherManager,
String role)
otherManager - nodemanager on the other side of the relationrole - name of the relation
public NodeList getRelatedNodes(NodeManager otherManager,
String role,
String searchDir)
Node
getRelatedNodes in interface NodegetRelatedNodes in class AbstractNodeotherManager - node manager on the other side of the relationrole - role of the relationsearchDir - direction of the relation
Should perhaps be implemented with that.public int countRelatedNodes(String type)
Node
countRelatedNodes in interface NodecountRelatedNodes in class AbstractNodetype - the name of the node manager the counted nodes
should have
public StringList getAliases()
Node
getAliases in interface NodegetAliases in class AbstractNodepublic void createAlias(String aliasName)
Node
createAlias in interface NodecreateAlias in class AbstractNodealiasName - the alias to be created for this nodepublic void deleteAlias(String aliasName)
Node
deleteAlias in interface NodedeleteAlias in class AbstractNodealiasName - the alias to be removed for this nodepublic void setContext(String context)
Node
setContext in interface NodesetContext in class AbstractNodecontext - The security context to which this node should belong,public String getContext()
Node
getContext in interface NodegetContext in class AbstractNodepublic StringList getPossibleContexts()
Node
getPossibleContexts in interface NodegetPossibleContexts in class AbstractNodepublic boolean mayWrite()
Node
mayWrite in interface NodemayWrite in class AbstractNodepublic boolean mayDelete()
Node
mayDelete in interface NodemayDelete in class AbstractNodepublic boolean mayChangeContext()
Node
mayChangeContext in interface NodemayChangeContext in class AbstractNodeprotected void finalize()
finalize in class Objectpublic Collection<Function<?>> getFunctions()
AbstractNodeNode.getNodeManager().Node.getFunctions().
getFunctions in interface NodegetFunctions in class AbstractNodeFunction objects.protected Function<?> getNodeFunction(String functionName)
AbstractNodegetFunctions.
getNodeFunction in class AbstractNodepublic Parameters createParameters(String functionName)
Node
createParameters in interface NodecreateParameters in class AbstractNodefunctionName - name of the function
Parameters object.protected FieldValue createFunctionValue(Object result)
createFunctionValue in class AbstractNode
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||