org.mmbase.storage.database
Class SQL92DatabaseStorage

java.lang.Object
  |
  +--org.mmbase.storage.database.Support2Storage
        |
        +--org.mmbase.storage.database.AbstractDatabaseStorage
              |
              +--org.mmbase.storage.database.SQL92DatabaseStorage
All Implemented Interfaces:
DatabaseStorage, MMJdbc2NodeInterface, Storage
Direct Known Subclasses:
OODatabaseStorage, RelationalDatabaseStorage

public abstract class SQL92DatabaseStorage
extends AbstractDatabaseStorage
implements DatabaseStorage

SQL92DatabaseStorage extends AbstractDatabaseStorage to implement the basic functionality for creating and updating databse tables, using SQL. Most statements created here are ANSI SQL 92, with the exception of statements for creating extended tables (see create(org.mmbase.module.core.MMObjectBuilder, org.mmbase.storage.Transaction)). It does not take into account db-specific effects of inheritance - as various databases have their own methods, it may be necessary to override the create(org.mmbase.module.core.MMObjectBuilder, org.mmbase.storage.Transaction), insertIntoTable(org.mmbase.module.core.MMObjectBuilder, org.mmbase.module.core.MMObjectNode, org.mmbase.storage.database.DatabaseTransaction), commitToTable(org.mmbase.module.core.MMObjectBuilder, org.mmbase.module.core.MMObjectNode, org.mmbase.storage.database.DatabaseTransaction), and deleteFromTable(org.mmbase.module.core.MMObjectBuilder, org.mmbase.module.core.MMObjectNode, org.mmbase.storage.database.DatabaseTransaction) methods. The basic implementation of these methods assumes an OO-database that does not require the use of specific database routines (i.e. alternate SQL syntax). Furthermore, most sql statements are now contained in their own wrapper methods: createSQL(java.lang.String, java.lang.String, java.lang.String, java.lang.String), insertSQL(java.lang.String, java.lang.String, java.lang.String), updateSQL(java.lang.String, java.lang.String, int), deleteSQL(java.lang.String, int) and various methods for returning SQL SELECT statements. You can override these method to change the sql statements used by the database layer.

Since:
MMBase-1.6
Version:
$Id: SQL92DatabaseStorage.java,v 1.4.2.1 2003/02/21 11:58:51 michiel Exp $
Author:
Pierre van Rooden

Fields inherited from class org.mmbase.storage.database.AbstractDatabaseStorage
mmb
 
Fields inherited from interface org.mmbase.storage.database.DatabaseStorage
KEY_FOREIGN, KEY_NONE, KEY_NOTNULL, KEY_PRIMARY, KEY_SECONDARY
 
Constructor Summary
protected SQL92DatabaseStorage()
          Constructs the AbstractDatabaseSupport database layer support class
 
Method Summary
 boolean addField(MMObjectBuilder builder, java.lang.String fieldname)
          Adds a field to the table of this builder.
protected  java.lang.String applyCreateScheme(java.lang.String tableName, java.lang.String fieldDefinitions, java.lang.String parentTableName)
          Applies the create scheme (if available), and returns the result (a field type defintiton string)
 boolean changeField(MMObjectBuilder builder, java.lang.String fieldname)
          Changes a field to the table of this builder.
 boolean commit(MMObjectNode node, Transaction trans)
          Commit this node to the specified builder table within a transaction.
protected  boolean commitToTable(MMObjectBuilder builder, MMObjectNode node, DatabaseTransaction trans)
          Commit the changes to this node to the specified builder table.
 boolean create(MMObjectBuilder builder, Transaction trans)
          Create a database table for the specified builder.
 boolean created(MMObjectBuilder builder)
          Tells if a table for the builder already exists
 boolean created(java.lang.String tableName)
          Tells if a table already exists
 boolean createObjectStorage(Transaction trans)
          Create the object table (the basic table for all objects) within a transaction
