org.mmbase.module.core
Class MMTable

java.lang.Object
  extended byorg.mmbase.util.functions.FunctionProvider
      extended byorg.mmbase.module.core.MMTable
Direct Known Subclasses:
MMObjectBuilder

public abstract class MMTable
extends FunctionProvider

MMTable is the base abstraction of a cloud of objects stored in one database table, essentially a cloud of objects of the same type. It provides a starting point for MMObjectBuilder by defining a scope - the database table - and basic functionality to create the table and query properties such as its size. This class does not contain actual management of nodes (this is left to MMOBjectBuilder).

Version:
$Id: MMTable.java,v 1.23 2006/06/16 09:08:42 michiel Exp $
Author:
Daniel Ockeloen, Pierre van Rooden (javadoc)

Field Summary
protected  int maxNodesFromQuery
          Maximum number of nodes to return on a query (-1 means no limit, and is also the default)
protected  MMBase mmb
          The MMBase module that this table belongs to
protected  StorageConnector storageConnector
           
protected  String tableName
          The table name
 
Fields inherited from class org.mmbase.util.functions.FunctionProvider
functions, getFunctions
 
Constructor Summary
MMTable()
          Empty constructor.
 
Method Summary
 int count(NodeSearchQuery query)
          Counts number of nodes matching a specified constraint.
 int count(String where)
          Deprecated. Use count(NodeSearchQuery) instead.
 boolean created()
          Check whether the table is accessible.
 String getFullTableName()
          Retrieve the full table name (including the clouds' base name)
 MMBase getMMBase()
          Return the MMBase object
 MMObjectNode getNode(int number, boolean useCache)
          Retrieves a node based on it's number (a unique key).
 List getNodes()
          Returns all the nodes from the builder.
protected  List getNodes(Collection virtuals)
          Convert virtual nodes to real nodes based on their otype Normally a multirelations-search will return virtual nodes.
 List getNodes(NodeSearchQuery query)
          Returns nodes matching a specified constraint.
 int getNodeType(int number)
          Retrieves an object's type.
 StorageConnector getStorageConnector()
           
 String getTableName()
          Retrieve the table name (without the clouds' base name)
 Enumeration search(String where)
          Deprecated. Use getNodes(NodeSearchQuery to perform a node search.
 Vector searchVector(String where)
          Deprecated. Use getNodes(NodeSearchQuery to perform a node search.
 void setMMBase(MMBase m)
          Set the MMBase object, and retrieve the storage layer.
 void setTableName(String tableName)
          Set tablename of the builder.
 int size()
          Determine the number of objects in this table.
 
Methods inherited from class org.mmbase.util.functions.FunctionProvider
addFunction, createParameters, getFunction, getFunctions, getFunctionValue, newFunctionInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mmb

protected MMBase mmb
The MMBase module that this table belongs to


tableName

protected String tableName
The table name


maxNodesFromQuery

protected int maxNodesFromQuery
Maximum number of nodes to return on a query (-1 means no limit, and is also the default)


storageConnector

protected StorageConnector storageConnector
Constructor Detail

MMTable

public MMTable()
Empty constructor.

Method Detail

setMMBase

public void setMMBase(MMBase m)
Set the MMBase object, and retrieve the storage layer.

Parameters:
m - the MMBase object to set as owner of this builder

getMMBase

public MMBase getMMBase()
Return the MMBase object

Since:
1.7

setTableName

public void setTableName(String tableName)
Set tablename of the builder. Should be used to initialize a MMTable object before calling init().

Parameters:
tableName - the name of the table

getTableName

public String getTableName()
Retrieve the table name (without the clouds' base name)

Returns:
a String containing the table name
Since:
MMBase-1.7

getFullTableName

public String getFullTableName()
Retrieve the full table name (including the clouds' base name)

Returns:
a String containing the full table name
Since:
MMBase-1.7

size

public int size()
Determine the number of objects in this table.

Returns:
The number of entries in the table.

created

public boolean created()
Check whether the table is accessible. In general, this means the table does not exist. Please note that this routine may also return false if the table is inaccessible due to insufficient rights.

Returns:
true if the table is accessible, false otherwise.

getStorageConnector

public StorageConnector getStorageConnector()

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, the key is invalid,or a MMObjectNode containing the contents of the requested node.
To Do:
when something goes wrong, the method currently catches the exception and returns null. It should actually throw a NotFoundException instead.

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.
To Do:
when something goes wrong, the method currently catches the exception and returns -1. It should actually throw a NotFoundException instead.

getNodes

protected List getNodes(Collection 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:
virtuals - containing virtual nodes
Returns:
List containing real nodes, directly from this Builders
Since:
MMBase-1.6.2

count

public int count(String where)
Deprecated. Use count(NodeSearchQuery) instead.

Counts number of nodes matching a specified constraint.

Parameters:
where - The constraint, can be a SQL where-clause, a MMNODE expression or an altavista-formatted expression.
Returns:
The number of nodes, or -1 when failing to retrieve the data.

count

public int count(NodeSearchQuery query)
          throws SearchQueryException
Counts number of nodes matching a specified constraint. The constraint is specified by a query that selects nodes of a specified type, which must be the nodetype corresponding to this builder.

Parameters:
query - The query.
Returns:
The number of nodes.
Throws:
IllegalArgumentException - when an invalid argument is supplied.
SearchQueryException - when failing to retrieve the data.
Since:
MMBase-1.7

getNodes

public List getNodes(NodeSearchQuery query)
              throws SearchQueryException
Returns nodes matching a specified constraint. The constraint is specified by a query that selects nodes of a specified type, which must be the nodetype corresponding to this builder.

Parameters:
query - The query.
Returns:
The nodes.
Throws:
IllegalArgumentException - When the nodetype specified by the query is not the nodetype corresponding to this builder.
SearchQueryException
Since:
MMBase-1.7

search

public Enumeration search(String where)
Deprecated. Use getNodes(NodeSearchQuery to perform a node search.

Enumerate all the objects that match the searchkeys

Parameters:
where - scan expression that the objects need to fulfill
Returns:
an Enumeration containing all the objects that apply.

searchVector

public Vector searchVector(String where)
Deprecated. Use getNodes(NodeSearchQuery to perform a node search.

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.

getNodes

public List getNodes()
Returns all the nodes from the builder.

Returns:
The nodes.


MMBase build 1.8.1.20060716