1 19 20 package org.netbeans.modules.javacore.parser; 21 22 import java.util.*; 23 import org.netbeans.api.java.classpath.ClassPath; 24 import org.netbeans.jmi.javamodel.JavaClass; 25 import org.netbeans.modules.javacore.ClassIndex; 26 27 30 class PackageImpScope implements ScopeMember { 31 private String jPackage; 32 private ClassPath classPath; 33 private Map positiveCache; 34 private Set negativeCache; 35 36 37 PackageImpScope(String pack,ClassPath cp) { 38 jPackage=pack.length()>0?pack.concat("."):pack; classPath=cp; 40 positiveCache=new HashMap(); 41 negativeCache=new HashSet(); 42 } 43 44 public Object lookup(Object key) { 45 Object val; 46 String className; 47 JavaClass jcls; 48 49 if (negativeCache.contains(key)) 50 return null; 51 val=positiveCache.get(key); 52 if (val!=null) 53 return val; 54 className=jPackage.concat((String )key); 55 jcls=ClassIndex.getClassByFqn(className,classPath); 56 if (jcls!=null) { 57 String name=jcls.getName(); 58 59 positiveCache.put(key, name); 60 return name; 61 } 62 negativeCache.add(key); 63 return null; 64 } 65 } 66 | Popular Tags |