protected  java.lang.String createSQL(java.lang.String tableName, java.lang.String fields, java.lang.String parentTableName, java.lang.String parentFields)
          Returns the SQL command to use for creating a specified table, optionally extending another supplied table.
 boolean delete(MMObjectNode node, Transaction trans)
          Delete a node within a transaction
 boolean deleteFromTable(MMObjectBuilder builder, MMObjectNode node, DatabaseTransaction trans)
          Remove a node from the specified builder table.
protected  java.lang.String deleteSQL(java.lang.String tableName, int number)
          Returns the SQL command to use for deleting an object in a table.
 boolean drop(MMObjectBuilder builder)
          Drops the table of this builder.
protected  java.lang.String dropSQL(java.lang.String tableName)
          Returns the SQL command to use for dropping a specified table Overide this method to add a database-specific syntax or optimalization
 byte[] getBytes(MMObjectNode node, java.lang.String fieldname)
          Get bytes from blob
protected abstract  byte[] getBytes(java.lang.String tableName, java.lang.String fieldname, int number)
          Get bytes from blob
protected  java.util.List getFieldsOrderCreate(MMObjectBuilder builder)
          Returns the fields of a builder in the order in which they should be created.
 MMObjectNode getNode(MMObjectBuilder builder, int number, Transaction trans)
          Select a node from a specified builder
 int getNodeType(int number, Transaction trans)
          Returns the nodetype for a specified nodereference
protected  MMObjectBuilder getParentBuilder(MMObjectBuilder builder)
          Returns the parent builder of the specifed builder.
protected  java.lang.String getParentTableName(MMObjectBuilder builder)
          Returns the name of the parent table of the specifed builder.
 java.lang.String getText(MMObjectNode node, java.lang.String fieldname)
          Get text from blob
protected abstract  java.lang.String getText(java.lang.String tableName, java.lang.String fieldname, int number)
          Get text from blob
 void init(MMBase mmb, XMLDatabaseReader document)
          Initializes the database layer.
 int insert(MMObjectNode node, Transaction trans)
          This method inserts a new object within a transaction, and registers the change.
protected  int insertIntoTable(MMObjectBuilder builder, MMObjectNode node, DatabaseTransaction trans)
          This method inserts a new object in a specified builder table.
protected  java.lang.String insertSQL(java.lang.String tableName, java.lang.String fieldNames, java.lang.String fieldValues)
          Returns the SQL command to use for inserting an object in a table.
 boolean isAllowedParentBuilder(MMObjectBuilder builder)
          Returns whether this database support layer allows for builder to be a parent builder (that is, other builders can 'extend' this builder and its database tables).
protected  boolean isParentField(MMObjectBuilder builder, java.lang.String fieldName)
          Tests whether the specified field is a member of the parent table of the specifed builder.
protected  void loadExistingTables()
          Load the names of the existing tables for this MMBase instance in memory.
 void loadFieldFromTable(MMObjectNode node, java.lang.String fieldname, java.sql.ResultSet rs, int i)
          Stores a field in a table ResultSet in a MMObjectNode.
protected  void loadSupportInformation()
          Load information on database support (i.e support of rollback).
protected  void prepare()
          Prepares the database layer.
protected  byte[] readBytesFromFile(java.lang.String filename)
          Reads a byte array from a file.
 boolean removeField(MMObjectBuilder builder, java.lang.String fieldname)
          Deletes a field from the table of this builder.
protected  java.lang.String selectSQL(java.lang.String tableName, java.lang.String fieldNames, java.lang.String where, java.lang.String orderby, int offset, int max)
          Returns the SQL command to use for selecting data from a table.
 boolean setValuePreparedStatement(java.sql.PreparedStatement stmt, MMObjectNode node, java.lang.String fieldname, int i)
          Set a prepared statement field i with value of key from the given node.
 int size(MMObjectBuilder builder)
          Return number of objects in a builder
 int size(java.lang.String tableName)
          Return number of entries consisting in given table.
 boolean supportsExtendedTables()
          Returns whether this storage layer supports extended tables.
 boolean supportsRollback()
          Returns whether rollback on storage level is supported.
