All Packages  Class Hierarchy  This Package  Previous  Next  Index

Interface interbase.interclient.Adaptor

public interface Adaptor
InterClient Extension

The Adaptor interface is used to modify (adapt) the behavior of an InterClient JDBC object in order to improve performance for certain applications which do not require the full implementation of JDBC standard behavior for that object.

A JDBC class which implements this interface is said to be adaptable. The Adaptor interface can be implemented by any JDBC class which can be adapted for improved performance under certain assumptions. An adaptation modifies the default behavior for a JDBC object by compromising standard JDBC behavior in favor of performance.

Certain JDBC driver classes may choose to implement this interface for enhanced performance with the JBuilder dataset components. Currently, JBuilder only looks for ResultSet adaptations. Future versions of JBuilder may be able to use this for other InterClient package objects.

Here's an example adaptation of a result set object which instructs the driver to right trim CHAR string instances, and to avoid constructing multiple java.sql.Date instances by reusing the first Date fetched on each subsequent fetch.

 import interbase.interclient.Adaptor;
 java.sql.Statement s = c.createStatement ();
 java.sql.ResultSet rs = s.executeQuery ("select NAME, BIRTHDAY from BIRTHDAYS");
 Adaptor rsAdaptor = (Adaptor) rs;
 rsAdaptor.adapt (Adaptor.RIGHT_TRIM_STRINGS, null);
 rsAdaptor.adapt (Adaptor.SINGLE_INSTANCE_TIME, null);
 while (rs.next ()) {
   System.out.println (rs.getString ("NAME"));    // no need to call trim()
   System.out.println (rs.getDate ("BIRTHDAY"));  // The first Date object constructed is reused 
 }                                                // and modified throughout the iterations.
 

Additional modifiers may be added in future releases.

A third party tool built to run with any or multiple JDBC drivers could be compiled with this interface in its class path in order to leverage performance improvements when using the InterClient driver as follows:

 java.sql.ResultSet resultSetToProcess = ...
 try {
   Class.forName ("interbase.interclient.Adaptor");
   interbase.interclient.Adaptor adaptor = (interbase.interclient.Adaptor) resultSetToProcess;
   adaptor.adapt (SINGLE_INSTANCE_TIME, null);
 }
 catch (ClassNotFoundException e) { // no adaptor found, that's ok }
 process (resultSetToProcess);
 
The performance of the 3rd party application will be greatly improved when InterClient is loaded as the JDBC driver backend, even if no other InterClient extensions are used, and the application makes only portable java.sql method calls.

Notice that a 3rd party tool provider needs to compile with the interbase.interclient.Adaptor interface in the class path, but does not need to compile with the complete interbase.interclient package unless it is using other InterClient extensions to the JDBC API.

Also notice that the Adaptor interface does NOT need to be shipped along with the 3rd party product. The Adaptor interface need not be present at run-time since the Adaptor declaration and call to adapt is only executed when the interbase.interclient.Adaptor class has been loaded.

InterClient VARs or those wishing to redistribute the Adaptor interface with a 3rd party app may prefer the following code:

 import interbase.interclient.Adaptor;
 java.sql.ResultSet resultSetToProcess = ...
 if (resultSetToProcess instanceof Adaptor) {
   Adaptor adaptor = (Adaptor) resultSetToProcess;
   adaptor.adapt (SINGLE_INSTANCE_TIME, null);
 }
 process (resultSetToProcess);
 
This Adaptor may be freely distributed along with 3rd party applications.

Other JDBC drivers may have their own peculiar adaptations and interfaces.


Variable Index

 o RIGHT_TRIM_STRINGS
This modifier instructs an adaptable JDBC object to create String instances with white space already trimmed from the end of the String on calls to ResultSet.getString ().
 o SINGLE_INSTANCE_TIME
This modifier instructs an adaptable JDBC object to reuse a single instance of a Java Time/Date/Timestamp object on calls to ResultSet.getDate(), ResultSet.getTime() and ResultSet.getTimestamp ().

Method Index

 o adapt(int, Object)
Adapt the JDBC object which implements this interface to the modification described by one of the above modifiers.
 o revert(int)
Revert back to the default JDBC behavior for the object previously adapted for the modification described by the given modifier.

Variables

 o RIGHT_TRIM_STRINGS
  public final static int RIGHT_TRIM_STRINGS
This modifier instructs an adaptable JDBC object to create String instances with white space already trimmed from the end of the String on calls to ResultSet.getString ().

 o SINGLE_INSTANCE_TIME
  public final static int SINGLE_INSTANCE_TIME
This modifier instructs an adaptable JDBC object to reuse a single instance of a Java Time/Date/Timestamp object on calls to ResultSet.getDate(), ResultSet.getTime() and ResultSet.getTimestamp ().

Methods

 o adapt
  public abstract boolean adapt(int modifier,
                                Object extraInfo) throws SQLException
Adapt the JDBC object which implements this interface to the modification described by one of the above modifiers.

Parameters:
modifier - is either RIGHT_TRIM_STRINGS, SINGLE_INSTANCE_TIME
extraInfo - Any extra information that needs to be specified along with the modifier.
Returns:
true if the modifier is supported, false otherwise.
Throws: SQLException
If driver is unable to adapt to the modification..
 o revert
  public abstract void revert(int modifier) throws SQLException
Revert back to the default JDBC behavior for the object previously adapted for the modification described by the given modifier.

Parameters:
modifier - is either RIGHT_TRIM_STRINGS, SINGLE_INSTANCE_TIME
Throws: SQLException
If driver is unable to revert the modification back to the standard JDBC behavior.

All Packages  Class Hierarchy  This Package  Previous  Next  Index