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).updateOnPk();
 		}
 
 		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 TODO provide reference to working example.

Version:
0.10 [19-6-2002]
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 select(java.lang.Object o, java.lang.Object condition)
          select an Object of the type of the Object o which match the supplied condition.
 java.util.Vector selectFromCondition(java.lang.Object o, Condition condition)
          select a collection of Objects of the type of the Object o which match the supplied condition.
 java.util.Vector selectFromParent(java.lang.Object o, java.lang.Object parent)
          select a collection of Objects of the type of the Objecto which match a defined relation with the parent.
 int update(java.lang.Object o)
          update an object of type o to the datastore
 

Method Detail

update

public int update(java.lang.Object o)
           throws java.lang.Exception
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:
Exception, - exception thrown from the specific data store controls, such as a JDBC driver
java.lang.Exception
See Also:
DataControl.updateOnPk()

insert

public int insert(java.lang.Object o)
           throws java.lang.Exception
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:
Exception, - exception thrown from the specific data store controls, such as a JDBC driver
java.lang.Exception
See Also:
DataControl.insert()

delete

public int delete(java.lang.Object o)
           throws java.lang.Exception
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:
Exception, - exception thrown from the specific data store controls, such as a JDBC driver
java.lang.Exception
See Also:
DataControl.updateOnPk()

select

public java.lang.Object select(java.lang.Object o,
                               java.lang.Object condition)
                        throws java.lang.Exception
select 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:
Exception, - exception thrown from the specific data store controls, such as a JDBC driver
java.lang.Exception
See Also:
DataControl.selectFromCondition(Condition), Condition

selectFromParent

public java.util.Vector selectFromParent(java.lang.Object o,
                                         java.lang.Object parent)
                                  throws java.lang.Exception
select a collection of Objects of the type of the Objecto which match a defined relation with the parent.

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.
parent - Object, this Object should contain the necessary information to make a relation with this Object
Returns:
A Vector of Objects which has a relation with the parent. Should return null if no relation could be established
Throws:
Exception, - exception thrown from the specific data store controls, such as a JDBC driver
java.lang.Exception
See Also:
DataControl.selectOnParent(Object)

selectFromCondition

public java.util.Vector selectFromCondition(java.lang.Object o,
                                            Condition condition)
                                     throws java.lang.Exception
select a collection 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 Vector of Objects which meet the condition. Should return null if no object meets the condition.
Throws:
Exception, - exception thrown from the specific data store controls, such as a JDBC driver
java.lang.Exception
See Also:
DataControl.selectFromCondition(Condition), Condition