01: package org.gomba.domains;
02:
03: import java.sql.ResultSet;
04:
05: import org.gomba.ParameterDefinition;
06: import org.gomba.ParameterDomain;
07: import org.gomba.ParameterResolver;
08:
09: /**
10: * This domain contains properties extracted from the first row of the
11: * ResultSet. Properties have the name of the corresponding columns.
12: *
13: * @author Flavio Tordini
14: * @version $Id: ColumnDomain.java,v 1.3 2004/07/16 15:48:33 flaviotordini Exp $
15: */
16: public class ColumnDomain implements ParameterDomain {
17:
18: /**
19: * @see org.gomba.ParameterDomain#getParameterValue(org.gomba.ParameterResolver,
20: * org.gomba.ParameterDefinition)
21: */
22: public Object getParameterValue(ParameterResolver context,
23: ParameterDefinition parameter) throws Exception {
24: ResultSet resultSet = context.getResultSet();
25:
26: // The ResultSet cursor should be positioned on a row. If the
27: // resultset is empty we should never even be here. If an Exception
28: // occurs here it is a bug.
29: return resultSet.getObject(parameter.getName());
30:
31: }
32:
33: /**
34: * @see org.gomba.ParameterDomain#getName()
35: */
36: public String getName() {
37: return "column";
38: }
39:
40: }
|