org.mmbase.module.core
Class MMObjectBuilder

java.lang.Object
  |
  +--org.mmbase.module.core.MMTable
        |
        +--org.mmbase.module.core.MMObjectBuilder
Direct Known Subclasses:
Articles, Attachments, BugReports, Cameras, Cassettes, CDs, Channel, Community, Cookies, CopyServices, DayMarkers, Dummy, Email, FieldDef, floppydrvs, Forums, ImageAliases, ImageCaches, Images, InsRel, Jumpers, MediaInputs, MediaOutputs, MediaParts, Message, MMEvents, MMServers, MultiRelations, Netfiles, NetFileSrv, OAlias, PCCards, People, PoolBuilder, Properties, Question, Quote, RAStatistics, RawAudios, RawVideos, RelDef, scanners, ServiceBuilder, Statistics, StatisticsShadow, Teasers, Todos, TypeDef, TypeRel, Urls, Users, Versions, VirtualBuilder, Vwms, Vwmtasks

public class MMObjectBuilder
extends MMTable

This class is the base class for all builders. It offers a list of routines which are useful in maintaining the nodes in the MMBase object cloud. Builders are the core of the MMBase system. They create, delete and search the MMObjectNodes. Most manipulations concern nodes of that builders type. However, a number of retrieval routines extend beyond a builders scope and work on the cloud in general, allowing some ease in retrieval of nodes. The basic routines in this class can be extended to handle more specific demands for nodes. Most of these 'extended builders' will be stored in mmbase.org.builders or mmbase.org.corebuilders. Examples include relation builders or builders for handling binary data such as images. The various builders are registered by the 'TypeDef' builder class (one of the core builders, itself an extension of this class).

Version:
$Revision: 1.115 $ $Date: 2002/02/14 12:32:33 $
Author:
Daniel Ockeloen, Rob Vermeulen, Pierre van Rooden, Eduard Witteveen, Johan Verelst

Field Summary
 boolean broadcastChanges
          Determines whether changes to this builder need be broadcasted to other known mmbase servers.
 java.lang.String className
          The classname as specified in the builder xml file mainly for use in export
static MMJdbc2NodeInterface database
          The class used to store and retrieve data in the database that is currently in use.
 boolean debug
          Deprecated. : use Logger routines instead
 java.lang.String description
          Description of the builder in the currently selected language Not that the first time the builder is created, this value is what is stored in the TypeDef table.
 java.util.Hashtable descriptions
          Descriptions of the builder per language Can be set with the <descriptions> tag in the xml builder file.
protected  java.util.Hashtable fields
           
static int NODE_MAX_SIZE
           
static LRUHashtable nodeCache
          The cache that contains the X last requested nodes X is currently set to 4096
static LRUHashtable obj2type
          The cache that contains the last X types of all requested objects X is currently set to 20000.
static int OBJ2TYPE_MAX_SIZE
           
 int oType
          The current builder's object type Retrieved from the TypeDef builder.
 boolean replaceCache
          Detemines whether the cache need be refreshed? Seems useless, as this value is never changed (always true)
 java.lang.String searchAge
          The default search age for this builder.
 java.util.Vector sortedDBLayout
          Contains the list of fieldnames as they used in the database.
static int TEMPNODE_DEFAULT_SIZE
           
static java.util.Hashtable TemporaryNodes
          Collection for temporary nodes, Used by the Temporarynodemanager when working with transactions The default size is 1024.
protected  boolean virtual
          Determines whether a builder is virtual (data is not stored in a database).
 
Fields inherited from class org.mmbase.module.core.MMTable
mmb, tableName
 
Constructor Summary
MMObjectBuilder()
          Constructor.
 
Method Summary
 void addField(FieldDefs def)
          Add a field to this builder.
 boolean addLocalObserver(MMBaseObserver obs)
          Adds a local observer to this builder.
 boolean addRemoteObserver(MMBaseObserver obs)
          Adds a remote observer to this builder.
 java.lang.String buildSet(java.util.Vector nodes, java.lang.String fieldName)
          Build a set command string from a set nodes ( should be moved )
 boolean checkAddTmpField(java.lang.String field)
          Defines a virtual field to use for temporary nodes
 boolean commit(MMObjectNode node)
          Commit changes to this node to the database.
 java.lang.String convertMMNode2SQL(java.lang.String where)
          Converts an MMNODE expression to SQL.
 int count(java.lang.String where)
          Count all the objects that match the searchkeys
 boolean create()
          Creates a new builder table in the current database.
 void createAlias(int number, java.lang.String alias)
          Creates an alias for a node, provided the OAlias builder is loaded.
 boolean created()
          Tests whether a builder table is created.
protected  void debug(java.lang.String msg)
          Debugging routine,sends message to log
 void deleteNodeCache()
          Delete the nodes cache.
