|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mmbase.module.core.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 | |
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. |
protected MMObjectBuilder |
parent
Pointer to the parent builder that is responsible for this node. |
Hashtable |
properties
Holds the 'extra' name-value pairs (the node's properties) which are retrieved from the 'properties' table. |
protected static RelatedNodesCache |
relatedCache
Results of getRelatedNodes |
protected static RelationsCache |
relationsCache
objectNumber -> List of all relation nodes |
static Object |
VALUE_NULL
Deprecated. Simply use null |
static String |
VALUE_SHORTED
Large fields (blobs) are loaded 'lazily', so only on explicit request. |
protected Map |
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 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)
|
boolean |
clearChanged()
Clear the 'signal' Vector with the changed keys since last commit/insert. |
boolean |
commit()
Commit the node to the database or other storage system. |
boolean |
commit(UserContext user)
Commit this node to the storage |
Parameters |
createParameters(String functionName)
|
boolean |
defaultEquals(MMObjectNode n)
|
void |
delPropertiesCache()
Deletes the propertie cache for this node. |
void |
delRelationsCache()
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 |
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()
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)
Get a binary value of a certain field. |
Set |
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 |
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. |
Map |
getOldValues()
|
int |
getOType()
Retrieve an object's object type. |
Set |
getPossibleContexts(UserContext user)
Returns the possible new security contexts for this node |
Hashtable |
getProperties()
Return a the properties for this node. |
MMObjectNode |
getProperty(String key)
Returns a specified property of this node. |
Vector |
getRelatedNodes()
Get all related nodes. |
Vector |
getRelatedNodes(String type)
Get the related nodes of a certain type. |
Vector |
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 |
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. |
static int |
getRelationCacheHits()
Deprecated. use RelationsCache.getCache().getHits() |
static int |
getRelationCacheMiss()
Deprecated. use RelationsCache.getCache().getMisses() |
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 |
getRelationNodes()
|
Enumeration |
getRelations()
Return the relations of this node. |
Enumeration |
getRelations(int otype)
Return the relations of this node, filtered on a specified type. |
Enumeration |
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 |
getValues()
|
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(java.lang.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 |
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,
boolean fieldValue)
Sets a key/value pair in the main values of this node. |
boolean |
setValue(String fieldName,
double fieldValue)
Sets a key/value pair in the main values of this node. |
boolean |
setValue(String fieldName,
int fieldValue)
Sets a key/value pair in the main values of this node. |
boolean |
setValue(String fieldName,
long fieldValue)
Sets a key/value pair in the main values of this node. |
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)
|
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final Object VALUE_NULL
null
public static final String VALUE_SHORTED
storeValue(java.lang.String, java.lang.Object), to unload the field again.
protected static final RelatedNodesCache relatedCache
protected static final RelationsCache relationsCache
protected Map values
protected boolean initializing
start() to start initializing, use finish() to end.
public Hashtable properties
protected MMObjectBuilder parent
getBuilder() instead.
protected boolean isNew
true, the node is a new node, which is not (yet) stored in storage.
| 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 map)
NodeMap).
| Method Detail |
public static int getRelationCacheHits()
public static int getRelationCacheMiss()
public MMObjectBuilder getBuilder()
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 succesfulpublic 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 getPossibleContexts(UserContext user)
user - the user who requests the context of the node.public String toString()
protected boolean checkFieldExistance(String fieldName)
true if field exists and may be used.
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(java.lang.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 boolean setValue(String fieldName,
boolean fieldValue)
boolean.
Note that if this node is a node in cache, the changes are immediately visible to
everyone, even if the changes are not committed.
The fieldName is added to the (public) 'changed' vector to track changes.
fieldName - the name of the field to changefieldValue - the value to assign
true
public boolean setValue(String fieldName,
int fieldValue)
int.
Note that if this node is a node in cache, the changes are immediately visible to
everyone, even if the changes are not committed.
The fieldName is added to the (public) 'changed' vector to track changes.
fieldName - the name of the field to changefieldValue - the value to assign
true
public boolean setValue(String fieldName,
long fieldValue)
int.
Note that if this node is a node in cache, the changes are immediately visible to
everyone, even if the changes are not committed.
The fieldName is added to the (public) 'changed' vector to track changes.
fieldName - the name of the field to changefieldValue - the value to assign
true
public boolean setValue(String fieldName,
double fieldValue)
double.
Note that if this node is a node in cache, the changes are immediately visible to
everyone, even if the changes are not committed.
The fieldName is added to the (public) 'changed' vector to track changes.
fieldName - the name of the field to changefieldValue - the value to assign
truepublic 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 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 getChanged()
public boolean isChanged()
true if changes have been made, false otherwisepublic boolean clearChanged()
truepublic void delPropertiesCache()
public Map getValues()
public Map getOldValues()
public Hashtable getProperties()
Hashtablepublic 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 boolean hasRelations()
true if any relations exist, false otherwise.public Enumeration getAllRelations()
Enumeration containing the nodespublic Enumeration getRelations()
Enumeration containing the nodesprotected List getRelationNodes()
public void removeRelations()
public int getRelationCount()
int indicating the number of nodes foundpublic Enumeration 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 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, java.lang.String, java.lang.String).
public Vector getRelatedNodes()
Vector containing MMObjectNodespublic Vector getRelatedNodes(String type)
type - the type of objects to be returned
Vector containing MMObjectNodes
public Vector getRelatedNodes(String type,
int search_type)
type - the type of teh realted node to returnsearch_type - the type of directionality to use
public Vector getRelatedNodes(String type,
String role,
int search_type)
type - the type of teh realted node to returnrole - the role of the relation (null if no role specified)search_type - the type of directionality to usepublic int getByteSize()
SizeMeasurable
getByteSize in interface SizeMeasurablepublic int getByteSize(SizeOf sizeof)
SizeMeasurable
getByteSize in interface SizeMeasurablepublic int hashCode()
public boolean equals(Object o)
public boolean defaultEquals(MMObjectNode n)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||