org.brains2b.data
Interface DataController


public interface DataController

Interface for a general Controller to use for all different data objects.

Implementation of this class should be able to find the DataControl implementation for the type of Object which is provided as paramters through the methods

Implementations would look something like:

                public int update(Object o) throws Exception {
                        return findDc(Object o).update();
                }
 
                public DataControl findDc(Object o) throws Exception {
                        //some method to find and instantiate the DataControl
                }

This interface is defined in general terms because no assumptions should be made about the type of datastore so the DataControl must be as general as possible. The most simple implementation would be using a JDBC connection, but you could also use it for XML or flat file datastorage

Version:
0.20 [16-01-2008]
Author:
dennis@brains2b.nl
See Also:
DataControl

Method Summary
 int delete(java.lang.Object o)
          delete an object of type o from the datastore
 int insert(java.lang.Object o)
          insert an object of type o to the datastore
 java.lang.Object retrieve(java.lang.Object o, Condition condition)
          retrieve an Object of the type of the Object o which match the supplied condition.
 java.util.List retrieveList(java.lang.Object o, Condition condition)
          retrieve a list of Objects of the type of the Object o which match the supplied condition.
 int update(java.lang.Object o)
          update an object of type o to the datastore
 

Method Detail

update

int update(java.lang.Object o)
           throws DataException
update an object of type o to the datastore

Parameters:
o - Object, the object to update
Returns:
int, the number or records updated, should always return one
Throws:
DataException, - exception thrown if the specific data store controls throw an Exception, such as a JDBC driver.
DataException
See Also:
DataControl.update()

insert

int insert(java.lang.Object o)
           throws DataException
insert an object of type o to the datastore

Parameters:
o - Object, the object to insert
Returns:
int, the number or records inserted, should always return one
Throws:
DataException, - exception thrown if the specific data store controls throw an Exception, such as a JDBC driver.
DataException
See Also:
DataControl.insert()

delete

int delete(java.lang.Object o)
           throws DataException
delete an object of type o from the datastore

Parameters:
o - Object, the object to delete
Returns:
int, the number or records deleted, should always return one
Throws:
DataException, - exception thrown if the specific data store controls throw an Exception, such as a JDBC driver.
DataException
See Also:
DataControl.update()

retrieve

java.lang.Object retrieve(java.lang.Object o,
                          Condition condition)
                          throws DataException
retrieve an Object of the type of the Object o which match the supplied condition.

Parameters:
o - Object the object which determines the type of objects you want to retrieve. An implementantion should not assume anything about the content of this Object and most implementations will ignore the values.
condition - Condition the condition which should be met by the retrieved objects
Returns:
An object which meets the condition. If more then one object meets the criteria implementations should only return the first one. Should return null if no object meets the condition.
Throws:
DataException, - exception thrown if the specific data store controls throw an Exception, such as a JDBC driver.
DataException
See Also:
DataControl.retrieveList(Condition), Condition

retrieveList

java.util.List retrieveList(java.lang.Object o,
                            Condition condition)
                            throws DataException
retrieve a list of Objects of the type of the Object o which match the supplied condition.

Parameters:
o - Object the object which determines the type of objects you want to retrieve. An implementantion should not assume anything about the content of this Object and most implementations will ignore the values.
condition - Condition the condition which should be met by the retrieved objects
Returns:
A list of Objects which meet the condition. Should return null if no object meets the condition.
Throws:
DataException, - exception thrown if the specific data store controls throw an Exception, such as a JDBC driver.
DataException
See Also:
DataControl.retrieveList(Condition), Condition