protected  java.lang.Object executeFunction(MMObjectNode node, java.lang.String function, java.lang.String field)
          Executes a function on the field of a node, and returns the result.
 boolean fieldLocalChanged(java.lang.String number, java.lang.String builder, java.lang.String field, java.lang.String value)
          Called when a local field is changed.
 int getAge(MMObjectNode node)
          Return the age of the node, determined using the daymarks builder.
 MMObjectNode getAliasedNode(java.lang.String key)
          Deprecated. Use getNode(java.lang.String) instead.
 java.lang.String getCacheNumbers()
          Get the numbers of the nodes cached (will be removed).
 int getCacheSize()
          Gets the number of nodes currently in the cache.
 int getCacheSize(java.lang.String type)
          Return the number of nodes in the cache of one objecttype.
 java.lang.String getClassName()
          Returns the classname of this builder
 byte[] getDBByte(java.sql.ResultSet rs, int idx)
          Get binary data of a database blob field.
 int getDBKey()
          Get the next database key (unique index for an object).
 int getDBState(java.lang.String fieldName)
          Return a field's database state.
 java.lang.String getDBText(java.sql.ResultSet rs, int idx)
          Get text from a blob field.
 int getDBType(java.lang.String fieldName)
          Return a field's database type.
 MMObjectNode getDefaultTeaser(MMObjectNode node, MMObjectNode tnode)
          Deprecated. Will be removed?
 java.lang.String getDefaultUrl(int src)
          Return the default url of this object.
 java.lang.String getDescription()
          Get description of the builder
 java.util.Hashtable getDescriptions()
          Get descriptions of the builder
 java.lang.String getDutchSName()
          Deprecated. use getSingularName(java.lang.String) instead.
 java.util.Vector getEditFields()
          Get the field definitions for the editor, sorted according to it's GUISearch property (as set in the builder xml file).
 FieldDefs getField(java.lang.String fieldName)
          Return a field's definition
 java.util.Vector getFieldNames()
          Return a list of field names of this table.
 java.util.Vector getFields()
          Return a list of field definitions of this table.
 java.lang.String getFullTableName()
          Retrieve the full table name (including the clouds' base name)
protected  java.util.Vector getFunctionParameters(java.lang.String fields)
           
 java.lang.String getGUIIndicator(MMObjectNode node)
          What should a GUI display for this node.
 java.lang.String getGUIIndicator(java.lang.String field, MMObjectNode node)
          What should a GUI display for this node/field combo.
 MMObjectNode getHardNode(int number)
          Retrieves a node based on it's number (a unique key), directly from the database, not using the node cache.
 MMObjectNode getHardNode(java.lang.String key)
          Retrieves a node based on a unique key.
protected  java.lang.String getHTML(java.lang.String body)
          Returns a HTML-version of a string.
 java.lang.String getInitParameter(java.lang.String name)
          Retrieve a specific property.
 java.util.Hashtable getInitParameters()
          Get all builder properties
 java.util.Vector getList(scanpage sp, StringTagger tagger, java.util.StringTokenizer tok)
          Obtains a list of string values by performing the provided command and parameters.
 java.lang.String getMachineName()
          Get the name of this mmserver from the MMBase Root
 java.lang.String getMaintainer()
          Retrieves the maintainer of this builder
 MMObjectNode getNewNode(java.lang.String owner)
          Get a new node, using this builder as its parent.
 MMObjectNode getNewTmpNode(java.lang.String owner, java.lang.String key)
          Create a new temporary node and put it in the temporary _exist node space
 FieldDefs getNextField(java.lang.String currentfield)
          Returns the next field as defined by its sortorder, according to it's GUIPos property (as set in the builder xml file).
 MMObjectNode getNode(int number)
          Retrieves a node based on it's number (a unique key), retrieving the node from the node cache if possible.
 MMObjectNode getNode(int number, boolean usecache)
          Retrieves a node based on it's number (a unique key).
 MMObjectNode getNode(java.lang.String key)
          Retrieves a node based on a unique key.
 MMObjectNode getNode(java.lang.String key, boolean usecache)
          Retrieves a node based on a unique key.
 int getNodeType(int number)
          Retrieves an object's type.
 java.lang.String getNumberFromName(java.lang.String name)
          Returns the number of the node with the specified name.
 java.lang.String getPluralName()
          Gets long name of the builder in the current default language.
 java.lang.String getPluralName(java.lang.String lang)
          Gets long name of the builder, using the specified language.
 java.util.Hashtable getPluralNames()
          Gets a list of plural names (language - value pairs)
 java.util.Vector getRelations_main(int src)
          Returns all relations of a node.
 java.lang.String getSearchAge()
          Gets search Age
 java.lang.String getShort(java.lang.String str, int len)
          Support routine to return shorter strings.
 byte[] getShortedByte(java.lang.String fieldname, int number)
          Get binary data of a database blob field.
 java.lang.String getShortedText(java.lang.String fieldname, int number)
          Get text from a blob field.
 java.lang.String getSingularName()
          Gets short name of the builder in the current default language.
 java.lang.String getSingularName(java.lang.String lang)
          Gets short name of the builder, using the specified language.
 java.util.Hashtable getSingularNames()
          Gets a list of singular names (language - value pairs)
 java.lang.String getSmartPath(java.lang.String documentRoot, java.lang.String path, java.lang.String nodeNumber, java.lang.String version)
          Returns the path to use for TREEPART, TREEFILE, LEAFPART and LEAFFILE.
 java.util.Vector getSortedFields()
          Get the field definitions for the editor, sorted according to it's GUIPos property (as set in the builder xml file).
 java.util.Vector getSortedListFields()
          Get the field definitions for the editor, sorted accoring to it's GUIList property (as set in the builder xml file).
 java.lang.String getTableName()
          Retrieve the table name (without the clouds' base name)
 MMObjectNode getTmpNode(java.lang.String key)
          Get nodes from the temporary node space
protected  java.lang.String getURLEncode(java.lang.String body)
          Returns a URLEncoded-version (MIME x-www-form-urlencoded) of a string.
 java.lang.Object getValue(MMObjectNode node, java.lang.String field)
          Provides additional functionality when obtaining field values.
 int getVersion()
          Retrieves the version of this builder
protected  java.lang.String getWAP(java.lang.String body)
          Returns a WAP-version of a string.
 java.lang.String getXMLPath()
          Retrieves the subpath of the builder's xml configuration file.
 java.util.Hashtable getXMLSetup()
          Deprecated. will be removed
 java.lang.String hostname_function(java.lang.String url)
          hostname, parses the hostname from a url, so http://www.somesite.com/index.html becomed www.somesite.com
 void init_obj2type()
          Creates a cache for storing types and objects.
 boolean init()
          Initializes this builder The property 'mmb' needs to be set for the builder before this method can be called.
 int insert(int oType, java.lang.String owner)
          Insert a new, empty, object of a certain type.
 int insert(java.lang.String owner, MMObjectNode node)
          Insert a new object (content provided) in the cloud, including an entry for the object alias (if provided).
 int insertDone(EditState ed, MMObjectNode node)
          Deprecated. This method doesn't seem to fit here, as it references a gui/html object (EditState), endangering the separation between content and layout, and has an undefined return value.
 boolean isNodeCached(int number)
          Is this node cached at this moment?
 boolean isVirtual()
          Is this byuilder virtual? A virtual builder represents nodes that are not stored or retrieved directly from the database, but are created as needed.
 boolean isXMLConfig()
          Deprecated. will be removed
 boolean nodeLocalChanged(java.lang.String machine, java.lang.String number, java.lang.String builder, java.lang.String ctype)
          Called when a local node is changed.
 boolean nodeRemoteChanged(java.lang.String machine, java.lang.String number, java.lang.String builder, java.lang.String ctype)
          Called when a remote node is changed.
 MMObjectNode preCommit(MMObjectNode node)
          This method is called before an actual write to the database is performed.
 int preEdit(EditState ed, MMObjectNode node)
          Deprecated. This method doesn't seem to fit here, as it references a gui/html object (EditState), endangering the separation between content and layout. It also has an undefined return value.
 boolean process(scanpage sp, java.util.StringTokenizer command, java.util.Hashtable cmds, java.util.Hashtable vars)
          The hook that passes all form related pages to the correct handler.
 void putTmpNode(java.lang.String key, MMObjectNode node)
          Put a Node in the temporary node list
 SortedVector readSearchResults(java.sql.ResultSet rs, SortedVector sv)
          Store the nodes in the resultset, obtained from a builder, in a sorted vector.
 void removeField(java.lang.String fieldname)
          Remove a field from this builder.
 void removeNode(MMObjectNode node)
          Remove a node from the cloud.
 void removeRelations(MMObjectNode node)
          Remove the relations of a node.
 void removeTmpNode(java.lang.String key)
          Remove a node from the temporary node space
 java.lang.String replace(scanpage sp, java.util.StringTokenizer tok)
          Obtains a string value by performing the provided command.
 void safeCache(java.lang.Integer n, MMObjectNode node)
          Stores a node in the cache provided the cache is not locked.
 boolean safeCommit(MMObjectNode node)
          Locks the node cache during the commit of a node.
 int safeInsert(MMObjectNode node, java.lang.String username)
          Locks the node cache during the insert of a node.
 java.util.Enumeration search(java.lang.String where)
          Enumerate all the objects that match the searchkeys
 java.util.Enumeration search(java.lang.String where, java.lang.String sort)
          Enumerate all the objects that match the searchkeys
 java.util.Enumeration search(java.lang.String where, java.lang.String sort, boolean direction)
          Enumerate all the objects that match the searchkeys
 java.util.Enumeration searchIn(java.lang.String where, java.lang.String in)
          Enumerate all the objects that match the searchkeys
 java.util.Enumeration searchIn(java.lang.String where, java.lang.String sort, boolean direction, java.lang.String in)
          Enumerate all the objects that match the searchkeys
 java.util.Enumeration searchIn(java.lang.String where, java.lang.String sort, java.lang.String in)
          Enumerate all the objects that match the searchkeys
 java.util.Vector searchNumbers(java.lang.String where)
          Rewturns a Vector containing all the objects that match the searchkeys.
 java.util.Vector searchVector(java.lang.String where)
          Deprecated. Use search() instead
 java.util.Vector searchVector(java.lang.String where, java.lang.String sorted)
          Returns a vector containing all the objects that match the searchkeys
 java.util.Vector searchVector(java.lang.String where, java.lang.String sorted, boolean direction)
          Returns a vector containing all the objects that match the searchkeys
 java.util.Vector searchVector(java.lang.String where, java.lang.String sorted, java.lang.String directions)
          Returns a vector containing all the objects that match the searchkeys in a given order.
 java.util.Vector searchVectorIn(java.lang.String in)
          Returns a vector containing all the objects that match the searchkeys
 java.util.Vector searchVectorIn(java.lang.String where, java.lang.String in)
           
 java.util.Vector searchVectorIn(java.lang.String where, java.lang.String sorted, boolean direction, java.lang.String in)
          Returns a vector containing all the objects that match the searchkeys
 java.util.Vector searchVectorIn(java.lang.String where, java.lang.String sorted, java.lang.String in)
          Returns a vector containing all the objects that match the searchkeys
 java.util.Enumeration searchWithWhere(java.lang.String where)
          Enumerate all the objects that match the where clause This method is slightly faster than search(), since it does not try to 'parse' the where clause.
 boolean sendFieldChangeSignal(MMObjectNode node, java.lang.String fieldname)
          Send a signal to other servers that a field was changed.
 void setClassName(java.lang.String d)
          Set classname of the builder
 void setDBLayout_xml(java.util.Hashtable fields)
          Stores the fieldnames of a table in a vector, based on the current fields definition.
 void setDBLayout(java.util.Vector vec)
          Stores the fieldnames of a table in a vector, based on the current fields definition.
 void setDebug(boolean state)
          Deprecated. : use Logger routines instead
 void setDefaults(MMObjectNode node)
          Sets defaults for a node.
 void setDescription(java.lang.String e)
          Set description of the builder
 void setDescriptions(java.util.Hashtable e)
          Set descriptions of the builder
 void setDutchSName(java.lang.String d)
          Deprecated. Will be removed soon
 void setInitParameter(java.lang.String name, java.lang.String value)
          Set a single builder property The propertie will not be saved.
 void setMaintainer(java.lang.String m)
          Sets the maintainer of this builder
 void setMMBase(MMBase m)
          Set the MMBase object.
 void setPluralNames(java.util.Hashtable names)
          Sets a list of plural names (language - value pairs)
 void setSearchAge(java.lang.String age)
          Sets search Age.
 void setSingularNames(java.util.Hashtable names)
          Sets a list of singular names (language - value pairs)
 void setTableName(java.lang.String tableName)
          Set tablename of the builder.
 boolean setValue(MMObjectNode node, java.lang.String fieldname)
          Provides additional functionality when setting field values.
 boolean setValue(MMObjectNode node, java.lang.String fieldname, java.lang.Object originalValue)
          Sets a key/value pair in the main values of this node.
 void setVersion(int i)
          Sets the version of this builder
 void setXmlConfig(boolean state)
          Deprecated. will be removed
 void setXMLPath(java.lang.String m)
          Sets the subpath of the builder's xml configuration file.
 void setXMLValues(java.util.Vector xmlfields)
          Stores fields information of this table.
 boolean signalNewObject(java.lang.String tableName, int number)
          Send a signal to other servers that a new node was created.
 void testValidData(MMObjectNode node)
          Tests whether the data in a node is valid (throws an exception if this is not the case).
 java.lang.String toXML(MMObjectNode node)
          Converts a node to XML.
 boolean waitUntilNodeChanged(MMObjectNode node)
          Waits until a node is changed (multicast).
 java.lang.String wrap(java.lang.String text, int width)
          Wraps a string.
 
Methods inherited from class org.mmbase.module.core.MMTable
size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OBJ2TYPE_MAX_SIZE

public static final int OBJ2TYPE_MAX_SIZE

NODE_MAX_SIZE

public static final int NODE_MAX_SIZE

TEMPNODE_DEFAULT_SIZE

public static final int TEMPNODE_DEFAULT_SIZE

obj2type

public static LRUHashtable obj2type
The cache that contains the last X types of all requested objects X is currently set to 20000. The hashtable is created using the init_obj2type() method, which seems strange - as other caches are instantiated during variable declaration.

nodeCache

public static LRUHashtable nodeCache
The cache that contains the X last requested nodes X is currently set to 4096

TemporaryNodes

public static java.util.Hashtable TemporaryNodes
Collection for temporary nodes, Used by the Temporarynodemanager when working with transactions The default size is 1024.

database

public static MMJdbc2NodeInterface database
The class used to store and retrieve data in the database that is currently in use.

debug

public boolean debug
Deprecated. : use Logger routines instead

If true, debug messages are send to the MMBase log

oType

public int oType
The current builder's object type Retrieved from the TypeDef builder.

description

public java.lang.String description
Description of the builder in the currently selected language Not that the first time the builder is created, this value is what is stored in the TypeDef table.

descriptions

public java.util.Hashtable descriptions
Descriptions of the builder per language Can be set with the <descriptions> tag in the xml builder file.

sortedDBLayout

public java.util.Vector sortedDBLayout
Contains the list of fieldnames as they used in the database. The list (which is based on input from the xml builder file) should be sorted on the order of fields as they are defined in the tabel. The first two fields are 'otype' and 'owner'. The field 'number' (the actual first field of a database table record) is not included in this collection.

searchAge

public java.lang.String searchAge
The default search age for this builder. Used for intializing editor search forms (see HtmlBase) Default value is 31. Can be changed with the <searchage> tag in the xml builder file.

className

public java.lang.String className
The classname as specified in the builder xml file mainly for use in export

replaceCache

public boolean replaceCache
Detemines whether the cache need be refreshed? Seems useless, as this value is never changed (always true)
See Also:
readSearchResults(java.sql.ResultSet, org.mmbase.util.SortedVector)

broadcastChanges

public boolean broadcastChanges
Determines whether changes to this builder need be broadcasted to other known mmbase servers. This setting also governs whether the cache for relation builders is emptied when a relation changes. Actual broadcasting (and cache emptying) is initiated in the 'database' object, when changes are commited to the database. By default, all builders broadcast their changes, with the exception of the TypeDef builder.

fields

protected java.util.Hashtable fields

virtual

protected boolean virtual
Determines whether a builder is virtual (data is not stored in a database).
Constructor Detail

MMObjectBuilder

public MMObjectBuilder()
Constructor. Derived builders should provide their own constructors, rather than use this one.
Method Detail

setDebug

public void setDebug(boolean state)
Deprecated. : use Logger routines instead

Sets debugging on or off

init

public boolean init()
Initializes this builder The property 'mmb' needs to be set for the builder before this method can be called. The method retrieves data from the TypeDef builder, or adds data to thet builder if the current builder si not yet registrered.
Returns:
Always true.
See Also:
create()

create

public boolean create()
Creates a new builder table in the current database.

testValidData

public void testValidData(MMObjectNode node)
                   throws InvalidDataException
Tests whether the data in a node is valid (throws an exception if this is not the case).
Parameters:
node - The node whose data to check
Throws:
InvalidDataException - If the data was unrecoverably invalid (the references did not point to existing objects)

insert

public int insert(int oType,
                  java.lang.String owner)
Insert a new, empty, object of a certain type.
Parameters:
oType - The type of object to create
owner - The administrator creating the node
Returns:
An int value which is the new object's unique number, -1 if the insert failed. The basic routine does not create any nodes this way and always fails.

insert

public int insert(java.lang.String owner,
                  MMObjectNode node)
Insert a new object (content provided) in the cloud, including an entry for the object alias (if provided). This method indirectly calls preCommit(org.mmbase.module.core.MMObjectNode).
Parameters:
owner - The administrator creating the node
node - The object to insert. The object need be of the same type as the current builder.
Returns:
An int value which is the new object's unique number, -1 if the insert failed.

insertDone

public int insertDone(EditState ed,
                      MMObjectNode node)
Deprecated. This method doesn't seem to fit here, as it references a gui/html object (EditState), endangering the separation between content and layout, and has an undefined return value.

Once a insert is done in the editor this method is called.
Parameters:
ed - Contains the current edit state (editor info). The main function of this object is to pass 'settings' and 'parameters' - value pairs that have been the during the edit process.
node - The node thatw as inserted
Returns:
An int value. It's meaning is undefined. The basic routine returns -1.

preEdit

public int preEdit(EditState ed,
                   MMObjectNode node)
Deprecated. This method doesn't seem to fit here, as it references a gui/html object (EditState), endangering the separation between content and layout. It also has an undefined return value.

Check and make last changes before calling commit(org.mmbase.module.core.MMObjectNode) or insert(int, java.lang.String). This method is called by the editor. This differs from preCommit(org.mmbase.module.core.MMObjectNode), which is called by the database system during the call to commit or insert.
Parameters:
ed - Contains the current edit state (editor info). The main function of this object is to pass 'settings' and 'parameters' - value pairs that have been the during the edit process.
node - The node that was inserted
Returns:
An int value. It's meaning is undefined. The basic routine returns -1.

preCommit

public MMObjectNode preCommit(MMObjectNode node)
This method is called before an actual write to the database is performed. It is called from within the database routines, unlike preEdit(org.mmbase.module.gui.html.EditState, org.mmbase.module.core.MMObjectNode), which is called by the editor. That is, preCommit is enforced, while preEdit is not (depending on the editor used).
Parameters:
node - The node to be committed.
Returns:
the node to be committed (possibly after changes have been made).

commit

public boolean commit(MMObjectNode node)
Commit changes to this node to the database. This method indirectly calls preCommit(org.mmbase.module.core.MMObjectNode). Use only to commit changes - for adding node, use insert(int, java.lang.String).
Parameters:
node - The node to be committed
Returns:
The committed node.

createAlias

public void createAlias(int number,
                        java.lang.String alias)
Creates an alias for a node, provided the OAlias builder is loaded.
Parameters:
number - the to-be-aliased node's unique number
alias - the aliasname to associate with the object

init_obj2type

public void init_obj2type()
Creates a cache for storing types and objects. The cache can contain a maximum of OBJ2TYPE_MAX_SIZE elements. Note that this should possibly be moved to the variable declaration part (like nodecache)?

getNewNode

public MMObjectNode getNewNode(java.lang.String owner)
Get a new node, using this builder as its parent. The new node is not a part of the cloud yet, and thus has the value -1 as a number. (Call insert(int, java.lang.String) to add the node to the cloud).
Parameters:
owner - The administrator creating the new node.
Returns:
A newly initialized MMObjectNode.

setDefaults

public void setDefaults(MMObjectNode node)
Sets defaults for a node. Fields "number", "owner" and "otype" are not set by this method.
Parameters:
node - The node to set the defaults of.

removeNode

public void removeNode(MMObjectNode node)
Remove a node from the cloud.
Parameters:
node - The node to remove.

removeRelations

public void removeRelations(MMObjectNode node)
Remove the relations of a node.
Parameters:
node - The node whose relations to remove.

isNodeCached

public boolean isNodeCached(int number)
Is this node cached at this moment?
Parameters:
number - The number of the node to check.
Returns:
true if the node is in the cache, false otherwise.

isVirtual

public boolean isVirtual()
Is this byuilder virtual? A virtual builder represents nodes that are not stored or retrieved directly from the database, but are created as needed.
Returns:
true if the builder is virtual.

safeCache

public void safeCache(java.lang.Integer n,
                      MMObjectNode node)
Stores a node in the cache provided the cache is not locked.

safeCommit

public boolean safeCommit(MMObjectNode node)
Locks the node cache during the commit of a node. This prevents the cache from gaining an invalid state during the commit.

safeInsert

public int safeInsert(MMObjectNode node,
                      java.lang.String username)
Locks the node cache during the insert of a node. This prevents the cache from adding the node, which means that the next time the node is read it is 'refreshed' from the database

getNodeType

public int getNodeType(int number)
Retrieves an object's type. If necessary, the type is added to the cache.
Parameters:
number - The number of the node to search for
Returns:
an int value which is the object type (otype) of the node.

getAliasedNode

public MMObjectNode getAliasedNode(java.lang.String key)
Deprecated. Use getNode(java.lang.String) instead.

Retrieves a node based on a unique key. The key is either an entry from the OAlias table or the string-form of an integer value (the number field of an object node).
Parameters:
key - The value to search for
Returns:
null if the node does not exist or the key is invalid, or a MMObjectNode containing the contents of the requested node.

getNode

public MMObjectNode getNode(java.lang.String key,
                            boolean usecache)
Retrieves a node based on a unique key. The key is either an entry from the OAlias table or the string-form of an integer value (the number field of an object node). Note that the OAlias builder needs to be active for the alias to be used (otherwise using an alias is concidered invalid).
Parameters:
key - The value to search for
usecache - If true, the node is retrieved from the node cache if possible.
Returns:
null if the node does not exist or the key is invalid, or a MMObjectNode containing the contents of the requested node.

getNode

public MMObjectNode getNode(java.lang.String key)
Retrieves a node based on a unique key. The key is either an entry from the OAlias table or the string-form of an integer value (the number field of an object node). Retrieves a node from the node cache if possible.
Parameters:
key - The value to search for
Returns:
null if the node does not exist or the key is invalid, or a MMObjectNode containing the contents of the requested node.

getHardNode

public MMObjectNode getHardNode(java.lang.String key)
Retrieves a node based on a unique key. The key is either an entry from the OAlias table or the string-form of an integer value (the number field of an object node). Retrieves the node from directly the database, not using the node cache.
Parameters:
key - The value to search for
Returns:
null if the node does not exist or the key is invalid, or a MMObjectNode containing the contents of the requested node.

getNode

public MMObjectNode getNode(int number,
                            boolean usecache)
Retrieves a node based on it's number (a unique key).
Parameters:
number - The number of the node to search for
usecache - If true, the node is retrieved from the node cache if possible.
Returns:
null if the node does not exist or the key is invalid, or a MMObjectNode containign the contents of the requested node.

getNode

public MMObjectNode getNode(int number)
Retrieves a node based on it's number (a unique key), retrieving the node from the node cache if possible.
Parameters:
number - The number of the node to search for
Returns:
null if the node does not exist or the key is invalid, or a MMObjectNode containign the contents of the requested node.

getHardNode

public MMObjectNode getHardNode(int number)
Retrieves a node based on it's number (a unique key), directly from the database, not using the node cache.
Parameters:
number - The number of the node to search for
Returns:
null if the node does not exist or the key is invalid, or a MMObjectNode containign the contents of the requested node.

getNewTmpNode

public MMObjectNode getNewTmpNode(java.lang.String owner,
                                  java.lang.String key)
Create a new temporary node and put it in the temporary _exist node space

putTmpNode

public void putTmpNode(java.lang.String key,
                       MMObjectNode node)
Put a Node in the temporary node list
Parameters:
key - The (temporary) key under which to store the node
node - The node to store

checkAddTmpField

public boolean checkAddTmpField(java.lang.String field)
Defines a virtual field to use for temporary nodes
Parameters:
field - the anme of the temporary field
Returns:
true if the field was added, false if it already existed.

getTmpNode

public MMObjectNode getTmpNode(java.lang.String key)
Get nodes from the temporary node space
Parameters:
key - The (temporary) key to use under which the node is stored

removeTmpNode

public void removeTmpNode(java.lang.String key)
Remove a node from the temporary node space
Parameters:
key - The (temporary) key under which the node is stored

count

public int count(java.lang.String where)
Count all the objects that match the searchkeys
Parameters:
where - scan expression that the objects need to fulfill
Returns:
the number of an Enumeration containing all the objects that apply.

search

public java.util.Enumeration search(java.lang.String where)
Enumerate all the objects that match the searchkeys
Parameters:
where - scan expression that the objects need to fulfill
Returns:
an Enumeration containing all the objects that apply.

searchVector

public java.util.Vector searchVector(java.lang.String where)
Deprecated. Use search() instead

Returns a vector containing all the objects that match the searchkeys
Parameters:
where - scan expression that the objects need to fulfill
Returns:
a vector containing all the objects that apply.

searchVectorIn

public java.util.Vector searchVectorIn(java.lang.String in)
Returns a vector containing all the objects that match the searchkeys
Parameters:
in - either a set of object numbers (in comma-separated string format), or a sub query returning a set of object numbers.
Returns:
a vector containing all the objects that apply.

searchNumbers

public java.util.Vector searchNumbers(java.lang.String where)
Rewturns a Vector containing all the objects that match the searchkeys. Only returns the object numbers.
Parameters:
where - scan expression that the objects need to fulfill
Returns:
a Vector containing all the object numbers that apply, null if en error occurred.

search

public java.util.Enumeration search(java.lang.String where,
                                    java.lang.String sort)
Enumerate all the objects that match the searchkeys
Parameters:
where - where clause that the objects need to fulfill
sorted - order in which to return the objects
Returns:
an Enumeration containing all the objects that apply.

searchIn

public java.util.Enumeration searchIn(java.lang.String where,
                                      java.lang.String sort,
                                      java.lang.String in)
Enumerate all the objects that match the searchkeys
Parameters:
where - where clause that the objects need to fulfill
sorted - order in which to return the objects
in - lost of node numbers to filter on
Returns:
an Enumeration containing all the objects that apply.

searchIn

public java.util.Enumeration searchIn(java.lang.String where,
                                      java.lang.String in)
Enumerate all the objects that match the searchkeys
Parameters:
where - where clause that the objects need to fulfill
in - lost of node numbers to filter on
Returns:
an Enumeration containing all the objects that apply.

search

public java.util.Enumeration search(java.lang.String where,
                                    java.lang.String sort,
                                    boolean direction)
Enumerate all the objects that match the searchkeys
Parameters:
where - where clause that the objects need to fulfill
sorted - order in which to return the objects
direction - sorts ascending if true, descending if false. Only applies if a sorted order is given.
Returns:
an Enumeration containing all the objects that apply.

searchIn

public java.util.Enumeration searchIn(java.lang.String where,
                                      java.lang.String sort,
                                      boolean direction,
                                      java.lang.String in)
Enumerate all the objects that match the searchkeys
Parameters:
where - where clause that the objects need to fulfill
sorted - order in which to return the objects
in - lost of node numbers to filter on
direction - sorts ascending if true, descending if false. Only applies if a sorted order is given.
Returns:
an Enumeration containing all the objects that apply.

searchVector

public java.util.Vector searchVector(java.lang.String where,
                                     java.lang.String sorted)
Returns a vector containing all the objects that match the searchkeys
Parameters:
where - where clause that the objects need to fulfill
sorted - order in which to return the objects
Returns:
a vector containing all the objects that apply.

searchVectorIn

public java.util.Vector searchVectorIn(java.lang.String where,
                                       java.lang.String sorted,
                                       java.lang.String in)
Returns a vector containing all the objects that match the searchkeys
Parameters:
where - where clause that the objects need to fulfill
sorted - order in which to return the objects
in - either a set of object numbers (in comma-separated string format), or a sub query returning a set of object numbers.
Returns:
a vector containing all the objects that apply.

searchVectorIn

public java.util.Vector searchVectorIn(java.lang.String where,
                                       java.lang.String in)

searchVector

public java.util.Vector searchVector(java.lang.String where,
                                     java.lang.String sorted,
                                     boolean direction)
Returns a vector containing all the objects that match the searchkeys
Parameters:
where - where clause that the objects need to fulfill
sorted - order in which to return the objects
direction - sorts ascending if true, descending if false. Only applies if a sorted order is given.
Returns:
a vector containing all the objects that apply.

searchVector

public java.util.Vector searchVector(java.lang.String where,
                                     java.lang.String sorted,
                                     java.lang.String directions)
Returns a vector containing all the objects that match the searchkeys in a given order.
Parameters:
where - where clause that the objects need to fulfill
sorted - a comma separated list of field names on wich the returned list should be sorted
directions - A comma separated list of the values indicating wether to sort up (ascending) or down (descending) on the corresponding field in the sorted parameter or null if sorting on all fields should be up. The value DOWN (case insensitive) indicates that sorting on the corresponding field should be down, all other values (including the empty value) indicate that sorting on the corresponding field should be up. If the number of values found in this parameter are less than the number of fields in the sorted parameter, all fields that don't have a corresponding direction value are sorted according to the last specified direction value.
Returns:
a vector containing all the objects that apply in the requested order

searchVectorIn

public java.util.Vector searchVectorIn(java.lang.String where,
                                       java.lang.String sorted,
                                       boolean direction,
                                       java.lang.String in)
Returns a vector containing all the objects that match the searchkeys
Parameters:
where - where clause that the objects need to fulfill
sorted - order in which to return the objects
in - either a set of object numbers (in comma-separated string format), or a sub query returning a set of object numbers.
direction - sorts ascending if true, descending if false. Only applies if a sorted order is given.
Returns:
a vector containing all the objects that apply.

searchWithWhere

public java.util.Enumeration searchWithWhere(java.lang.String where)
Enumerate all the objects that match the where clause This method is slightly faster than search(), since it does not try to 'parse' the where clause.
Parameters:
where - where clause (SQL-syntax) that the objects need to fulfill
Returns:
an Enumeration containing all the objects that apply.

readSearchResults

public SortedVector readSearchResults(java.sql.ResultSet rs,
                                      SortedVector sv)
Store the nodes in the resultset, obtained from a builder, in a sorted vector. (Called by nl.vpro.mmbase.module.search.TeaserSearcher.createShopResult ?) The nodes retrieved are added to the cache.
Parameters:
rs - The resultset containing the nodes
Returns:
The SortedVector which holds the data

buildSet

public java.lang.String buildSet(java.util.Vector nodes,
                                 java.lang.String fieldName)
Build a set command string from a set nodes ( should be moved )
Parameters:
fieldName - fieldname whsoe values should be put in the set
Returns:
a comma-seperated list of values, as a String

getFields

public java.util.Vector getFields()
Return a list of field definitions of this table.
Returns:
a Vector with the tables fields (FieldDefs)

getFieldNames

public java.util.Vector getFieldNames()
Return a list of field names of this table.
Returns:
a Vector with the tables field anmes (String)

getField

public FieldDefs getField(java.lang.String fieldName)
Return a field's definition
Parameters:
the - requested field's name
Returns:
a FieldDefs belonging with the indicated field

addField

public void addField(FieldDefs def)
Add a field to this builder. This does not affect the builder config file, nor the table used.
Parameters:
def - the field definiton to add

removeField

public void removeField(java.lang.String fieldname)
Remove a field from this builder. This does not affect the builder config file, nor the table used.
Parameters: