01: package net.sourceforge.jaxor.api;
02:
03: import net.sourceforge.jaxor.MetaField;
04:
05: import java.io.Serializable;
06: import java.sql.ResultSet;
07: import java.sql.SQLException;
08:
09: /*
10: * This class represents an individual value in a relational database
11: * entity. It provides a way to map a MetaField with the
12: * corresponding value for the field in a given entity row.
13: * Custom mappers can be created and used in mapping files.
14: */
15:
16: public interface Mapper extends Serializable {
17:
18: /**
19: * This method is implemneted by each of the mappers for the
20: * standard SQL and Java types as well as custom mappers
21: * implemented to handle 1:1 entity relations.
22: *
23: * @return the valid SQL type defined in java.sql.Types
24: */
25: public int getSQLType();
26:
27: /**
28: * This method actually populates the value for this entity "cell"
29: * given the indicated result set. User-defined concrete
30: * instances of the AbstractMapper class can perform whatever
31: * steps are necessary to return the appropriate mapped type.
32: *
33: * @param rs the ResultSet with the cell data
34: * @exception SQLException if there is a problem accessing the
35: * data in the result set
36: */
37:
38: public Object getValueFromResultSet(ResultSet rs, FieldAdapter field)
39: throws SQLException;
40:
41: /**
42: * This method is used to resolve the foreign key mapping when the
43: * value of the mapper is to be updated for the given entity.
44: *
45: * @return the appropriate SQL object type or null
46: */
47: public Object mapToSqlObject(Object obj);
48:
49: public void validate(Object obj, MetaField field);
50: }
|