KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ibatis > sqlmap > engine > accessplan > BaseAccessPlan


1 /*
2  * Copyright 2004 Clinton Begin
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  * http://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.accessplan;
17
18 import com.ibatis.common.beans.ClassInfo;
19
20 import java.lang.reflect.Method JavaDoc;
21
22 /**
23  * Base implementation of the AccessPlan interface
24  */

25 public abstract class BaseAccessPlan implements AccessPlan {
26
27   protected Class JavaDoc clazz;
28   protected String JavaDoc[] propertyNames;
29   protected ClassInfo info;
30
31   BaseAccessPlan(Class JavaDoc clazz, String JavaDoc[] propertyNames) {
32     this.clazz = clazz;
33     this.propertyNames = propertyNames;
34     info = ClassInfo.getInstance(clazz);
35   }
36
37   protected Class JavaDoc[] getTypes(String JavaDoc[] propertyNames) {
38     Class JavaDoc[] types = new Class JavaDoc[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 JavaDoc[] getGetters(String JavaDoc[] propertyNames) {
46     Method JavaDoc[] methods = new Method JavaDoc[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 JavaDoc[] getSetters(String JavaDoc[] propertyNames) {
54     Method JavaDoc[] methods = new Method JavaDoc[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 JavaDoc[] getGetterNames(String JavaDoc[] propertyNames) {
62     String JavaDoc[] names = new String JavaDoc[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 JavaDoc[] getSetterNames(String JavaDoc[] propertyNames) {
70     String JavaDoc[] names = new String JavaDoc[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
78 }
79
Popular Tags