systemic.sif.sifcommon.mapping.adapter
Class ResultSetAdapter

java.lang.Object
  extended by systemic.sif.sifcommon.mapping.adapter.ResultSetAdapter
All Implemented Interfaces:
openadk.library.tools.mapping.FieldAdaptor

public class ResultSetAdapter
extends java.lang.Object
implements openadk.library.tools.mapping.FieldAdaptor

Basic implementation of the ADK FieldAdaptor interface for java.sql.ResultSet. An initial implementation was provided by Andrew Elmhorst. This implementation has been further enhanced by Joerg Huber.

Note: This class is only expected to be used for Outbound message mappings (ie. publishers). The behaviour is unknown (in fact it will not work) for Inbound messages (ie. subscribers).

Author:
Joerg Huber & Andrew Elmhorst

Constructor Summary
ResultSetAdapter(java.sql.ResultSet sourceData, java.lang.Class clazz)
          Initialises the ResultSet Adapter.
 
Method Summary
 openadk.library.SIFSimpleType getSIFValue(java.lang.String name, openadk.library.SIFTypeConverter typeConverter, openadk.library.tools.mapping.FieldMapping fm)
           
 java.lang.Object getValue(java.lang.String name)
           
 boolean hasField(java.lang.String fieldName)
           
 boolean hasNext()
          Moves the position in the resultset forward by one record.
 openadk.library.SIFDataObject map(openadk.library.tools.mapping.MappingsContext mappingCtx)
          This methods will return an object of the type specified in the constructor of this class.
 void setSIFValue(java.lang.String fieldName, openadk.library.SIFSimpleType sifDataElement, openadk.library.tools.mapping.FieldMapping fm)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResultSetAdapter

public ResultSetAdapter(java.sql.ResultSet sourceData,
                        java.lang.Class clazz)
                 throws java.lang.Exception
Initialises the ResultSet Adapter.

Parameters:
sourceData - The resultset for this adapter.
clazz - The class that will be returned as part of the map() method.
Throws:
java.lang.Exception - If there is a problem with the resultset and therefore this class cannot be created.
Method Detail

map

public openadk.library.SIFDataObject map(openadk.library.tools.mapping.MappingsContext mappingCtx)
                                  throws openadk.library.tools.mapping.ADKMappingException
This methods will return an object of the type specified in the constructor of this class. The properties of the class are populated according to the mappings provided in the MappingsContext. It is expected that the MappingsContext is an Outbound context since this class is intended to be used by publishers.

Parameters:
mappingCtx - The mapping context that shall be used to populate the returned sif object.
Returns:
A SIF object of the type defined in the 'clazz' parameter in the constructor of this class.
Throws:
openadk.library.tools.mapping.ADKMappingException - Failure to map due to invalid mapping syntax, context or semantics.

hasNext

public boolean hasNext()
                throws java.sql.SQLException
Moves the position in the resultset forward by one record. After this call the resultset points to the latest position. If there are more resultsets then this method will return true, otherwise false is returned.

Note: Do not call resultSet.next() outside of this class!!!!

Returns:
TRUE if more rows are available in the result set otherwise FALSE is returned.
Throws:
java.sql.SQLException

getSIFValue

public openadk.library.SIFSimpleType getSIFValue(java.lang.String name,
                                                 openadk.library.SIFTypeConverter typeConverter,
                                                 openadk.library.tools.mapping.FieldMapping fm)
Specified by:
getSIFValue in interface openadk.library.tools.mapping.FieldAdaptor

getValue

public java.lang.Object getValue(java.lang.String name)
Specified by:
getValue in interface openadk.library.tools.mapping.FieldAdaptor

hasField

public boolean hasField(java.lang.String fieldName)
Specified by:
hasField in interface openadk.library.tools.mapping.FieldAdaptor

setSIFValue

public void setSIFValue(java.lang.String fieldName,
                        openadk.library.SIFSimpleType sifDataElement,
                        openadk.library.tools.mapping.FieldMapping fm)
Specified by:
setSIFValue in interface openadk.library.tools.mapping.FieldAdaptor