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.accessplan;
17:
18: import com.ibatis.common.beans.ClassInfo;
19:
20: import java.lang.reflect.Method;
21:
22: /**
23: * Base implementation of the AccessPlan interface
24: */
25: public abstract class BaseAccessPlan implements AccessPlan {
26:
27: protected Class clazz;
28: protected String[] propertyNames;
29: protected ClassInfo info;
30:
31: BaseAccessPlan(Class clazz, String[] propertyNames) {
32: this .clazz = clazz;
33: this .propertyNames = propertyNames;
34: info = ClassInfo.getInstance(clazz);
35: }
36:
37: protected Class[] getTypes(String[] propertyNames) {
38: Class[] types = new Class[propertyNames.length];
39: for (int i = 0; i < propertyNames.length; i++) {
40: types[i] = info.getGetterType(propertyNames[i]);
41: }
42: return types;
43: }
44:
45: protected Method[] getGetters(String[] propertyNames) {
46: Method[] methods = new Method[propertyNames.length];
47: for (int i = 0; i < propertyNames.length; i++) {
48: methods[i] = info.getGetter(propertyNames[i]);
49: }
50: return methods;
51: }
52:
53: protected Method[] getSetters(String[] propertyNames) {
54: Method[] methods = new Method[propertyNames.length];
55: for (int i = 0; i < propertyNames.length; i++) {
56: methods[i] = info.getSetter(propertyNames[i]);
57: }
58: return methods;
59: }
60:
61: protected String[] getGetterNames(String[] propertyNames) {
62: String[] names = new String[propertyNames.length];
63: for (int i = 0; i < propertyNames.length; i++) {
64: names[i] = info.getGetter(propertyNames[i]).getName();
65: }
66: return names;
67: }
68:
69: protected String[] getSetterNames(String[] propertyNames) {
70: String[] names = new String[propertyNames.length];
71: for (int i = 0; i < propertyNames.length; i++) {
72: names[i] = info.getSetter(propertyNames[i]).getName();
73: }
74: return names;
75: }
76:
77: }
|