1 16 package org.apache.axis.utils.bytecode; 17 18 import java.io.IOException ; 19 import java.lang.reflect.Constructor ; 20 import java.lang.reflect.Method ; 21 import java.util.*; 22 23 36 public class ChainedParamReader { 37 private List chain = new ArrayList(); 38 private List clsChain = new ArrayList(); 39 private Map methodToParamMap = new HashMap(); 40 41 46 public ChainedParamReader(Class cls) throws IOException { 47 ParamReader reader = new ParamReader(cls); 48 chain.add(reader); 49 clsChain.add(cls); 50 } 51 52 61 public String [] getParameterNames(Constructor ctor) { 62 return ((ParamReader) chain.get(0)).getParameterNames(ctor); 64 } 65 66 76 public String [] getParameterNames(Method method) { 77 if (methodToParamMap.containsKey(method)) { 79 return (String []) methodToParamMap.get(method); 80 } 81 82 String [] ret = null; 83 for (Iterator it = chain.iterator(); it.hasNext();) { 84 ParamReader reader = (ParamReader) it.next(); 85 ret = reader.getParameterNames(method); 86 if (ret != null) { 87 methodToParamMap.put(method, ret); 88 return ret; 89 } 90 } 91 Class cls = (Class ) clsChain.get(chain.size() - 1); 93 while (cls.getSuperclass() != null) { 94 Class superClass = cls.getSuperclass(); 95 try { 96 ParamReader _reader = new ParamReader(superClass); 97 chain.add(_reader); 98 clsChain.add(cls); 99 ret = _reader.getParameterNames(method); 100 if (ret != null) { methodToParamMap.put(method, ret); 102 return ret; 103 } 104 } catch (IOException e) { 105 return null; 107 } 108 } 109 methodToParamMap.put(method, ret); 110 return null; 111 } 112 } 113 | Popular Tags |