protected  java.lang.String updateSQL(java.lang.String tableName, java.lang.String setFields, int number)
          Returns the SQL command to use for updating an object in a table.
 boolean updateStorage(MMObjectBuilder builder)
          Changes the storage of a builder to match its new configuration.
protected  boolean writeBytesToFile(java.lang.String filename, byte[] value)
          Writes a byte array to a file.
 
Methods inherited from class org.mmbase.storage.database.AbstractDatabaseStorage
applyForeignKeyScheme, applyKeyScheme, applyNotNullScheme, applyPrimaryKeyScheme, applyScheme, commit, constructFieldDefinition, constructFieldDefinition, create, createDatabaseTransaction, createDatabaseTransaction, createKey, createKey, createObjectStorage, createSQL, createTransaction, delete, deployDatabaseDocument, getBinaryFilePath, getCreateExtendedScheme, getCreateScheme, getFieldNameMap, getForeignKeyScheme, getFullTableName, getJDBC, getKeyScheme, getMaxDropSize, getNode, getNodeType, getNotNullScheme, getNumberString, getPrimaryKeyScheme, getStoreBinaryAsFile, getTypeMap, insert, mapToMMBaseFieldName, mapToTableFieldName, matchType, registerChanged, registerParentBuilder, selectSQL, selectSQL, selectSQL, setBinaryFilePath, setCreateExtendedScheme, setCreateScheme, setDBByte, setDBText, setFieldNameMap, setForeignKeyScheme, setKeyScheme, setMaxDropSize, setNotNullScheme, setPrimaryKeyScheme, setStoreBinaryAsFile, setTypeMap
 
Methods inherited from class org.mmbase.storage.database.Support2Storage
commit, createObjectTable, decodeDBnodeField, decodeDBnodeField, getAllowedField, getConnection, getDBByte, getDBKey, getDBText, getDisallowedField, getMMNodeSearch2SQL, getOTypeString, getOwnerString, getShortedByte, getShortedText, insert, removeNode, updateTable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.mmbase.storage.database.DatabaseStorage
deployDatabaseDocument, getBinaryFilePath, getCreateExtendedScheme, getCreateScheme, getFieldNameMap, getForeignKeyScheme, getJDBC, getKeyScheme, getMaxDropSize, getNotNullScheme, getPrimaryKeyScheme, getStoreBinaryAsFile, getTypeMap, mapToMMBaseFieldName, mapToTableFieldName, registerChanged, setBinaryFilePath, setCreateExtendedScheme, setCreateScheme, setFieldNameMap, setForeignKeyScheme, setKeyScheme, setMaxDropSize, setNotNullScheme, setPrimaryKeyScheme, setStoreBinaryAsFile, setTypeMap
 
Methods inherited from interface org.mmbase.storage.Storage
commit, create, createKey, createKey, createObjectStorage, createTransaction, delete, getNode, getNodeType, insert, registerParentBuilder
 

Constructor Detail

SQL92DatabaseStorage

protected SQL92DatabaseStorage()
Constructs the AbstractDatabaseSupport database layer support class
Method Detail

init

public void init(MMBase mmb,
                 XMLDatabaseReader document)
Initializes the database layer. This reads database specific content from the database configuration document.
Specified by:
init in interface DatabaseStorage
Overrides:
init in class AbstractDatabaseStorage
Parameters:
mmb - the MBase instance that uses this database layer
document - the database configuration document

loadExistingTables

protected void loadExistingTables()
Load the names of the existing tables for this MMBase instance in memory.

loadSupportInformation

protected void loadSupportInformation()
Load information on database support (i.e support of rollback).

prepare

protected void prepare()
Prepares the database layer. Override this method if you need to make preparations for your database.

supportsExtendedTables

public boolean supportsExtendedTables()
Returns whether this storage layer supports extended tables.
Specified by:
supportsExtendedTables in interface DatabaseStorage
Overrides:
supportsExtendedTables in class AbstractDatabaseStorage
Returns:
boolean true if extended tables are supported

