org.mmbase.storage.implementation.database
Class JDBC2NodeWrapper

java.lang.Object
  extended byorg.mmbase.storage.implementation.database.JDBC2NodeWrapper
All Implemented Interfaces:
MMJdbc2NodeInterface, SearchQueryHandler

public class JDBC2NodeWrapper
extends java.lang.Object
implements MMJdbc2NodeInterface

Wrapper of MMJdbc2NodeInterface for the storage classes

Version:
$Id: JDBC2NodeWrapper.java,v 1.12.2.1 2004/09/07 12:58:46 pierre Exp $
Author:
Pierre van Rooden

Field Summary
 
Fields inherited from interface org.mmbase.storage.search.SearchQueryHandler
FEATURE_MAX_NUMBER, FEATURE_OFFSET, SUPPORT_NONE, SUPPORT_NORMAL, SUPPORT_OPTIMAL, SUPPORT_WEAK
 
Constructor Summary
JDBC2NodeWrapper(StorageManagerFactory factory)
           
 
Method Summary
 boolean addField(MMObjectBuilder bul, java.lang.String dbname)
           
 boolean changeField(MMObjectBuilder bul, java.lang.String dbname)
           
 boolean commit(MMObjectBuilder bul, MMObjectNode node)
           
 boolean create(MMObjectBuilder bul)
           
 boolean created(java.lang.String tableName)
          Tells if a table already exists
 boolean createObjectTable(java.lang.String baseName)
           
 MMObjectNode decodeDBnodeField(MMObjectNode node, java.lang.String fieldName, java.sql.ResultSet rs, int i)
          Sets the value of the field with name 'fieldName' in the node.
 MMObjectNode decodeDBnodeField(MMObjectNode node, java.lang.String fieldName, java.sql.ResultSet rs, int i, java.lang.String prefix)
           
 boolean drop(MMObjectBuilder bul)
           
 java.lang.String getAllowedField(java.lang.String disallowedField)
           
 MultiConnection getConnection(JDBCInterface jdbc)
           
 byte[] getDBByte(java.sql.ResultSet rs, int idx)
           
 int getDBKey()
          Gives an unique number for a node to be inserted.
 java.lang.String getDBText(java.sql.ResultSet rs, int idx)
           
 java.lang.String getDisallowedField(java.lang.String allowedfield)
           
 java.lang.String getMMNodeSearch2SQL(java.lang.String where, MMObjectBuilder bul)
          Converts an MMNODE expression to an SQL expression.
 java.util.List getNodes(SearchQuery query, MMObjectBuilder builder)
          Processes a search query, returns the result as a list of nodes.
 java.lang.String getNumberString()
           
 java.lang.String getOTypeString()
           
 java.lang.String getOwnerString()
           
 byte[] getShortedByte(java.lang.String tableName, java.lang.String fieldName, int number)
           
 java.lang.String getShortedText(java.lang.String tableName, java.lang.String fieldName, int number)
           
 int getSupportLevel(Constraint constraint, SearchQuery query)
          Gets the level at which a constraint is supported for a query by this handler.
 int getSupportLevel(int feature, SearchQuery query)
          Gets the level at which a feature is supported for a query by this handler.
 void init(MMBase mmb, XMLDatabaseReader parser)
           
 int insert(MMObjectBuilder bul, java.lang.String owner, MMObjectNode node)
           
 boolean isAllowedParentBuilder(MMObjectBuilder builder)
          Returns whether this database support layer allows for buidler to be a parent builder (that is, other builders can 'extend' this builder and its database tables).
 void registerParentBuilder(MMObjectBuilder parent, MMObjectBuilder child)
          Registers a builder as a parent builder (that is, other buidlers can 'extend' this builder and its database tables).
 boolean removeField(MMObjectBuilder bul, java.lang.String dbname)
           
 void removeNode(MMObjectBuilder bul, MMObjectNode node)
           
 void setDBByte(int i, java.sql.PreparedStatement stmt, byte[] bytes)
           
 boolean updateTable(MMObjectBuilder bul)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JDBC2NodeWrapper

public JDBC2NodeWrapper(StorageManagerFactory factory)
Method Detail

init

public void init(MMBase mmb,
                 XMLDatabaseReader parser)
