org.hydrateframework
Interface KeyAssembler


public interface KeyAssembler

The KeyAssembler interface is implemented by classes that know how to build the elements of a key from a results set. It is similar, but simpler than a Assembler interface and is implemented by an inner class, RefBld of each of the generated key classes.

Version:
@(#)$Revision: 1.1 $
Author:
David Chamberlin

Method Summary
 ObjectKey getKey()
          Make the key that this assembler has been created to build.
 java.lang.Class getKeyClass()
          Returns the Class object that represents the class of key that this assembler will build.
 boolean isAllocatedByDb()
          Indicate whether this key was allocated by the database.
 ObjectKey makeKeyFromInt(int defPrimary)
          Makes a key from a single integer.
 ObjectKey makeKeyFromValues(java.lang.Object[] keys)
          Makes the key from the given array of objects.
 void prepareToProcessResults(java.sql.ResultSet rs, Assembler bld)
          This method is called after a statement has been executed, but before iterating through the results set.
 boolean readState(java.sql.ResultSet rs)
          The implementation of this method reads the data values from the current row of the results set to make a key.
 void writeState(java.sql.ResultSet rs, java.lang.Object x)
          This method updates the fields associated with this key in the given results set.
 

Method Detail

prepareToProcessResults

void prepareToProcessResults(java.sql.ResultSet rs,
                             Assembler bld)
This method is called after a statement has been executed, but before iterating through the results set. It gives the key assembler an opportunity to find the indexes of the fields that it is interested in to know whether it is possible to build a key from this query and if so, save the look up time for the named key fields when iterating through the query.

Parameters:
rs - the results set that has just been returned.
bld - the assembler that will build the object which this key will reference. The column map is taken from that assembler.

readState

boolean readState(java.sql.ResultSet rs)
                  throws java.sql.SQLException
The implementation of this method reads the data values from the current row of the results set to make a key.

Parameters:
rs - the results set which must match the value given in the initial call to prepareToProcessResults(java.sql.ResultSet, org.hydrateframework.Assembler).
Returns:
true if the fields were read successfully.
Throws:
java.sql.SQLException

writeState

void writeState(java.sql.ResultSet rs,
                java.lang.Object x)
                throws java.sql.SQLException
This method updates the fields associated with this key in the given results set.

Parameters:
rs - the results set to update which must match the value given in the initial call to prepareToProcessResults(java.sql.ResultSet, org.hydrateframework.Assembler).
Throws:
java.sql.SQLException

getKey

ObjectKey getKey()
Make the key that this assembler has been created to build.

Returns:
a newly created key using the data that was read from the current row.

isAllocatedByDb

boolean isAllocatedByDb()
Indicate whether this key was allocated by the database. (e.g. an autonumber column.

Returns:
true if the database allocated this key.

getKeyClass

java.lang.Class getKeyClass()
Returns the Class object that represents the class of key that this assembler will build.


makeKeyFromValues

ObjectKey makeKeyFromValues(java.lang.Object[] keys)
Makes the key from the given array of objects.

Returns:
the newly created key

makeKeyFromInt

ObjectKey makeKeyFromInt(int defPrimary)
Makes a key from a single integer. This method is included to improve efficiency when a key is a simple integer as it avoids unnecessary object creation.



Copyright © 2000 The Hydrate Project. All Rights Reserved.