supportsRollback

public boolean supportsRollback()
Returns whether rollback on storage level is supported.
Specified by:
supportsRollback in interface Storage
Overrides:
supportsRollback in class AbstractDatabaseStorage
Returns:
true if transactions are supported

applyCreateScheme

protected java.lang.String applyCreateScheme(java.lang.String tableName,
                                             java.lang.String fieldDefinitions,
                                             java.lang.String parentTableName)
Applies the create scheme (if available), and returns the result (a field type defintiton string)
Overrides:
applyCreateScheme in class AbstractDatabaseStorage
Parameters:
tableName - the table to create
fieldDefinitions - comma separated list of field definitions
parentTableName - the parent table (only used in OO databases)
Returns:
the applied scheme

createSQL

protected java.lang.String createSQL(java.lang.String tableName,
                                     java.lang.String fields,
                                     java.lang.String parentTableName,
                                     java.lang.String parentFields)
Returns the SQL command to use for creating a specified table, optionally extending another supplied table. Overide this method to add a database-specific syntax or optimalization Note that the default implementation uses Ansi SQL and ignores the parentTableName parameter, instead using parentFields to complete the table creation command.
Overrides:
createSQL in class AbstractDatabaseStorage
Parameters:
tableName - the name of the table to create
fields - the definitions of the fields
parentTableName - the name of the parent table. this value is null if the table to be created has no parent table. The table is assumed to exist.
parentFields - the definitions of the fields of the parent table (for use by relational databases)
Returns:
the sql query

dropSQL

protected java.lang.String dropSQL(java.lang.String tableName)
Returns the SQL command to use for dropping a specified table Overide this method to add a database-specific syntax or optimalization
Parameters:
tableName - the name of the table to drop
Returns:
the sql query

insertSQL

protected java.lang.String insertSQL(java.lang.String tableName,
                                     java.lang.String fieldNames,
                                     java.lang.String fieldValues)
Returns the SQL command to use for inserting an object in a table. Overide this method to add a database-specific syntax or optimalization
Overrides:
insertSQL in class AbstractDatabaseStorage
Parameters:
tableName - the name of the table where to insert
fieldNames - the names of the fields to insert
fieldValues - the values (generally '?' tokens that will be replaced) of the fields to insert
Returns:
the sql query

updateSQL

protected java.lang.String updateSQL(java.lang.String tableName,
                                     java.lang.String setFields,
                                     int number)
Returns the SQL command to use for updating an object in a table. Overide this method to add a database-specific syntax or optimalization
Overrides:
updateSQL in class AbstractDatabaseStorage
Parameters:
tableName - the name of the table where to update
setfields - the set-commands for the table fields, generally of the format 'field1=?, field2=? ...'
number - the number of the object to update
Returns:
the sql query

deleteSQL

protected java.lang.String deleteSQL(java.lang.String tableName,
                                     int number)
Returns the SQL command to use for deleting an object in a table. Overide this method to add a database-specific syntax or optimalization
Overrides:
deleteSQL in class AbstractDatabaseStorage
Parameters:
tableName - the name of the table where to delete
number - the number of the object to delete
Returns:
the sql query

selectSQL

protected java.lang.String selectSQL(java.lang.String tableName,
                                     java.lang.String fieldNames,
                                     java.lang.String where,
                                     java.lang.String orderby,
                                     int offset,
                                     int max)
Returns the SQL command to use for selecting data from a table. Overide this method to add a database-specific syntax or optimalization
Overrides:
selectSQL in class AbstractDatabaseStorage
Parameters:
tableName - the name of the table where to update
fieldNames - commaseparated list of fieldnames to retrieve, can be null (retrieve all fields)
where - constraints, can be null (no constraints)
orderby - optional fields to order by, can be null (no order)
offset - offset from where to select records. Note: if you specify an offset larger than 0, you have to specify max
max - maximum number of records, can be -1 (no max)
Returns:
the sql query

isAllowedParentBuilder

