01: /*
02: * Copyright 2004 Clinton Begin
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package com.ibatis.sqlmap.engine.mapping.result;
17:
18: import com.ibatis.sqlmap.engine.scope.RequestScope;
19:
20: import java.sql.ResultSet;
21: import java.sql.SQLException;
22:
23: /**
24: * This is a grouping of ResultMapping objects used to map results back to objects
25: */
26: public interface ResultMap {
27:
28: public static final Object NO_VALUE = new Object();
29:
30: /**
31: * A way to identify the ResultMap
32: *
33: * @return - an ID
34: */
35: public String getId();
36:
37: /**
38: * Perform the mapping, and return the results
39: *
40: * @param request - the request scope
41: * @param rs - the result set to map
42: *
43: * @return - an object array with the data in it
44: *
45: * @throws SQLException - if an exception is thrown processing the results
46: */
47: public Object[] getResults(RequestScope request, ResultSet rs)
48: throws SQLException;
49:
50: /**
51: * Callback method for RowHandler
52: *
53: * @param request - the request scope
54: * @param resultObject - the object being populated
55: * @param values - the values from the database
56: *
57: * @return - the populated object
58: */
59: public Object setResultObjectValues(RequestScope request,
60: Object resultObject, Object[] values);
61:
62: /**
63: * Getter for the ResultMapping objects
64: *
65: * @return - an array of ResultMapping objects
66: */
67: public ResultMapping[] getResultMappings();
68:
69: /**
70: * Getter for the class that data wil be mapped into
71: *
72: * @return - the class
73: */
74: public Class getResultClass();
75:
76: /**
77: * Gets a unique key based on the values provided.
78: * @param values Result values representing a single row of results.
79: * @return The unique key.
80: */
81: public Object getUniqueKey(Object[] values);
82:
83: public ResultMap resolveSubMap(RequestScope request, ResultSet rs)
84: throws SQLException;
85:
86: public Discriminator getDiscriminator();
87:
88: }
|