org.mmbase.module.core
Class MMObjectBuilder

java.lang.Object
  |
  +--org.mmbase.module.core.MMTable
        |
        +--org.mmbase.module.core.MMObjectBuilder
Direct Known Subclasses:
AbstractServletBuilder, Articles, BugReports, Cameras, Cassettes, CDs, Channel, Community, Cookies, CopyServices, DayMarkers, Dummy, Email, FieldDef, floppydrvs, Forums, ImageAliases, 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, UserBuilder, 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:
$Id: MMObjectBuilder.java,v 1.181.2.33 2003/08/26 08:51:12 johannes Exp $
Author:
Daniel Ockeloen, Rob Vermeulen, Pierre van Rooden, Eduard Witteveen, Johan Verelst, Michiel Meeuwissen

Field Summary
 boolean broadcastChanges
          Determines whether changes to this builder need be broadcasted to other known mmbase servers.
static MMJdbc2NodeInterface database
          Deprecated. use MMBase.getMMBase().getDatabase() or mmb.getDatabase() instead
static java.lang.String DEFAULT_ALINEA
          Default replacements for method getHTML()
static java.lang.String DEFAULT_EOL
           
 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 NodeCache nodeCache
          The cache that contains the X last requested nodes
static Cache obj2type
          Deprecated. Will not be available anymore in 1.7
static int OBJ2TYPE_MAX_SIZE
          Max size of the object type cache, config/caches.xml can override this
 int oType
          The current builder's object type Retrieved from the TypeDef builder.
 boolean REPLACE_CACHE
          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
          Deprecated. this vector should not be used - if the order of the fields is an issue, use getFields(sortorder).
static int TEMPNODE_DEFAULT_SIZE
          Default size of the temporary node cache
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.
 boolean 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.
 void deleteNodeCache()
          Delete the nodes cache.
 boolean drop()
          Drops the builder table from the current database
 boolean equals(MMObjectNode o1, MMObjectNode o2)
          Implements equals for nodes (this is in MMObjectBuilder because you cannot override MMObjectNode)
 boolean equals(java.lang.Object o)
          Equals must be implemented because of the list of MMObjectBuilder which is used for ancestors
protected  java.lang.Object executeFunction(MMObjectNode node, java.lang.String function, java.util.List arguments)
           
protected  java.lang.Object executeFunction(MMObjectNode node, java.lang.String function, java.lang.String field)
          Deprecated. use executeFunction(MMObjectNode, String, List)
 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.
protected  java.util.List getAncestors()
          Gives the list of parent-builders.
 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()
          Deprecated. don't use
 java.io.File getConfigFile()
          Gets the file that contains the configuration 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.util.List getDescendants()
          Creates list of descendant-builders.
 java.lang.String getDescription()
          Get description of the builder
 java.lang.String getDescription(java.lang.String lang)
          Gets description of the builder, using the specified language.
 java.util.Hashtable getDescriptions()
          Get descriptions of the builder
 java.util.Vector getEditFields()
          Deprecated. use getFields() with sortorder ORDER_SEARCH
 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.util.List getFields(int sortorder)
          Get the field definitions for the editor, sorted according to the specified order.
 java.lang.String getFullTableName()
          Retrieve the full table name (including the clouds' base name)
protected  java.util.Vector getFunctionParameters(java.lang.String fields)
          Deprecated. use executeFunction(node, function, list)
 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.
protected  java.lang.String getLocaleGUIIndicator(java.util.Locale locale, MMObjectNode node)
          The GUIIndicator can depend on the locale.
protected  java.lang.String getLocaleGUIIndicator(java.util.Locale locale, java.lang.String field, MMObjectNode node)
          The GUIIndicator can depend on the locale.
 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)
          Deprecated. use getNextField() with sortorder ORDER_EDIT
 FieldDefs getNextField(java.lang.String currentfield, int sortorder)
          Returns the next field as defined by its sortorder, according to the specified order.
 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.
 java.util.List getNodes(java.util.List virtuals)
          Convert virtual nodes to real nodes based on their otype Normally a multirelations-search will return virtual nodes.
 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.
 int getObjectType()
          Returns the objecttype (otype).
