1 19 package org.netbeans.modules.javacore.jmiimpl.javamodel; 20 21 import org.netbeans.jmi.javamodel.UnresolvedClass; 22 import org.netbeans.jmi.javamodel.UnresolvedClassClass; 23 import org.netbeans.mdr.handlers.ClassProxyHandler; 24 import org.netbeans.mdr.persistence.MOFID; 25 import org.netbeans.mdr.persistence.StorageException; 26 import org.netbeans.mdr.storagemodel.StorableBaseObject; 27 import org.netbeans.mdr.storagemodel.StorableClass; 28 import org.netbeans.mdr.util.DebugException; 29 import javax.jmi.reflect.ConstraintViolationException; 30 import java.util.Collection ; 31 import java.util.Collections ; 32 import org.netbeans.jmi.javamodel.JavaModelPackage; 33 import org.netbeans.modules.javacore.JMManager; 34 import org.netbeans.modules.javacore.api.JavaModel; 35 import org.openide.ErrorManager; 36 37 41 public abstract class UnresolvedClassClassImpl extends ClassProxyHandler implements UnresolvedClassClass { 42 44 private static final String MOFID_PREFIX = "unresolved:"; private static final InstanceMap allInstances = new InstanceMap(); 46 47 48 public UnresolvedClassClassImpl(StorableClass s) { 49 super(s); 50 } 51 52 public UnresolvedClass createUnresolvedClass(java.lang.String name, java.util.List annotations, int modifiers, java.lang.String javadocText, org.netbeans.jmi.javamodel.JavaDoc javadoc, java.util.List contents, org.netbeans.jmi.javamodel.MultipartId superClassName, java.util.List interfaceNames, java.util.List typeArguments) { 53 throw new ConstraintViolationException(this, refMetaObject(), "Cannot create unresolved classes explicitly."); } 55 56 public UnresolvedClass createUnresolvedClass() { 57 throw new ConstraintViolationException(this, refMetaObject(), "Cannot create unresolved classes explicitly."); } 59 60 public UnresolvedClass resolveUnresolved(String name) { 61 if (name == null) { 62 JMManager.getLog().notify(ErrorManager.INFORMATIONAL, new Exception ("!! Trying to get unresolved class for name == null")); return null; 64 } 65 UnresolvedClassImpl result = (UnresolvedClassImpl) allInstances.get(name); 66 if (result == null) { 67 if (JavaModel.getDefaultExtent().equals(refImmediatePackage())) { 68 try { 69 StorableBaseObject s = _getDelegate(); 71 MOFID mofId = new MOFID(name.hashCode(), MOFID_PREFIX + name); 72 DeferredObject o = new DeferredObject(mofId, s.getMdrStorage(), s.getImmediatePackageId(), s.getOutermostPackageId(), s.getMetaObject(), (StorableClass) s, null); 73 result = (UnresolvedClassImpl) _getRepository().getHandler(o); 74 result.name = name; 75 allInstances.put(name, result); 76 } catch (StorageException e) { 77 throw new DebugException(); 78 } 79 } else { 80 return ((UnresolvedClassClassImpl) JavaModel.getDefaultExtent().getUnresolvedClass()).resolveUnresolved(name); 81 } 82 } 83 return result; 84 } 85 86 protected Collection _allOfClass(boolean recursive) { 87 return Collections.unmodifiableCollection(allInstances.values()); 88 } 89 90 public org.netbeans.jmi.javamodel.Type resolve(java.lang.String name) { 91 JavaModelPackage pkg = (JavaModelPackage) refImmediatePackage(); 92 return pkg.getType().resolve(name); 93 } 94 } 95 | Popular Tags |