org.mmbase.module.core
Class VirtualBuilder

Package class diagram package VirtualBuilder
java.lang.Object
  extended by org.mmbase.util.functions.FunctionProvider
      extended by org.mmbase.module.core.MMTable
          extended by org.mmbase.module.core.MMObjectBuilder
              extended by org.mmbase.module.core.VirtualBuilder
All Implemented Interfaces:
EventListener, NodeEventListener, RelationEventListener
Direct Known Subclasses:
ClusterBuilder, ResultBuilder, VirtualReferrerBuilder

public class VirtualBuilder
extends MMObjectBuilder

VirtualBuilder is a builder which creates 'virtual' nodes. This class is intended to facilitate practical creation of virtual builders by capturing events that migth otherwise lead to unexpected or faulty behavior.

Version:
$Id: VirtualBuilder.java 45315 2011-02-18 20:23:11Z michiel $
Author:
Pierre van Rooden

Field Summary
 
Fields inherited from class org.mmbase.module.core.MMObjectBuilder
AGE_PARAMETERS, broadCastChanges, DEFAULT_ALINEA, DEFAULT_EOL, description, descriptions, EVENT_TYPE_LOCAL, EVENT_TYPE_REMOTE, FIELD_NUMBER, FIELD_OBJECT_TYPE, FIELD_OWNER, fields, genericBlobCache, getFunctionsFunction, GUI_INDICATOR, GUI_PARAMETERS, guiFunction, infoFunction, internalVersion, maintainer, nodeCache, oType, pluralNames, searchAge, singularNames, SYSTEM_OWNER, TEMPNODE_DEFAULT_SIZE, temporaryNodes, TMP_FIELD_EXISTS, TMP_FIELD_NUMBER, TMP_FIELD_RESOLVED, virtual, WRAP_PARAMETERS, wrapFunction, xmlPath
 
Fields inherited from class org.mmbase.module.core.MMTable
maxNodesFromQuery, mmb, storageConnector, tableName
 
Fields inherited from class org.mmbase.util.functions.FunctionProvider
functions, getFunctions
 
Constructor Summary
  VirtualBuilder(MMBase m)
          Creates an instance of a Virtual builder.
protected VirtualBuilder(MMBase m, String tableName)
          Creates an instance of a Virtual builder and registers it in MMBase.
 
Method Summary
 boolean create()
          Creates a new builder table in the current database.
 int getDBState(String fieldName)
          Return a field's database state.
 Map<String,CoreField> getFields(MMObjectNode node)
          Get text from a blob field from a database.
 String getGUIIndicator(MMObjectNode node)
          What should a GUI display for this node.
 MMObjectNode getNewNode(String owner)
          Get a new node, using this builder as its parent.
protected  byte[] getShortedByte(String fieldName, MMObjectNode node)
          Get binary data of a blob field.
protected  String getShortedText(String fieldName, MMObjectNode node)
          Get text from a blob field.
 boolean init()
          Initializes this builder.
 int insert(String owner, MMObjectNode node)
          Insert a new object (content provided) in the cloud, including an entry for the object alias (if provided).
 
Methods inherited from class org.mmbase.module.core.MMObjectBuilder
addEventListener, addField, addLocalObserver, addRemoteObserver, broadcastChanges, checkAddTmpField, clearBlobCache, commit, createAlias, createAlias, createIfNotExists, delete, equals, equals, executeFunction, executeFunction, fieldLocalChanged, getAncestors, getBlobCache, getClassName, getConfigFile, getConfigResource, getDataTypeCollector, getDBType, getDefaultTeaser, getDefaultUrl, getDescendants, getDescription, getDescription, getDescriptions, getEmptyNode, getField, getFieldNames, getFields, getFields, getFunction, getFunctionParameters, getFunctions, getFunctionValue, getGUIIndicator, getGUIIndicator, getHTML, getInitParameter, getInitParameters, getInitParameters, getInternalVersion, getList, getLocaleGUIIndicator, getLocaleGUIIndicator, getMachineName, getMaintainer, getNewTmpNode, getNextField, getNextField, getNode, getNode, getNode, getNodeFromCache, getNodeGUIIndicator, getNumber, getObjectType, getObjectValue, getParentBuilder, getPluralName, getPluralName, getPluralNames, getRelations_main, getSearchAge, getShort, getShortedInputStream, getSingularName, getSingularName, getSingularNames, getSmartPath, getTmpNode, getURLEncode, getValue, getVersion, getWAP, getXMLPath, hasField, hashCode, hashCode, hostname_function, insert, isExtensionOf, isNodeCached, isNull, isVirtual, loadInitParameters, newFunctionInstance, nodeLocalChanged, nodeRemoteChanged, notify, notify, preCommit, process, putTmpNode, removeEventListener, removeField, removeLocalObserver, removeNode, removeRelations, removeRemoteObserver, removeSyncNodes, removeTmpNode, replace, safeCache, safeCommit, safeInsert, sendFieldChangeSignal, setDefaults, setDescription, setDescriptions, setFields, setInitParameter, setInitParameters, setMaintainer, setParentBuilder, setPluralNames, setSearchAge, setSingularNames, setUniqueValue, setUniqueValue, setValue, setValue, setVersion, setXMLPath, shutdown, testValidData, toString, toString, update, updateFields, wrap
 