protected  java.lang.Object getObjectValue(MMObjectNode node, java.lang.String field)
          Like getValue, but without the 'old' code.
 MMObjectBuilder getParentBuilder()
          Returns the builder that this builder extends.
 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)
protected  java.lang.String getQuery(java.lang.String where)
          Parses arguments of searchVector and searchList
protected  java.lang.String getQuery(java.lang.String where, java.lang.String sorted, boolean direction)
          Parses arguments of searchVector and searchList
protected  java.lang.String getQuery(java.lang.String where, java.lang.String sorted, java.lang.String directions)
          Parses arguments of searchVector and searchList
 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()
          Deprecated. use getFields() with sortorder ORDER_EDIT
 java.util.Vector getSortedListFields()
          Deprecated. use getFields() with sortorder ORDER_LIST
 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.
 int hashCode(MMObjectNode o)
          Implements for MMObjectNode
 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
 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 isExtensionOf(MMObjectBuilder o)
          Checks wether this builder is an extension of the argument builder
 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 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.List searchList(java.lang.String where)
          As searchVector.
 java.util.List searchList(java.lang.String where, java.lang.String sorted, java.lang.String directions)
          As searchVector But - throws Exception on error - returns List
 java.util.Vector searchNumbers(java.lang.String where)
          Returns 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 setDBLayout_xml(java.util.Hashtable fields)
          Deprecated. sortedDBLayout should not be used any more. use the getFields(sortorder) method 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 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, and retrieve the database lasyer.
 void setParentBuilder(MMObjectBuilder parent)
          Sets the builder that this builder extends, and registers it in the database layer.
 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 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 toString()
          Implmenting a sensible toString is usefull for debugging.
 java.lang.String toString(MMObjectNode n)
          Implements for MMObjectNode
 java.lang.String toXML(MMObjectNode node)
          Converts a node to XML.
protected  void updateFields()
          Clears all field list caches, and recalculates the database field list.
 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, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

OBJ2TYPE_MAX_SIZE

public static final int OBJ2TYPE_MAX_SIZE
Max size of the object type cache, config/caches.xml can override this

TEMPNODE_DEFAULT_SIZE

public static final int TEMPNODE_DEFAULT_SIZE
Default size of the temporary node cache

DEFAULT_ALINEA

public static final java.lang.String DEFAULT_ALINEA
Default replacements for method getHTML()

DEFAULT_EOL

public static final java.lang.String DEFAULT_EOL

obj2type

public static Cache obj2type
Deprecated. Will not be available anymore in 1.7

The cache that contains the last X types of all requested objects

nodeCache

public static NodeCache nodeCache
The cache that contains the X last requested nodes

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
Deprecated. use MMBase.getMMBase().getDatabase() or mmb.getDatabase() instead

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

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
Deprecated. this vector should not be used - if the order of the fields is an issue, use getFields(sortorder).

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.

REPLACE_CACHE

public boolean REPLACE_CACHE
Detemines whether the cache need be refreshed? Seems useless, as this value is never changed (always true)

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

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 that builder if the current builder is not yet registered.
Returns:
true if init was completed, false if uncompleted.
See Also:
create()

create

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

drop

public boolean drop()
Drops the builder table from 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:
true if commit successful

createAlias

public boolean 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
Returns:
if the alias could be created

getParentBuilder

public MMObjectBuilder getParentBuilder()
Returns the builder that this builder extends.
Returns:
the extended (parent) builder, or null if not available
Since:
MMBase-1.6

getAncestors

protected java.util.List getAncestors()
Gives the list of parent-builders.
Since:
MMBase-1.6.2

getDescendants

public java.util.List getDescendants()
Creates list of descendant-builders.
Since:
MMBase-1.6.2