Specified by:
init in interface MMJdbc2NodeInterface

isAllowedParentBuilder

public boolean isAllowedParentBuilder(MMObjectBuilder builder)
Description copied from interface: MMJdbc2NodeInterface
Returns whether this database support layer allows for buidler to be a parent builder (that is, other builders can 'extend' this builder and its database tables).

Specified by:
isAllowedParentBuilder in interface MMJdbc2NodeInterface
Parameters:
builder - the builder to test
Returns:
true if the builder can be extended

registerParentBuilder

public void registerParentBuilder(MMObjectBuilder parent,
                                  MMObjectBuilder child)
                           throws StorageException
Description copied from interface: MMJdbc2NodeInterface
Registers a builder as a parent builder (that is, other buidlers can 'extend' this builder and its database tables). At the least, this code should check whether the builder is allowed as a parent builder, and throw an exception if this is not possible. This method can be overridden to allow for optimization of code regarding such builders.

Specified by:
registerParentBuilder in interface MMJdbc2NodeInterface
Parameters:
parent - the parent builder to register
child - the builder to register as the parent's child
Throws:
StorageException

decodeDBnodeField

public MMObjectNode decodeDBnodeField(MMObjectNode node,
                                      java.lang.String fieldName,
                                      java.sql.ResultSet rs,
                                      int i)
Description copied from interface: MMJdbc2NodeInterface
Sets the value of the field with name 'fieldName' in the node. Using the given database result set. The value of the field will be taken from the i-th collumn of the result set. Note: This method may attempt to map the provided 'database' fieldname to the MMBase name. In very specific cases, this may not have the desired result.

Specified by:
decodeDBnodeField in interface MMJdbc2NodeInterface
Parameters:
node - The node from which a field must be set
fieldName - The name of the field which must be set. This is expected to be the field as used by the database, not the field as used by MMBase.
rs - The resultset from which the value of the field must be obtained
i - The integer indicating from which position the value must be gotten from the resultSet record.

decodeDBnodeField

public MMObjectNode decodeDBnodeField(MMObjectNode node,
                                      java.lang.String fieldName,
                                      java.sql.ResultSet rs,
                                      int i,
                                      java.lang.String prefix)
Specified by:
decodeDBnodeField in interface MMJdbc2NodeInterface
Parameters:
prefix - When using cluster nodes, the key of the value map of the node must be prefixed (e.g. with 'news.')
See Also:
MMJdbc2NodeInterface.decodeDBnodeField(MMObjectNode, String, ResultSet, int)

getMMNodeSearch2SQL

public java.lang.String getMMNodeSearch2SQL(java.lang.String where,
                                            MMObjectBuilder bul)
Description copied from interface: MMJdbc2NodeInterface
Converts an MMNODE expression to an SQL expression. Returns the result as an SQL where-clause, but with the leading "WHERE " left out.

Specified by:
getMMNodeSearch2SQL in interface MMJdbc2NodeInterface
Parameters:
where - The MMNODE expression.
bul - The builder for the type of nodes that is queried.
Returns:
The SQL expression.
See Also:
MMObjectBuilder.convertMMNode2SQL(String)

getShortedText

public java.lang.String getShortedText(java.lang.String tableName,
                                       java.lang.String fieldName,
                                       int number)
Specified by:
getShortedText in interface MMJdbc2NodeInterface
Warning: No Java Documentation Available.

getShortedByte

public byte[] getShortedByte(java.lang.String tableName,
                             java.lang.String fieldName,
                             int number)
Specified by:
getShortedByte in interface MMJdbc2NodeInterface
Warning: No Java Documentation Available.

getDBByte

public byte[] getDBByte(java.sql.ResultSet rs,
                        int idx)
Specified by:
getDBByte in interface MMJdbc2NodeInterface

getDBText

public java.lang.String getDBText(java.sql.ResultSet rs,
                                  int idx)
Specified by:
getDBText in interface MMJdbc2NodeInterface

insert

public int insert(MMObjectBuilder bul,
                  java.lang.String owner,
                  MMObjectNode node)
Specified by:
insert in interface MMJdbc2NodeInterface

commit

public boolean commit(MMObjectBuilder bul,
                      MMObjectNode node)