public boolean isAllowedParentBuilder(MMObjectBuilder builder)
Returns whether this database support layer allows for builder to be a parent builder (that is, other builders can 'extend' this builder and its database tables). The default behavior is to disallow any object other than "object" or "insrel". Database layers that support other builders should override this mnethod.
Specified by:
isAllowedParentBuilder in interface Storage
Overrides:
isAllowedParentBuilder in class AbstractDatabaseStorage
Parameters:
builder - the builder to test
Returns:
true if the builder can be extended
Since:
MMBase-1.6

setValuePreparedStatement

public boolean setValuePreparedStatement(java.sql.PreparedStatement stmt,
                                         MMObjectNode node,
                                         java.lang.String fieldname,
                                         int i)
                                  throws java.sql.SQLException
Set a prepared statement field i with value of key from the given node.
Specified by:
setValuePreparedStatement in interface DatabaseStorage
Overrides:
setValuePreparedStatement in class AbstractDatabaseStorage
Throws:
java.sql.SQLException - if an error occurred while filling in the fields

loadFieldFromTable

public void loadFieldFromTable(MMObjectNode node,
                               java.lang.String fieldname,
                               java.sql.ResultSet rs,
                               int i)
Stores a field in a table ResultSet in a MMObjectNode.
Specified by:
loadFieldFromTable in interface DatabaseStorage
Overrides:
loadFieldFromTable in class AbstractDatabaseStorage
Parameters:
node - the node to store the field in
fieldname - the name of the field as it is known to MMBase
rs - the ResultSet containing the table row
i - the index of the field in the ResultSet

getText

protected abstract java.lang.String getText(java.lang.String tableName,
                                            java.lang.String fieldname,
                                            int number)
Get text from blob
Overrides:
getText in class Support2Storage

getText

public java.lang.String getText(MMObjectNode node,
                                java.lang.String fieldname)
Get text from blob
Specified by:
getText in interface Storage
Overrides:
getText in class AbstractDatabaseStorage
Following copied from interface: org.mmbase.storage.Storage
Parameters:
node - the node to retrieve the text from
fieldname - the name of the field to retrieve
Returns:
the retrieved text

getBytes

protected abstract byte[] getBytes(java.lang.String tableName,
                                   java.lang.String fieldname,
                                   int number)
Get bytes from blob
Overrides:
getBytes in class Support2Storage

getBytes

public byte[] getBytes(MMObjectNode node,
                       java.lang.String fieldname)
Get bytes from blob
Specified by:
getBytes in interface Storage
Overrides:
getBytes in class AbstractDatabaseStorage
Following copied from interface: org.mmbase.storage.Storage
Parameters:
node - the node to retrieve the byte array from
fieldname - the name of the field to retrieve
Returns:
the retrieved byte array

insert

public int insert(MMObjectNode node,
                  Transaction trans)
           throws StorageException
This method inserts a new object within a transaction, and registers the change. Only fields with states of DBSTATE_PERSISTENT or DBSTATE_SYSTEM are stored in the database tables.
Specified by:
insert in interface Storage
Overrides:
insert in class AbstractDatabaseStorage
Parameters:
node - The node to insert
trans - the transaction to perform the insert in
Returns:
The (new) number for this node, or -1 if an error occurs.
Throws:
StorageException - if an error occurred during insert

insertIntoTable

protected int insertIntoTable(MMObjectBuilder builder,
                              MMObjectNode node,
                              DatabaseTransaction trans)
                       throws StorageException