setParentBuilder

public void setParentBuilder(MMObjectBuilder parent)
                      throws StorageException
Sets the builder that this builder extends, and registers it in the database layer.
Parameters:
parent - the extended (parent) builder, or null if not available
Since:
MMBase-1.6

isExtensionOf

public boolean isExtensionOf(MMObjectBuilder o)
Checks wether this builder is an extension of the argument builder
Since:
MMBase-1.6.2

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.

getObjectType

public int getObjectType()
Returns the objecttype (otype). This is similar to the otype field value of objects of teh builder, and the number of the bilder's object in the typedef builder. In other words: getNode(getObjectType()) returns this builder's objectnode.
Returns:
the objecttype

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.

getNodes

public java.util.List getNodes(java.util.List virtuals)
Convert virtual nodes to real nodes based on their otype Normally a multirelations-search will return virtual nodes. These nodes will only contain values which where specified in the field-vector. This method will make real nodes of those virtual nodes.
Parameters:
List - containing virtual nodes
Returns:
List containing real nodes
Since:
MMBase-1.6.2

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.
Throws:
java.lang.RuntimeException - If the node does not exist

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 name 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.

getQuery

protected java.lang.String getQuery(java.lang.String where)
Parses arguments of searchVector and searchList
Since:
MMBase-1.6

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.

searchList

public java.util.List searchList(java.lang.String where)
                          throws java.sql.SQLException
As searchVector. Differences are: - Throws exception on SQL errors - returns List rather then Vector.
Since:
MMBase-1.6

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)
Returns 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)

getQuery

protected java.lang.String getQuery(java.lang.String where,
                                    java.lang.String sorted,
                                    boolean direction)
Parses arguments of searchVector and searchList
Since:
MMBase-1.6

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.

getQuery

protected java.lang.String getQuery(java.lang.String where,
                                    java.lang.String sorted,
                                    java.lang.String directions)
Parses arguments of searchVector and searchList
Since:
MMBase-1.6

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

searchList

public java.util.List searchList(java.lang.String where,
                                 java.lang.String sorted,
                                 java.lang.String directions)
                          throws java.sql.SQLException
As searchVector But - throws Exception on error - returns List
Since:
MMBase-1.6

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

updateFields

protected void updateFields()
Clears all field list caches, and recalculates the database field list.

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:
fieldname - the name of the field to remove

getDBType

public int getDBType(java.lang.String fieldName)
Return a field's database type. The returned value is one of the following values declared in FieldDefs: TYPE_STRING, TYPE_INTEGER, TYPE_BYTE, TYPE_FLOAT, TYPE_DOUBLE, TYPE_LONG, TYPE_NODE, TYPE_UNKNOWN
Parameters:
the - requested field's name
Returns:
the field's type.

getDBState

public int getDBState(java.lang.String fieldName)
Return a field's database state. The returned value is one of the following values declared in FieldDefs: DBSTATE_VIRTUAL, DBSTATE_PERSISTENT, DBSTATE_SYSTEM, DBSTATE_UNKNOWN
Parameters:
the - requested field's name
Returns:
the field's type.

getGUIIndicator

public java.lang.String getGUIIndicator(MMObjectNode node)
What should a GUI display for this node. Default is the first non system field (first field after owner). Override this to display your own choice (see Images.java).
Parameters:
node - The node to display
Returns:
the display of the node as a String

getGUIIndicator

public java.lang.String getGUIIndicator(java.lang.String field,
                                        MMObjectNode node)
What should a GUI display for this node/field combo. Default is null (indicating to display the field as is) Override this to display your own choice.
Parameters:
node - The node to display
field - the name field of the field to display
Returns:
the display of the node's field as a String, null if not specified

getLocaleGUIIndicator

protected java.lang.String getLocaleGUIIndicator(java.util.Locale locale,
                                                 java.lang.String field,
                                                 MMObjectNode node)
The GUIIndicator can depend on the locale. Override this function
Since:
MMBase-1.6

