1 /*
2 * Copyright 2004-2022 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
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.exchange;
17
18 import com.ibatis.sqlmap.engine.cache.CacheKey;
19 import com.ibatis.sqlmap.engine.mapping.parameter.ParameterMap;
20 import com.ibatis.sqlmap.engine.mapping.result.ResultMap;
21 import com.ibatis.sqlmap.engine.scope.StatementScope;
22
23 import java.util.Map;
24
25 /**
26 * Interface for exchanging data between a parameter map/result map and the related objects.
27 */
28 public interface DataExchange {
29
30 /**
31 * Initializes the data exchange instance.
32 *
33 * @param properties
34 * the properties
35 */
36 public void initialize(Map properties);
37
38 /**
39 * Gets a data array from a parameter object.
40 *
41 * @param statementScope
42 * - the scope of the request
43 * @param parameterMap
44 * - the parameter map
45 * @param parameterObject
46 * - the parameter object
47 *
48 * @return - the objects
49 */
50 public Object[] getData(StatementScope statementScope, ParameterMap parameterMap, Object parameterObject);
51
52 /**
53 * Sets values from a data array into a result object.
54 *
55 * @param statementScope
56 * - the request scope
57 * @param resultMap
58 * - the result map
59 * @param resultObject
60 * - the result object
61 * @param values
62 * - the values to be mapped
63 *
64 * @return the resultObject
65 */
66 public Object setData(StatementScope statementScope, ResultMap resultMap, Object resultObject, Object[] values);
67
68 /**
69 * Sets values from a data array into a parameter object.
70 *
71 * @param statementScope
72 * - the request scope
73 * @param parameterMap
74 * - the parameter map
75 * @param parameterObject
76 * - the parameter object
77 * @param values
78 * - the values to set
79 *
80 * @return parameterObject
81 */
82 public Object setData(StatementScope statementScope, ParameterMap parameterMap, Object parameterObject,
83 Object[] values);
84
85 /**
86 * Returns an object capable of being a unique cache key for a parameter object.
87 *
88 * @param statementScope
89 * - the request scope
90 * @param parameterMap
91 * - the parameter map
92 * @param parameterObject
93 * - the parameter object
94 *
95 * @return - a cache key
96 */
97 public CacheKey getCacheKey(StatementScope statementScope, ParameterMap parameterMap, Object parameterObject);
98
99 }