|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||

java.lang.Objectorg.mmbase.module.core.MMObjectNode
public class MMObjectNode
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)
| Field Summary | |
|---|---|
Set<String> |
aliases
New aliases of the node |
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. |
(package private) MMObjectBuilder |
oldBuilder
|
protected MMObjectBuilder |
parent
Pointer to the parent builder that is responsible for this node. |
long |
sequence
|
static String |
VALUE_SHORTED
Large fields (blobs) are loaded 'lazily', so only on explicit request. |
protected Map<String,Object> |
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<String,Object> 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)
|
protected Object |
checkSerializable(String fieldName,
Object fieldValue)
MMObjectNode's are serializable (which is used by e.g. |
boolean |
clearChanged()
Clear the 'signal' Vector with the changed keys since last commit/insert. |
MMObjectNode |
clone()
|
boolean |
commit()
Commit the node to the database or other storage system. |
boolean |
commit(UserContext user)
Commit this node to the storage |
int |
compareTo(MMObjectNode n)
|
Parameters |
createParameters(String functionName)
|
boolean |
defaultEquals(MMObjectNode n)
|
(package private) String |
defaultToString()
|
void |
delPropertiesCache()
Deletes the propertie cache for this node. |
void |
delRelationsCache()
Delete the relation cache for this node. |
static void |
delRelationsCache(Integer number)
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<MMObjectNode> |
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()
|
int |
getByteSize(SizeOf sizeof)
|
byte[] |
getByteValue(String fieldName)
Get a binary value of a certain field. |
Set<String> |
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<Function<?>> |
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. |
MMObjectBuilder |
getOldBuilder()
Returns the original builder after setBuilder(org.mmbase.module.core.MMObjectBuilder). |
Map<String,Object> |
getOldValues()
This can be modified by other users of this object though. |
int |
getOType()
Retrieve an object's object type. |
Set<String> |
getPossibleContexts(UserContext user)
Returns the possible new security contexts for this node |
Map<String,MMObjectNode> |
getProperties()
Return a the properties for this node. |
MMObjectNode |
getProperty(String key)
Returns a specified property of this node. |
Vector<MMObjectNode> |
getRelatedNodes()
Get all related nodes. |
Vector<MMObjectNode> |
getRelatedNodes(String type)
Get the related nodes of a certain type. |
Vector<MMObjectNode> |
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<MMObjectNode> |
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. |
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<MMObjectNode> |
getRelationNodes()
|
Enumeration<MMObjectNode> |
getRelations()
Return the relations of this node. |
Enumeration<MMObjectNode> |
getRelations(int otype)
Return the relations of this node, filtered on a specified type. |
Enumeration<MMObjectNode> |
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<String,Object> |
getValues()
Returns an (unmodifiable) map representing all key/values present in this node. |
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(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 |
setBuilder(MMObjectBuilder bul)
|
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,
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)
|
(package private) void |
useAliases()
|
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String VALUE_SHORTED
storeValue(java.lang.String, java.lang.Object), to unload the field again.
protected Map<String,Object> values
protected boolean initializing
start() to start initializing, use finish() to end.
protected MMObjectBuilder parent
getBuilder() instead.
protected boolean isNew
true, the node is a new node, which is not (yet) stored in storage.
public Set<String> aliases
MMObjectBuilder oldBuilder
public long sequence
| Constructor Detail |
|---|
public MMObjectNode(MMObjectBuilder parent)
parent - the node's parent, an instance of the node's builder.
IllegalArgumentException - If parent is null
public MMObjectNode(MMObjectBuilder parent,
boolean isNew)
parent - the node's parent, an instance of the node's builder.isNew - if the node is a newly created node
IllegalArgumentException - If parent is nullpublic MMObjectNode(MMObjectNode node)
public MMObjectNode(MMObjectBuilder parent,
Map<String,Object> map)
NodeMap).
| Method Detail |
|---|
public MMObjectBuilder getBuilder()
public MMObjectBuilder getOldBuilder()
setBuilder(org.mmbase.module.core.MMObjectBuilder).
public void setBuilder(MMObjectBuilder bul)
public void start()
public void finish()
public void testValidData()
throws InvalidDataException
InvalidDataException - If the data was unrecoverably invalid (the references did not point to existing objects)public boolean commit()
true if the commit was succesfull, false is it failedpublic void cancel()
public int insert(String userName)
userName - the name of the user who inserts the node. This value is ignored
public int insert(UserContext user)
user - the user who inserts the node.
Used to set security-related information
public boolean commit(UserContext user)
user - the user who commits the node.
Used to set security-related information
true if successfulpublic void remove(UserContext user)
user - the user who removes the node.
Used to set security-related information
public void setContext(UserContext user,
String context,
boolean now)
user - the user who changes the context of the node.context - the new contextnow - if true, the context is changed instantly, otherwise it is changed
after the node is send to storage.public String getContext(UserContext user)
user - the user who requests the context of the node.public Set<String> getPossibleContexts(UserContext user)
user - the user who requests the context of the node.public String toString()
toString in class ObjectString defaultToString()
protected boolean checkFieldExistance(String fieldName)
true if field exists and may be used.
protected final Object checkSerializable(String fieldName,
Object fieldValue)
public void storeValue(String fieldName,
Object fieldValue)
setValue(java.lang.String, java.lang.Object) to change fields.
fieldName - the name of the field to changefieldValue - the value to assignpublic Object retrieveValue(String fieldName)
getValue(java.lang.String) to load fields.
fieldName - the name of the field to change
public boolean isVirtual()
public boolean isNew()
insert(String), and otherwise with commit().
protected Document toXML(Object value,
String fieldName)
public boolean setValue(String fieldName,
Object fieldValue)
fieldName - the name of the field to changefieldValue - the value to assign
true When the field was changed, false otherwise.
public void setSize(String fieldName,
long size)
getSize(String)public long getSize(String fieldName)
public int getNumber()
public int getOType()
public boolean isNull(String fieldName)
public Object getValue(String fieldName)
fieldName - the name of the field who's data to return
Objectpublic String getStringValue(String fieldName)
fieldName - the name of the field who's data to return
String
public Object getFunctionValue(String functionName,
List<?> parameters)
public Parameters createParameters(String functionName)
public Function<?> getFunction(String functionName)
public Collection<Function<?>> getFunctions()
public Document getXMLValue(String fieldName)
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
fieldName - the name of the field to be returned
null
IllegalArgumentException - if the value cannot be converted.public byte[] getByteValue(String fieldName)
fieldName - the name of the field who's data to return
byte [] (binary/blob field)public InputStream getInputStreamValue(String fieldName)
public MMObjectNode getNodeValue(String fieldName)
null.
fieldName - the name of the field who's data to return
intpublic int getIntValue(String fieldName)
fieldName - the name of the field who's data to return
intpublic boolean getBooleanValue(String fieldName)
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.
fieldName - the name of the field who's data to return
intpublic Integer getIntegerValue(String fieldName)
fieldName - the name of the field who's data to return
Integerpublic long getLongValue(String fieldName)
fieldName - the name of the field who's data to return
longgetValue(java.lang.String),
Casting.toLong(java.lang.Object, long)public float getFloatValue(String fieldName)
fieldName - the name of the field who's data to return
floatpublic double getDoubleValue(String fieldName)
fieldName - the name of the field who's data to return
doublepublic Date getDateValue(String fieldName)
fieldName - the name of the field who's data to return
Datepublic List getListValue(String fieldName)
fieldName - the name of the field who's data to return
Listpublic int getDBType(String fieldName)
fieldName - the name of the field which' type to return
public int getDBState(String fieldName)
fieldName - the name of the field who's state to return
public Set<String> getChanged()
public boolean isChanged()
true if changes have been made, false otherwisepublic boolean clearChanged()
truepublic void delPropertiesCache()
public Map<String,Object> getValues()
Collections.synchronizedMap(java.util.Map) ).
public Map<String,Object> getOldValues()
Collections.synchronizedMap(java.util.Map) ).
public Map<String,MMObjectNode> getProperties()
Mappublic MMObjectNode getProperty(String key)
key - the name of the property to retrieve
MMObjectNodepublic void putProperty(MMObjectNode node)
node - the property object as a MMObjectNodepublic String getGUIIndicator()
Stringpublic String getName()
public void delRelationsCache()
public static void delRelationsCache(Integer number)
number - nodenumberpublic boolean hasRelations()
true if any relations exist, false otherwise.public Enumeration<MMObjectNode> getAllRelations()
Enumeration containing the nodespublic Enumeration<MMObjectNode> getRelations()
Enumeration containing the nodesprotected List<MMObjectNode> getRelationNodes()
public void removeRelations()
public int getRelationCount()
int indicating the number of nodes foundpublic Enumeration<MMObjectNode> getRelations(int otype)
otype - the 'type' of relations to return. The type identifies a relation (InsRel-derived) builder, not a reldef object.
Enumeration containing the nodespublic Enumeration<MMObjectNode> getRelations(String wantedtype)
wantedtype - the 'type' of relations to return. The type identifies a relation (InsRel-derived) builder, not a reldef object.
Enumeration containing the nodespublic int getRelationCount(String wt)
wt - the 'type' of related nodes (NOT the relations!).
int indicating the number of nodes foundpublic int getAge()
public boolean sendFieldChangeSignal(String fieldName)
fieldName - the name of the changed field.
truepublic void setAlias(String alias)
MMObjectBuilder.createAlias(int, String).
void useAliases()
public Vector<MMObjectNode> getRelatedNodes()
Vector containing MMObjectNodespublic Vector<MMObjectNode> getRelatedNodes(String type)
type - the type of objects to be returned
Vector containing MMObjectNodes
public Vector<MMObjectNode> getRelatedNodes(String type,
int search_type)
type - the type of teh realted node to returnsearch_type - the type of directionality to use
public Vector<MMObjectNode> getRelatedNodes(String type,
String role,
int search_type)
type - the type of the related node to returnrole - the role of the relation (null if no role specified)search_type - the type of directionality to usepublic int getByteSize()
getByteSize in interface SizeMeasurablepublic int getByteSize(SizeOf sizeof)
getByteSize in interface SizeMeasurablepublic int hashCode()
hashCode in class Objectpublic boolean equals(Object o)
equals in class Objectpublic boolean defaultEquals(MMObjectNode n)
public int compareTo(MMObjectNode n)
public MMObjectNode clone()
clone in interface PublicCloneable<MMObjectNode>clone in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||