getLocaleGUIIndicator

protected java.lang.String getLocaleGUIIndicator(java.util.Locale locale,
                                                 MMObjectNode node)
The GUIIndicator can depend on the locale. Override this function
Since:
MMBase-1.6

getFields

public java.util.List getFields(int sortorder)
Get the field definitions for the editor, sorted according to the specified order. This method makes an explicit sort (it does not use a cached list).
Returns:
a vector with ordered FieldDefs

getEditFields

public java.util.Vector getEditFields()
Deprecated. use getFields() with sortorder ORDER_SEARCH

Get the field definitions for the editor, sorted according to it's GUISearch property (as set in the builder xml file). Used for creating search-forms.
Returns:
a vector with FieldDefs

getSortedListFields

public java.util.Vector getSortedListFields()
Deprecated. use getFields() with sortorder ORDER_LIST

Get the field definitions for the editor, sorted accoring to it's GUIList property (as set in the builder xml file). Used for creating list-forms (tables).
Returns:
a vector with FieldDefs

getSortedFields

public java.util.Vector getSortedFields()
Deprecated. use getFields() with sortorder ORDER_EDIT

Get the field definitions for the editor, sorted according to it's GUIPos property (as set in the builder xml file). Used for creating edit-forms.
Returns:
a vector with FieldDefs

getNextField

public FieldDefs getNextField(java.lang.String currentfield,
                              int sortorder)
Returns the next field as defined by its sortorder, according to the specified order.

getNextField

public FieldDefs getNextField(java.lang.String currentfield)
Deprecated. use getNextField() with sortorder ORDER_EDIT

Returns the next field as defined by its sortorder, according to it's GUIPos property (as set in the builder xml file). Used for moving between fields in an edit-form.

getTableName

