1 19 20 package org.netbeans.modules.javacore.parser; 21 22 import java.lang.reflect.Modifier ; 23 import java.util.HashMap ; 24 import java.util.Map ; 25 import org.netbeans.jmi.javamodel.ClassMember; 26 import org.netbeans.jmi.javamodel.Field; 27 import org.netbeans.jmi.javamodel.JavaClass; 28 import org.netbeans.jmi.javamodel.Method; 29 30 34 public class StaticImportScope implements ScopeMember { 35 private JavaClass javaClass; 36 private Map features; 37 private String name; 38 39 StaticImportScope(JavaClass jcls,String n) { 40 javaClass=jcls; 41 name=n; 42 } 43 44 private void initFeatureMap() { 45 Object [] featureArr=javaClass.getFeatures().toArray(); 46 47 features=new HashMap (); 48 for (int i=0;i<featureArr.length;i++) { 49 ClassMember feature=(ClassMember)featureArr[i]; 50 int modifiers=feature.getModifiers(); 51 String fname; 52 53 if (!Modifier.isStatic(modifiers)) 54 continue; 55 fname=feature.getName(); 56 if (name!=null && !name.equals(fname)) 57 continue; 58 if (feature instanceof Field) { 59 features.put(fname, feature); 60 } 61 else if (feature instanceof Method) { 62 features.put(fname.concat("("),javaClass.getName()); } 64 } 65 javaClass=null; 66 } 67 68 public Object lookup(Object key) { 69 if (features==null) 70 initFeatureMap(); 71 return features.get(key); 72 } 73 } 74 | Popular Tags |