Methods inherited from class org.mmbase.module.core.MMTable
count, count, created, getFullTableName, getMMBase, getNode, getNodes, getNodes, getNodes, getNodeType, getStorageConnector, getTableName, search, searchVector, setMMBase, setTableName, size
 
Methods inherited from class org.mmbase.util.functions.FunctionProvider
addFunction, createParameters, getFunction, getFunctions, getFunctionValue
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VirtualBuilder

public VirtualBuilder(MMBase m)
Creates an instance of a Virtual builder. A builder instantiated with this constrcutor is not registered in MMBase and should only be used as a temporary parent for virtual nodes which do not have a long life span.

Parameters:
m - the MMbase cloud creating the node

VirtualBuilder

protected VirtualBuilder(MMBase m,
                         String tableName)
Creates an instance of a Virtual builder and registers it in MMBase.

Parameters:
m - the MMbase cloud creating the node
tableName - the name of the builder as known in the MMbase system
Method Detail

init

public boolean init()
Initializes this builder. No specifici cation is performed. This method overrides the default emthod in MMObhjectBuilder, which would otherwise attempt to access the database.

Overrides:
init in class MMObjectBuilder
Returns:
Always true.
See Also:
create()

create

public boolean create()
Creates a new builder table in the current database. This method does not perform any action in a virtual builder, as there is no actual table associated with it.

Overrides:
create in class MMObjectBuilder

insert

public int insert(String owner,
                  MMObjectNode node)
Insert a new object (content provided) in the cloud, including an entry for the object alias (if provided). This method does not perform any action in a virtual builder.

Overrides:
insert in class MMObjectBuilder
Parameters:
owner - The administrator creating the node
node - The object to insert
Returns:
-1 (the insert failed)

getNewNode

public MMObjectNode getNewNode(String owner)
Get a new node, using this builder as its parent. The new node is a virtual node.

Overrides:
getNewNode in class MMObjectBuilder
Parameters:
owner - The administrator creating the new node.
Returns:
A newly initialized VirtualNode.

getGUIIndicator

public String getGUIIndicator(MMObjectNode node)
What should a GUI display for this node. Default the value returned is GUI_INDICATOR ('no info'). Override this to display your own choice (see Images.java). You may want to override MMObjectBuilder.getNodeGUIIndicator(MMObjectNode, org.mmbase.util.functions.Parameters) for more flexibility. The default behavior of a virtual node is to display the content of the 'name' field (if present). XXX: should be changed to something better

Overrides:
getGUIIndicator in class MMObjectBuilder
Parameters:
node - The node to display
Returns:
either the name field of the node or "no info"

getDBState

public int getDBState(String fieldName)
Return a field's database state. The default behavior for a virtual node is to return DBSTATE_VIRTUAL.

Overrides:
getDBState in class MMObjectBuilder
Parameters:
fieldName - the requested field's name
Returns:
DBSTATE_VIRTUAL

getShortedText

protected String getShortedText(String fieldName,
                                MMObjectNode node)
Get text from a blob field. This function is called to 'load' a field into the node, because it was not loaded together with the node, because it is supposed to be too big. Since virtual builders are generally not associated with a database, this method returns null.

Overrides:
getShortedText in class MMObjectBuilder
Parameters:
fieldName - name of the field
node -
Returns:
null

getShortedByte

protected byte[] getShortedByte(String fieldName,
                                MMObjectNode node)
Get binary data of a blob field. This function is called to 'load' a field into the node, because it was not loaded together with the node, because it is supposed to be too big. Since virtual builders are generally not associated with a database, this method returns null.

Overrides:
getShortedByte in class MMObjectBuilder
Parameters:
fieldName - name of the field
node -
Returns:
null

getFields

public Map<String,CoreField> getFields(MMObjectNode node)
Get text from a blob field from a database.

Since:
MMBase-1.8


MMBase2 Core 2.0-SNAPSHOT - 2013-05-29T22:08