public java.lang.String getTableName()
Retrieve the table name (without the clouds' base name)
Returns:
a String containing the table name

getFullTableName

public java.lang.String getFullTableName()
Retrieve the full table name (including the clouds' base name)
Returns:
a String containing the full table name

getValue

public java.lang.Object getValue(MMObjectNode node,
                                 java.lang.String field)
Provides additional functionality when obtaining field values. This method is called whenever a Node of the builder's type fails at evaluating a getValue() request (generally when a fieldname is supplied that doesn't exist). It allows the system to add 'functions' to be included with a field name, such as 'html(body)' or 'time(lastmodified)'. This method will parse the fieldname, determining functions and calling the executeFunction(org.mmbase.module.core.MMObjectNode, java.lang.String, java.util.List) method to handle it. Functions in fieldnames can be given in the format 'functionname(fieldname)'. An old format allows 'functionname_fieldname' instead, though this only applies to the text functions 'short', 'html', and 'wap'. Functions can be nested, i.e. 'html(shorted(body))'. Derived builders should override this method only if they want to provide virtual fieldnames. To provide addiitonal functions, override executeFunction(org.mmbase.module.core.MMObjectNode, java.lang.String, java.util.List) instead.
Parameters:
node - the node whos efields are queries
field - the fieldname that is requested
Returns:
the result of the 'function', or null if no valid functions could be determined.

getObjectValue

protected java.lang.Object getObjectValue(MMObjectNode node,
                                          java.lang.String field)
Like getValue, but without the 'old' code.
Since:
MMBase-1.6

getFunctionParameters

protected java.util.Vector getFunctionParameters(java.lang.String fields)
Deprecated. use executeFunction(node, function, list)


executeFunction

protected java.lang.Object executeFunction(MMObjectNode node,
                                           java.lang.String function,
                                           java.util.List arguments)
Since:
MMBase-1.6

executeFunction

protected java.lang.Object executeFunction(MMObjectNode node,
                                           java.lang.String function,
                                           java.lang.String field)
Deprecated. use executeFunction(MMObjectNode, String, List)

Executes a function on the field of a node, and returns the result. This method is called by the builder's getValue(org.mmbase.module.core.MMObjectNode, java.lang.String) method. Derived builders should override this method to provide additional functions. current functions are:
on dates: date, time, timesec, longmonth, month, monthnumber, weekday, shortday, day, yearhort year
on text: wap, html, shorted, uppercase, lowercase
on node: age()
on numbers: wrap_<int>, currency_euro
Parameters:
node - the node whose fields are queries
field - the fieldname that is requested
Returns:
the result of the 'function', or null if no valid functions could be determined.

getRelations_main

public java.util.Vector getRelations_main(int src)
Returns all relations of a node. This returns the relation objects, not the objects related to. Note that the relations returned are always of builder type 'InsRel', even if they are really from a derived builser such as AuthRel.
Parameters:
src - the number of the node to obtain the relations from
Returns:
a Vector with InsRel nodes

getDefaultUrl

public java.lang.String getDefaultUrl(int src)
Return the default url of this object. The basic value returned is null.
Parameters:
src - the number of the node to obtain the url from
Returns:
the basic url as a String, or null if unknown.

getSmartPath

public 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. The system searches in a provided base path for a filename that matches the supplied number/alias of a node (possibly extended with a version number). See the documentation on the TREEPART SCAN command for more info.
Parameters:
documentRoot - the root of the path to search
path - the subpath of the path to search
nodeNumber - the numbve ror alias of the node to filter on
version - the version number (or null if not applicable) to filter on
Returns:
the found path as a String, or null if not found This method should be added to the bridge so jsp can make use of it. This method can be overriden to make an even smarter search possible.

getCacheSize

public int getCacheSize()
Gets the number of nodes currently in the cache.
Returns:
the number of nodes in the cache

getCacheSize

public int getCacheSize(java.lang.String type)
Return the number of nodes in the cache of one objecttype.
Parameters:
type - the object type to count
Returns:
the number of nodes of that type in the cache

getCacheNumbers

public java.lang.String getCacheNumbers()
Get the numbers of the nodes cached (will be removed).

deleteNodeCache

public void deleteNodeCache()
Delete the nodes cache.

getDBKey

public int getDBKey()
Get the next database key (unique index for an object).
Returns:
an int value that is the next available key for an object.

getAge

public int getAge(MMObjectNode node)
Return the age of the node, determined using the daymarks builder.
Parameters:
node - The node whose age to determine
Returns:
the age in days, or 0 if unknown (daymarks builder not present)

getMachineName

public java.lang.String getMachineName()
Get the name of this mmserver from the MMBase Root
Returns:
a String which is the server's name

nodeRemoteChanged

public 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. Should be called by subclasses if they override it.
Parameters:
machine - Name of the machine that changed the node.
number - Number of the changed node as a String
builder - type of the changed node
ctype - command type, 'c'=changed, 'd'=deleted', 'r'=relations changed, 'n'=new
Returns:
always true

nodeLocalChanged

public 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. Should be called by subclasses if they override it.
Parameters:
machine - Name of the machine that changed the node.
number - Number of the changed node as a String
builder - type of the changed node
ctype - command type, 'c'=changed, 'd'=deleted', 'r'=relations changed, 'n'=new
Returns:
always true

fieldLocalChanged

public 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.
Parameters:
number - Number of the changed node as a String
builder - type of the changed node
field - name of the changed field
value - value it changed to
Returns:
always true

addRemoteObserver

public boolean addRemoteObserver(MMBaseObserver obs)
Adds a remote observer to this builder. The observer is notified whenever an object of this builder is changed, added, or removed.
Returns:
always true

addLocalObserver

public boolean addLocalObserver(MMBaseObserver obs)
Adds a local observer to this builder. The observer is notified whenever an object of this builder is changed, added, or removed.
Returns:
always true

getDefaultTeaser

public MMObjectNode getDefaultTeaser(MMObjectNode node,
                                     MMObjectNode tnode)
Deprecated. Will be removed?

Used to create a default teaser by any builder

waitUntilNodeChanged

public boolean waitUntilNodeChanged(MMObjectNode node)
Waits until a node is changed (multicast).
Parameters:
node - the node to wait for

getList

public java.util.Vector getList(scanpage sp,
                                StringTagger tagger,
                                java.util.StringTokenizer tok)
                         throws ParseException
Obtains a list of string values by performing the provided command and parameters. This method is SCAN related and may fail if called outside the context of the SCAN servlet.
Parameters:
sp - The scanpage (containing http and user info) that calls the function
tagger - a Hashtable of parameters (name-value pairs) for the command
tok - a list of strings that describe the (sub)command to execute
Returns:
a Vector containing the result values as a String

replace

public java.lang.String replace(scanpage sp,
                                java.util.StringTokenizer tok)
Obtains a string value by performing the provided command. The command can be called:

process

public 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. This method is SCAN related and may fail if called outside the context of the SCAN servlet. The methood is currentkly called by the MMEDIT module, whenever a 'PRC-CMD-BUILDER-...' command is encountered in the list of commands to be processed.
Parameters:
sp - The scanpage (containing http and user info) that calls the function
command - a list of strings that describe the (sub)command to execute (the portion after ' PRC-CMD-BUILDER')
cmds - the commands (PRC-CMD) that are iurrently being processed, including the current command.
vars - variables (PRC-VAR) thatw ere set to be used during processing. the variable 'EDITSTATE' accesses the EditState object (if applicable).
Returns:
the result value as a String

convertMMNode2SQL

public java.lang.String convertMMNode2SQL(java.lang.String where)
Converts an MMNODE expression to SQL. MMNODE expressions are resolved by the database support classes. This means that some database-specific expressions can easier be converted.
Parameters:
where - the MMNODE expression
Returns:
the SQL clause as a String

setMMBase

public void setMMBase(MMBase m)
Set the MMBase object, and retrieve the database lasyer.
Parameters:
m - the MMBase object to set as owner of this builder

setDBLayout_xml

public void setDBLayout_xml(java.util.Hashtable fields)
Deprecated. sortedDBLayout should not be used any more. use the getFields(sortorder) method instead

Stores the fieldnames of a table in a vector, based on the current fields definition. The fields 'otype' and 'owner' become the first and second fieldnames.
Parameters:
fields - A list of the builder's FieldDefs

setTableName

public void setTableName(java.lang.String tableName)
Set tablename of the builder. Should be used to initialize a MMTable object before calling init().
Parameters:
the - name of the table

setDescription

public void setDescription(java.lang.String e)
Set description of the builder
Parameters:
the - description text

setDescriptions

public void setDescriptions(java.util.Hashtable e)
Set descriptions of the builder
Parameters:
a - Hashtable containing the descriptions

getDescription

public java.lang.String getDescription()
Get description of the builder
Returns:
the description text

getDescription

public java.lang.String getDescription(java.lang.String lang)
Gets description of the builder, using the specified language.
Parameters:
lang - The language requested

getDescriptions

public java.util.Hashtable getDescriptions()
Get descriptions of the builder
Returns:
a Hashtable containing the descriptions

setSearchAge

public void setSearchAge(java.lang.String age)
Sets search Age.
Parameters:
age - the search age as a String

getSearchAge

public java.lang.String getSearchAge()
Gets search Age
Returns:
the search age as a String

getSingularName

public java.lang.String getSingularName(java.lang.String lang)
Gets short name of the builder, using the specified language.
Parameters:
lang - The language requested
Returns:
the short name in that language, or null if it is not available

getSingularName

public java.lang.String getSingularName()
Gets short name of the builder in the current default language. If the current language is not available, the "en" version is returned instead. If that name is not available, the internal builder name (table name) is returned.
Returns:
the short name in either the default language or in "en"

getPluralName

public java.lang.String getPluralName(java.lang.String lang)
Gets long name of the builder, using the specified language.
Parameters:
lang - The language requested
Returns:
the long name in that language, or null if it is not available

getPluralName

public java.lang.String getPluralName()
Gets long name of the builder in the current default language. If the current language is not available, the "en" version is returned instead. If that name is not available, the singular name is returned.
Returns:
the long name in either the default language or in "en"

getClassName

public java.lang.String getClassName()
Deprecated. don't use

Returns the classname of this builder

sendFieldChangeSignal

public boolean sendFieldChangeSignal(MMObjectNode node,
                                     java.lang.String fieldname)
Send a signal to other servers that a field was changed.
Parameters:
node - the node the field was changed in
fieldname - the name of the field that was changed
Returns:
always true

signalNewObject

public boolean signalNewObject(java.lang.String tableName,
                               int number)
Send a signal to other servers that a new node was created.
Parameters:
tableName - the table in which a node was edited (?)
number - the number of the new node
Returns:
always true

toXML

public java.lang.String toXML(MMObjectNode node)
Converts a node to XML. This routine does not take into account invalid charaters (such as &ft;, <, &) in a datafield.
Parameters:
node - the node to convert
Returns:
the XML String

setSingularNames

public void setSingularNames(java.util.Hashtable names)
Sets a list of singular names (language - value pairs)

getSingularNames

public java.util.Hashtable getSingularNames()
Gets a list of singular names (language - value pairs)

setPluralNames

public void setPluralNames(java.util.Hashtable names)
Sets a list of plural names (language - value pairs)

getPluralNames

public java.util.Hashtable getPluralNames()
Gets a list of plural names (language - value pairs)

getShortedText

public java.lang.String getShortedText(java.lang.String fieldname,
                                       int number)
Get text from a blob field. the text is cut if it is to long.
Parameters:
fieldname - name of the field
number - number of the object in the table
Returns:
a String containing the contents of a field as text

getShortedByte

public byte[] getShortedByte(java.lang.String fieldname,
                             int number)
Get binary data of a database blob field. the data is cut if it is to long.
Parameters:
fieldname - name of the field
number - number of the object in the table
Returns:
an array of byte containing the contents of a field as text

getDBByte

public byte[] getDBByte(java.sql.ResultSet rs,
                        int idx)
Get binary data of a database blob field.
Parameters:
fieldname - name of the field
number - number of the object in the table
Returns:
an array of byte containing the contents of a field as text

getDBText

public java.lang.String getDBText(java.sql.ResultSet rs,
                                  int idx)
Get text from a blob field.
Parameters:
fieldname - name of the field
number - number of the object in the table
Returns:
a String containing the contents of a field as text

created

public boolean created()
Tests whether a builder table is created. XXX Should be moved to MMTable.
Overrides:
created in class MMTable
Returns:
true if the table exists, false otherwise

getNumberFromName

public java.lang.String getNumberFromName(java.lang.String name)
Returns the number of the node with the specified name. Tests whether a builder table is created. Should be moved to MMTable.
Returns:
true if the table exists, false otherwise

setValue

public boolean setValue(MMObjectNode node,
                        java.lang.String fieldName,
                        java.lang.Object originalValue)
Sets a key/value pair in the main values of this node. 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.
Parameters:
fieldname - the name of the field to change
fieldValue - the value to assign
originalValue - the value which was original in the field
Returns:
true When an update is required(when changed), false if original value was set back into the field.

setValue

public boolean setValue(MMObjectNode node,
                        java.lang.String fieldname)
Provides additional functionality when setting field values. This method is called whenever a Node of the builder's type tries to change a value. It allows the system to add functionality such as checking valid data. Derived builders should override this method if they want to add functionality.
Parameters:
node - the node whose fields are changed
field - the fieldname that is changed
Returns:
true if the call was handled.

getHTML

protected java.lang.String getHTML(java.lang.String body)
Returns a HTML-version of a string. This replaces a number of tokens with HTML sequences. The default output does not match well with the new xhtml standards (ugly html), nor does it replace all tokens. Default replacements can be overridden by setting the builder properties in your .xml: html.alinea html.endofline Example: <br /> <br /> <br />
Parameters:
body - text to convert
Returns:
the convert text

getWAP

protected java.lang.String getWAP(java.lang.String body)
Returns a WAP-version of a string. This replaces a number of tokens with WAP sequences.
Parameters:
body - text to convert
Returns:
the convert text

getURLEncode

protected java.lang.String getURLEncode(java.lang.String body)
Returns a URLEncoded-version (MIME x-www-form-urlencoded) of a string. This version uses the java.net.URLEncoder class to encode it.
Parameters:
body - text to convert
Returns:
the URLEncoded text

getShort

public java.lang.String getShort(java.lang.String str,
                                 int len)
Support routine to return shorter strings. Cuts a string to a amximum length if it exceeds the length specified.
Parameters:
str - the string to shorten
len - the maximum length
Returns:
the (possibly shortened) string

setXMLValues

public void setXMLValues(java.util.Vector xmlfields)
Stores fields information of this table. Asside from the fields supplied by the caller, a field 'otype' is added. This method calls setDBLayout_xml(java.util.Hashtable) to create a fieldnames list.
Parameters:
xmlfields - A Vector with fields as they appear in the current table. This data is retrieved from an outside source (such as an xml file), and thus may be incorrect.

setXMLPath

public void setXMLPath(java.lang.String m)
Sets the subpath of the builder's xml configuration file.

getXMLPath

public java.lang.String getXMLPath()
Retrieves the subpath of the builder's xml configuration file. Needed for builders that reside in subdirectories in the builder configuration file directory.

getConfigFile

public java.io.File getConfigFile()
Gets the file that contains the configuration of this builder
Returns:
the builders configuration File object

getInitParameters

public java.util.Hashtable getInitParameters()
Get all builder properties
Returns:
a Hashtable containing the current properties

setInitParameter

public void setInitParameter(java.lang.String name,
                             java.lang.String value)
Set a single builder property The propertie will not be saved.
Parameters:
name - name of the property
value - value of the property

getInitParameter

public java.lang.String getInitParameter(java.lang.String name)
Retrieve a specific property.
Parameters:
name - the name of the property to get
Returns:
the value of the property as a String

setVersion

public void setVersion(int i)
Sets the version of this builder
Parameters:
i - the version number

getVersion

public int getVersion()
Retrieves the version of this builder
Returns:
the version number

getMaintainer

public java.lang.String getMaintainer()
Retrieves the maintainer of this builder
Returns:
the name of the maintainer

setMaintainer

public void setMaintainer(java.lang.String m)
Sets the maintainer of this builder
Parameters:
m - the name of the maintainer

hostname_function

public 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

wrap

public java.lang.String wrap(java.lang.String text,
                             int width)
Wraps a string. Inserts newlines (\n) into a string at periodic intervals, to simulate wrapping. This also removes whitespace to the start of a line.
Parameters:
text - the text to wrap
width - the maximum width to wrap at
Returns:
the wrapped tekst

toString

public java.lang.String toString()
Implmenting a sensible toString is usefull for debugging.
Overrides:
toString in class java.lang.Object
Since:
MMBase-1.6.2

toString

public java.lang.String toString(MMObjectNode n)
Implements for MMObjectNode
Since:
MMBase-1.6.2

equals

public boolean equals(java.lang.Object o)
Equals must be implemented because of the list of MMObjectBuilder which is used for ancestors
Overrides:
equals in class java.lang.Object
Since:
MMBase-1.6.2

equals

public boolean equals(MMObjectNode o1,
                      MMObjectNode o2)
Implements equals for nodes (this is in MMObjectBuilder because you cannot override MMObjectNode)
Since:
MMBase-1.6.2

hashCode

public int hashCode(MMObjectNode o)
Implements for MMObjectNode
Since:
MMBase-1.6.2


MMBase build 1.6.5.20030923