org.mmbase.module.corebuilders
Class OAlias

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.corebuilders.OAlias
All Implemented Interfaces:
EventListener, NodeEventListener, RelationEventListener

public class OAlias
extends MMObjectBuilder

The OAlias builder is an optional corebuilder used to associate aliases with nodes. Each OAlias object contains a name field (the alias), and a destination field (the number of the object referenced). This builder is not used directly. If you add aliases, use MMObjectBuilder.createAlias(int, java.lang.String, java.lang.String) instead of the builder's insert method. MMBase will run without this builder, but most applications use aliases.

Version:
$Id: OAlias.java 41871 2010-04-13 10:31:27Z michiel $
Author:
Rico Jansen, Michiel Meeuwissen

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, getFunctions, GUI_INDICATOR, GUI_PARAMETERS, guiFunction, infoFunction, internalVersion, nodeCache, oType, pluralNames, searchAge, singularNames, SYSTEM_OWNER, TEMPNODE_DEFAULT_SIZE, TMP_FIELD_EXISTS, TMP_FIELD_NUMBER, virtual, WRAP_PARAMETERS, wrapFunction
 
Fields inherited from class org.mmbase.module.core.MMTable
maxNodesFromQuery, mmb, storageConnector, tableName
 
Fields inherited from class org.mmbase.util.functions.FunctionProvider
functions
 
Constructor Summary
OAlias()
           
 
Method Summary
 void createAlias(String alias, int number)
          Creates an alias for the node with the given number, and updates the alias cache.
 void createAlias(String alias, int number, String owner)
          Creates an alias for the node with the given number, and updates the alias cache.
 String getAlias(int number)
          Obtain the alias of a node.
 MMObjectNode getAliasedNode(String alias)
          Obtain a node from the cloud through its alias
 List<String> getAliasList(int number)
          Obtain the aliases of a node.
 int getNumber(String name)
          Obtain the number of a node through its alias
 boolean init()
          Initializes this builder The property 'mmb' needs to be set for the builder before this method can be called.
 boolean nodeRemoteChanged(String machine, String number, String builder, String ctype)
          Called when a remote node is changed.
 void removeNode(MMObjectNode node)
          Remove a node from the cloud and update the cache
 
Methods inherited from class org.mmbase.module.core.MMObjectBuilder
addEventListener, addField, addLocalObserver, addRemoteObserver, broadcastChanges, checkAddTmpField, clearBlobCache, commit, create, createAlias, createAlias, delete, equals, equals, executeFunction, executeFunction, fieldLocalChanged, getAncestors, getBlobCache, getClassName, getConfigFile, getConfigResource, getDataTypeCollector, getDBState, getDBType, getDefaultTeaser, getDefaultUrl, getDescendants, getDescription, getDescription, getDescriptions, getEmptyNode, getField, getFieldNames, getFields, getFields, getFunction, getFunctionParameters, getFunctions, getGUIIndicator, getGUIIndicator, getGUIIndicator, getHTML, getInitParameter, getInitParameters, getInitParameters, getInternalVersion, getList, getLocaleGUIIndicator, getLocaleGUIIndicator, getMachineName, getMaintainer, getNewNode, getNewTmpNode, getNextField, getNextField, getNode, getNode, getNode, getNodeFromCache, getNodeGUIIndicator, getNumber, getObjectType, getObjectValue, getParentBuilder, getPluralName, getPluralName, getPluralNames, getRelations_main, getSearchAge, getShort, getShortedByte, getShortedInputStream, getShortedText, getSingularName, getSingularName, getSingularNames, getSmartPath, getTmpNode, getURLEncode, getValue, getVersion, getWAP, getXMLPath, hasField, hashCode, hashCode, hostname_function, insert, insert, isExtensionOf, isNodeCached, isNull, isVirtual, loadInitParameters, newFunctionInstance, nodeLocalChanged, notify, notify, preCommit, process, removeEventListener, removeField, removeLocalObserver, removeRelations, removeRemoteObserver, removeSyncNodes, replace, safeCache, sendFieldChangeSignal, setDefaults, setDescription, setDescriptions, setFields, setInitParameter, setMaintainer, 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

OAlias

public OAlias()
Method Detail

init

public boolean init()
Description copied from class: MMObjectBuilder
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.

Overrides:
init in class MMObjectBuilder
Returns:
true if init was completed, false if uncompleted.
See Also:
MMObjectBuilder.create()

getNumber

public int getNumber(String name)
Obtain the number of a node through its alias

Parameters:
name - the alias of the desired node
Returns:
the number of the node, or -1 if the alias does not exist
See Also:
getAliasedNode(java.lang.String)

getAlias

public String getAlias(int number)
Obtain the alias of a node. If a node has more aliases, it returns only one. Which one is not specified.

Parameters:
number - the number of the node
Returns:
the alias of the node, or null if it does not exist
See Also:
getNumber(java.lang.String)
To Do:
No caching here?

getAliasList

public List<String> getAliasList(int number)
Obtain the aliases of a node. If a node has more aliases, it returns only one. Which one is not specified.

Parameters:
number - the number of the node
Returns:
a List of the aliases of the node, or an emoty list if none exist
See Also:
getAlias(int)

getAliasedNode

public MMObjectNode getAliasedNode(String alias)
Obtain a node from the cloud through its alias

Parameters:
alias - the alias of the desired node
Returns:
the node, or null if the alias does not exist
Throws:
RuntimeException - if the alias exists but the node itself doesn't (this indicates an inconsistency in the database)
See Also:
getNumber(java.lang.String)

createAlias

public void createAlias(String alias,
                        int number)
Creates an alias for the node with the given number, and updates the alias cache.

Since:
MMBase-1.7

createAlias

public void createAlias(String alias,
                        int number,
                        String owner)
Creates an alias for the node with the given number, and updates the alias cache.

Since:
MMBase-1.8

removeNode

public void removeNode(MMObjectNode node)
Remove a node from the cloud and update the cache

Overrides:
removeNode in class MMObjectBuilder
Parameters:
node - The node to remove.

nodeRemoteChanged

public boolean nodeRemoteChanged(String machine,
                                 String number,
                                 String builder,
                                 String ctype)
Called when a remote node is changed. Should be called by subclasses if they override it. If a node is changed or newly created, this adds the new or updated alias to the cache.

Overrides:
nodeRemoteChanged in class MMObjectBuilder
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
Since:
MMBase-1.7.1


MMBase 2.0-SNAPSHOT - null