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.exchange;
17:
18: import com.ibatis.sqlmap.engine.mapping.parameter.ParameterMap;
19: import com.ibatis.sqlmap.engine.mapping.parameter.ParameterMapping;
20: import com.ibatis.sqlmap.engine.mapping.result.ResultMap;
21: import com.ibatis.sqlmap.engine.scope.RequestScope;
22:
23: import java.util.Map;
24:
25: /**
26: * DataExchange implementation for primitive objects
27: */
28: public class PrimitiveDataExchange extends BaseDataExchange implements
29: DataExchange {
30:
31: protected PrimitiveDataExchange(
32: DataExchangeFactory dataExchangeFactory) {
33: super (dataExchangeFactory);
34: }
35:
36: public void initialize(Map properties) {
37: }
38:
39: public Object[] getData(RequestScope request,
40: ParameterMap parameterMap, Object parameterObject) {
41: ParameterMapping[] mappings = parameterMap
42: .getParameterMappings();
43: Object[] data = new Object[mappings.length];
44: for (int i = 0; i < mappings.length; i++) {
45: data[i] = parameterObject;
46: }
47: return data;
48: }
49:
50: public Object setData(RequestScope request, ResultMap resultMap,
51: Object resultObject, Object[] values) {
52: return values[0];
53: }
54:
55: public Object setData(RequestScope request,
56: ParameterMap parameterMap, Object parameterObject,
57: Object[] values) {
58: return values[0];
59: }
60:
61: }
|