Specified by:
commit in interface MMJdbc2NodeInterface

removeNode

public void removeNode(MMObjectBuilder bul,
                       MMObjectNode node)
Specified by:
removeNode in interface MMJdbc2NodeInterface

getDBKey

public int getDBKey()
Gives an unique number for a node to be inserted. This method should be implemneted to work with multiple mmbase instances working on the same storage.

Specified by:
getDBKey in interface MMJdbc2NodeInterface
Returns:
unique number

setDBByte

public void setDBByte(int i,
                      java.sql.PreparedStatement stmt,
                      byte[] bytes)
Specified by:
setDBByte in interface MMJdbc2NodeInterface

created

public boolean created(java.lang.String tableName)
Description copied from interface: MMJdbc2NodeInterface
Tells if a table already exists

Specified by:
created in interface MMJdbc2NodeInterface
Returns:
true if table exists, false if table doesn't exists

create

public boolean create(MMObjectBuilder bul)
Specified by:
create in interface MMJdbc2NodeInterface

createObjectTable

public boolean createObjectTable(java.lang.String baseName)
Specified by:
createObjectTable in interface MMJdbc2NodeInterface

getConnection

public MultiConnection getConnection(JDBCInterface jdbc)
                              throws java.sql.SQLException
Specified by:
getConnection in interface MMJdbc2NodeInterface
Throws:
java.sql.SQLException

getDisallowedField

public java.lang.String getDisallowedField(java.lang.String allowedfield)
Specified by:
getDisallowedField in interface MMJdbc2NodeInterface

getAllowedField

public java.lang.String getAllowedField(java.lang.String disallowedField)
Specified by:
getAllowedField in interface MMJdbc2NodeInterface

getNumberString

public java.lang.String getNumberString()
Specified by:
getNumberString in interface MMJdbc2NodeInterface

getOwnerString

public java.lang.String getOwnerString()
Specified by:
getOwnerString in interface MMJdbc2NodeInterface

getOTypeString

public java.lang.String getOTypeString()
Specified by:
getOTypeString in interface MMJdbc2NodeInterface

drop

public boolean drop(MMObjectBuilder bul)
Specified by:
drop in interface MMJdbc2NodeInterface

updateTable

public boolean updateTable(MMObjectBuilder bul)
Specified by:
updateTable in interface MMJdbc2NodeInterface

addField

public boolean addField(MMObjectBuilder bul,
                        java.lang.String dbname)
Specified by:
addField in interface MMJdbc2NodeInterface

removeField

public boolean removeField(MMObjectBuilder bul,
                           java.lang.String dbname)
Specified by:
removeField in interface MMJdbc2NodeInterface

changeField

public boolean changeField(MMObjectBuilder bul,
                           java.lang.String dbname)
Specified by:
changeField in interface MMJdbc2NodeInterface

getSupportLevel

public int getSupportLevel(int feature,
                           SearchQuery query)
                    throws SearchQueryException
Description copied from interface: SearchQueryHandler
Gets the level at which a feature is supported for a query by this handler. This is one of either: Given the choice, the query handler with the highest level of support is prefered.

Specified by:
getSupportLevel in interface SearchQueryHandler
Throws:
SearchQueryException

getSupportLevel

public int getSupportLevel(Constraint constraint,
                           SearchQuery query)
                    throws SearchQueryException
Description copied from interface: SearchQueryHandler
Gets the level at which a constraint is supported for a query by this handler. This is one of either: Given the choice, the query handler with the highest level of support is prefered.

Specified by:
getSupportLevel in interface SearchQueryHandler
Throws:
SearchQueryException

getNodes

public java.util.List getNodes(SearchQuery query,
                               MMObjectBuilder builder)
                        throws SearchQueryException
Description copied from interface: SearchQueryHandler
Processes a search query, returns the result as a list of nodes. Depending on the specified builder, the results will be:

Specified by:
getNodes in interface SearchQueryHandler
Parameters:
query - The search query.
builder - The builder for the result nodes. Specify a ResultBuilder to get resultnodes. ClusterBuilder to get clusternodes.
Returns:
The resulting nodes.
Throws:
SearchQueryException
See Also:
ResultNode, ClusterNode


MMBase build 1.7.1.20041002