1 19 24 25 package org.netbeans.modules.javacore.parser; 26 27 import java.util.ArrayList ; 28 import java.util.HashMap ; 29 import java.util.List ; 30 import java.util.Map ; 31 import org.netbeans.jmi.javamodel.ClassDefinition; 32 import org.netbeans.jmi.javamodel.Method; 33 34 38 class MethodScopeMember implements ScopeMember { 39 private ClassDefinition javaClass; 40 private Map methodsMap; 41 42 43 MethodScopeMember(ClassDefinition jcls) { 44 javaClass=jcls; 45 } 46 47 private void initMethodsMap() { 48 Object features[]=javaClass.getContents().toArray(); 49 50 methodsMap=new HashMap (); 51 javaClass=null; 52 for (int i=0;i<features.length;i++) { 53 Object feature=features[i]; 54 55 if (feature instanceof Method) { 56 Method method=(Method)feature; 57 String name=method.getName(); 58 Object ms=methodsMap.get(name); 59 60 if (ms==null) { 61 methodsMap.put(name,method); 62 } else { 63 if (ms instanceof Method) { 64 List mlist=new ArrayList (); 65 mlist.add(ms); 66 methodsMap.put(name,mlist); 67 ms=mlist; 68 } 69 ((List )ms).add(method); 70 } 71 } 72 } 73 } 74 75 public Object lookup(Object key) { 76 if (methodsMap==null) 77 initMethodsMap(); 78 return methodsMap.get(key); 79 } 80 } 81 | Popular Tags |