KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > uitags > tagutil > bean > ElTagBeanInfo


1 /**
2  * Dec 9, 2004
3  *
4  * Copyright 2004 uitags
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package net.sf.uitags.tagutil.bean;
19
20 import java.lang.reflect.Method JavaDoc;
21 import java.util.ArrayList JavaDoc;
22 import java.util.HashMap JavaDoc;
23 import java.util.Iterator JavaDoc;
24 import java.util.List JavaDoc;
25 import java.util.Map JavaDoc;
26
27
28 /**
29  * A class that adapts {@link net.sf.uitags.tagutil.bean.TagBeanInfo}
30  * for EL support.
31  *
32  * @author jonni
33  * @version $Id$
34  */

35 public abstract class ElTagBeanInfo extends TagBeanInfo {
36   /**
37    * If more than one setter under the same name exist, this method chooses
38    * one that deals with <code>String</code>. Tag handlers with EL support
39    * may overload setters defined in the parent with ones that take
40    * <code>String</code>. This method explicitly hides those overloaded
41    * setters.
42    *
43    * @return setter methods of the tag handler (list of <code>Method</code>s)
44    * @throws RuntimeException if the tag handler class was not found
45    */

46   List JavaDoc getTagHandlerSetters() {
47     List JavaDoc methods = super.getTagHandlerSetters();
48
49     // Map key is the method name
50
Map JavaDoc methodMap = new HashMap JavaDoc();
51     for (Iterator JavaDoc i = methods.iterator(); i.hasNext(); ) {
52       Method JavaDoc currMethod = (Method JavaDoc) i.next();
53       String JavaDoc methodName = currMethod.getName();
54
55       Method JavaDoc similarlyNamed = (Method JavaDoc) methodMap.get(methodName);
56       // If method under the same name hasn't existed, add to map
57
if (similarlyNamed == null) {
58         methodMap.put(methodName, currMethod);
59       }
60       // If method under the same name exists, we want one that deals
61
// with String object
62
else {
63         if (currMethod.getParameterTypes()[0].equals(String JavaDoc.class)) {
64           methodMap.put(methodName, currMethod);
65         }
66       }
67     }
68
69     return new ArrayList JavaDoc(methodMap.values());
70   }
71 }
72
Popular Tags