This method inserts a new object in a specified builder table. It performs a simple insert statement (obtained with insertSQL(java.lang.String, java.lang.String, java.lang.String), using the name and fields of the specified builder. Override this method to add required code, such as recursive updates for relational databases. Only fields with states of DBSTATE_PERSISTENT or DBSTATE_SYSTEM are stored in the database tables.
Parameters:
builder - the builder to store the node in. This can be a parentbuilder of the node's actual builder
node - The node to insert
trans - the transaction to perform the insert in
Returns:
The (new) number for this node, or -1 if an error occurs.
Throws:
StorageException - if an error occurred during insert

commit

public boolean commit(MMObjectNode node,
                      Transaction trans)
               throws StorageException
Commit this node to the specified builder table within a transaction.
Specified by:
commit in interface Storage
Overrides:
commit in class AbstractDatabaseStorage
Parameters:
builder - the builder to commit the node to. This can be a parentbuilder of the node's actual builder
node - The node to commit
trans - the transaction to perform the insert in
Returns:
true of succesful, false otherwise
Throws:
StorageException - if an error occurred during commit

commitToTable

protected boolean commitToTable(MMObjectBuilder builder,
                                MMObjectNode node,
                                DatabaseTransaction trans)
                         throws StorageException
Commit the changes to this node to the specified builder table.
Parameters:
builder - the builder to commit the node to. This can be a parentbuilder of the node's actual builder
node - The node to commit
trans - the transaction to perform the insert in
Returns:
true if succesful, false otherwise
Throws:
StorageException - if an error occurred during commit

delete

public boolean delete(MMObjectNode node,
                      Transaction trans)
               throws StorageException
Delete a node within a transaction
Specified by:
delete in interface Storage
Overrides:
delete in class AbstractDatabaseStorage
Parameters:
node - The node to delete
trans - the transaction to perform the insert in
Returns:
true if succesful, false otherwise
Throws:
StorageException - if an error occurred during delete

deleteFromTable

public boolean deleteFromTable(MMObjectBuilder builder,
                               MMObjectNode node,
                               DatabaseTransaction trans)
                        throws StorageException
Remove a node from the specified builder table.
Parameters:
builder - the builder to remove the node from. This can be a parentbuilder of the node's actual builder
node - The node to delete
trans - the transaction to perform the insert in
Returns:
true if succesful, false otherwise
Throws:
StorageException - if an error occurred during delete

getNode

public MMObjectNode getNode(MMObjectBuilder builder,
                            int number,
                            Transaction trans)
                     throws StorageException
Select a node from a specified builder
Specified by:
getNode in interface Storage
Overrides:
getNode in class AbstractDatabaseStorage
Parameters:
builder - The builder to select from
number - the number of the node
trans - the transaction to perform the insert in
Returns:
the MMObjectNode that was found, or null f it doesn't exist
Throws:
StorageException - if an error occurred during selection

getNodeType

public int getNodeType(int number,
                       Transaction trans)
                throws StorageException
Returns the nodetype for a specified nodereference
Specified by:
getNodeType in interface Storage
Overrides:
getNodeType in class AbstractDatabaseStorage
Parameters:
number - the number of the node
trans - the transaction to perform the insert in
Returns:
int the object type or -1 if not found
Throws:
StorageException - if an error occurred during selection

getFieldsOrderCreate

protected java.util.List getFieldsOrderCreate(MMObjectBuilder builder)
Returns the fields of a builder in the order in which they should be created.
Note: order is not of import with this particular database layer, which refers to fields by name (not index). However, older databases DO rely on a specific order of the fields, specifically when inserting data. Also, some older routines in MMBase that still execute SQL on their own (shudder!) access fields on index. Therefor, this supportclass (and extending classes) should make sure the desired order is maintained.
Parameters:
builder - the buidler whose fields to retrieve and sort
Returns:
a list of fields.

getParentBuilder

protected MMObjectBuilder getParentBuilder(MMObjectBuilder builder)
Returns the parent builder of the specifed builder. If the value is null, the builder either has no parent, or its builder is the "object" table, but there was no builder created for this low-level table.
Parameters:
builder - the buidler to find the parent of
Returns:
the parent buidler or null if it cannot be determined

getParentTableName

protected java.lang.String getParentTableName(MMObjectBuilder builder)
Returns the name of the parent table of the specifed builder. If the value is null, the builder has no parent table.
Parameters:
builder - the builder to find the parent of
Returns:
the parent table or null if it has no parent

isParentField

protected boolean isParentField(MMObjectBuilder builder,
                                java.lang.String fieldName)
Tests whether the specified field is a member of the parent table of the specifed builder.
Parameters:
builder - the builder to find the parent of
fieldname - the name to test
Returns:
true if the field belongs to the parent table

create

public boolean create(MMObjectBuilder builder,
                      Transaction trans)
               throws StorageException
Create a database table for the specified builder.
Specified by:
create in interface Storage
Overrides:
create in class AbstractDatabaseStorage
Parameters:
builder - the builder to create the table for\
trans - the transaction to perform the insert in
Returns:
true if the table was succesfully created
Throws:
StorageException - if an error occurred during create

createObjectStorage

public boolean createObjectStorage(Transaction trans)
                            throws StorageException
Create the object table (the basic table for all objects) within a transaction
Specified by:
createObjectStorage in interface Storage
Overrides:
createObjectStorage in class AbstractDatabaseStorage
Parameters:
trans - the transaction to perform the insert in
Returns:
true if the table was succesfully created
Throws:
StorageException - if an error occurred during create

created

public boolean created(MMObjectBuilder builder)
Tells if a table for the builder already exists
Specified by:
created in interface Storage
Overrides:
created in class AbstractDatabaseStorage
Parameters:
builder - the builder to check
Returns:
true if table exists, false if table doesn't exists

created

public boolean created(java.lang.String tableName)
Tells if a table already exists
Parameters:
tableName - name of the table to check
Returns:
true if table exists, false if table doesn't exists

size

public int size(MMObjectBuilder builder)
Return number of objects in a builder
Specified by:
size in interface Storage
Overrides:
size in class AbstractDatabaseStorage
Parameters:
builder - the builder whose objects to count
Returns:
the number of objects the builder has, or -1 if the builder does not exist.

size

public int size(java.lang.String tableName)
Return number of entries consisting in given table. If the table does not exist, the function returns -1.
Parameters:
tableName - the table whose records to counted
Returns:
the number of items the table has, or -1 if the table does not exist.

writeBytesToFile

protected boolean writeBytesToFile(java.lang.String filename,
                                   byte[] value)
Writes a byte array to a file.
Parameters:
file - name the path of the file
value - the value to write
Returns:
true if succesful

readBytesFromFile

protected byte[] readBytesFromFile(java.lang.String filename)
Reads a byte array from a file.
Overrides:
readBytesFromFile in class Support2Storage
Parameters:
file - name the path of the file
Returns:
value the value read

drop

public boolean drop(MMObjectBuilder builder)
Drops the table of this builder.
Specified by:
drop in interface Storage
Overrides:
drop in class AbstractDatabaseStorage
Parameters:
builder - the builder whose table to drop
Returns:
true if succesful

addField

public boolean addField(MMObjectBuilder builder,
                        java.lang.String fieldname)
Adds a field to the table of this builder.
Specified by:
addField in interface Storage
Overrides:
addField in class AbstractDatabaseStorage
Parameters:
builder - the builder whose table to change
fieldname - the name fo the field to add
Returns:
true if succesful

removeField

public boolean removeField(MMObjectBuilder builder,
                           java.lang.String fieldname)
Deletes a field from the table of this builder.
Specified by:
removeField in interface Storage
Overrides:
removeField in class AbstractDatabaseStorage
Parameters:
builder - the builder whose table to change
fieldname - the name fo the field to delete
Returns:
true if succesful

changeField

public boolean changeField(MMObjectBuilder builder,
                           java.lang.String fieldname)
Changes a field to the table of this builder.
Specified by:
changeField in interface Storage
Overrides:
changeField in class AbstractDatabaseStorage
Parameters:
builder - the builder whose table to change
fieldname - the name fo the field to change
Returns:
true if succesful

updateStorage

public boolean updateStorage(MMObjectBuilder builder)
Changes the storage of a builder to match its new configuration.
Specified by:
updateStorage in interface Storage
Overrides:
updateStorage in class AbstractDatabaseStorage
Parameters:
builder - the builder whose table to change
Returns:
true if succesful


MMBase build 1.6.5.20030923