org.openxava.tab.impl
Class JDBCTabProvider

java.lang.Object
  extended by org.openxava.tab.impl.JDBCTabProvider
All Implemented Interfaces:
java.io.Serializable, ISearch, ITabProvider

public class JDBCTabProvider
extends java.lang.Object
implements ITabProvider, java.io.Serializable

An ITabProvider that obtain data via JDBC.

It is a JavaBean and allows set properties as table name, fields, search condition, etc.
Before use this object is advisable call to invariant().

Author:
Javier Paniza
See Also:
Serialized Form

Constructor Summary
JDBCTabProvider()
           
 
Method Summary
 int getChunkSize()
          Size of chunk returned by nextChunk().
 java.lang.String[] getConditions()
          List of codition in SQL format.
 IConnectionProvider getConnectionProvider()
          To obtaint JDBC connections.
 int getCurrent()
           
 java.lang.String[] getFields()
           
 int getResultSize()
          Record (or object, or row) count of last consult.
 java.lang.Number getSum(java.lang.String column)
           
 java.lang.String getTable()
          Database table name.
 void invariant()
          Verify invariant.
 DataChunk nextChunk()
          Obtain the next data chunk.
 void reset()
          If you call this method the next time that you call ITabProvider.nextChunk() you will obtain the first chunk and fresh data from db.
 void search(int index, java.lang.Object key)
          Execute the search.
 void search(java.lang.String condition, java.lang.Object key)
          Execute search.
 void setChunkSize(int chunkSize)
          Size of chunk returned by nextChunk().
 void setConditions(java.lang.String[] conditions)
          List of codition in SQL format.
 void setConnectionProvider(IConnectionProvider connectionProvider)
          To obtaint JDBC connections.
 void setCurrent(int i)
           
 void setFields(java.lang.String[] fields)
          Table fields to include.
 void setTable(java.lang.String tabla)
          Database table name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JDBCTabProvider

public JDBCTabProvider()
Method Detail

search

public void search(int index,
                   java.lang.Object key)
            throws FinderException,
                   java.rmi.RemoteException
Description copied from interface: ISearch
Execute the search.

If there are no object then generate a empty result, but does not throw a exception.

Specified by:
search in interface ISearch
Parameters:
index - Index of serach to execute
key - Key to send to search
Throws:
FinderException - Any logic problem on search
java.rmi.RemoteException - Any system problem on search

search

public void search(java.lang.String condition,
                   java.lang.Object key)
            throws FinderException,
                   java.rmi.RemoteException
Description copied from interface: ISearch
Execute search.

If there are no object then generate a empty result, but does not throw a exception.

Specified by:
search in interface ISearch
Parameters:
condition - Condition to use in search.
key - Key to send to search
Throws:
FinderException - Any logic problem on search
java.rmi.RemoteException - Any system problem on search

getFields

public java.lang.String[] getFields()

getConditions

public java.lang.String[] getConditions()
List of codition in SQL format.

The condition can be:

Although complete SELECTs are used in all cases is necessary to specify a correct value for fields and table.
When you use complete SELECTs the table and fields used in SELECT must to match with fields and table.


getConnectionProvider

public IConnectionProvider getConnectionProvider()
To obtaint JDBC connections.


getTable

public java.lang.String getTable()
Database table name.


getChunkSize

public int getChunkSize()
Size of chunk returned by nextChunk().


invariant

public void invariant()
               throws java.lang.IllegalStateException
Verify invariant.

Invariant:

Throws:
java.lang.IllegalStateException - If invariant is broken

setFields

public void setFields(java.lang.String[] fields)
Table fields to include.


setConditions

public void setConditions(java.lang.String[] conditions)
List of codition in SQL format.

The condition can be:

Although complete SELECTs are used in all cases is necessary to specify a correct value for fields and table.
When you use complete SELECTs the table and fields used in SELECT must to match with fields and table.


setConnectionProvider

public void setConnectionProvider(IConnectionProvider connectionProvider)
To obtaint JDBC connections.


setTable

public void setTable(java.lang.String tabla)
Database table name.


setChunkSize

public void setChunkSize(int chunkSize)
Size of chunk returned by nextChunk().


nextChunk

public DataChunk nextChunk()
                    throws java.rmi.RemoteException
Description copied from interface: ITabProvider
Obtain the next data chunk.

This method can be call from a TableModel to obtain data on demand.

Specified by:
nextChunk in interface ITabProvider
Throws:
java.rmi.RemoteException

getCurrent

public int getCurrent()

setCurrent

public void setCurrent(int i)

getResultSize

public int getResultSize()
                  throws java.rmi.RemoteException
Description copied from interface: ITabProvider
Record (or object, or row) count of last consult.

Specified by:
getResultSize in interface ITabProvider
Throws:
java.rmi.RemoteException

getSum

public java.lang.Number getSum(java.lang.String column)
                        throws java.rmi.RemoteException
Specified by:
getSum in interface ITabProvider
Throws:
java.rmi.RemoteException

reset

public void reset()
           throws java.rmi.RemoteException
Description copied from interface: ITabProvider
If you call this method the next time that you call ITabProvider.nextChunk() you will obtain the first chunk and fresh data from db.

Specified by:
reset in interface ITabProvider
Throws:
java.rmi.RemoteException