1 19 package org.netbeans.modules.javacore.jmiimpl.javamodel; 20 21 import java.util.List ; 22 import org.netbeans.jmi.javamodel.*; 23 import org.netbeans.mdr.handlers.ClassProxyHandler; 24 import org.netbeans.mdr.persistence.StorageException; 25 import org.netbeans.mdr.storagemodel.StorableBaseObject; 26 import org.netbeans.mdr.storagemodel.StorableClass; 27 import org.netbeans.modules.javacore.ClassIndex; 28 29 33 public abstract class JavaEnumClassImpl extends ClassProxyHandler implements JavaEnumClass { 34 37 38 public JavaEnumClassImpl(StorableClass s) { 39 super(s); 40 } 41 42 46 public JavaEnum createJavaEnum() { 47 return create(null, null, 0, null, null, null, null, null); 48 } 49 50 public JavaEnum createJavaEnum(String name, List annotations, int modifiers, String javadocText, JavaDoc javadoc, List features, MultipartId superClassName, List interfaceNames, List typeArguments, List constants) { 51 return create(name, annotations, modifiers, javadocText, javadoc, features, interfaceNames, constants); 52 } 53 54 protected abstract JavaEnum super_createJavaEnum(String name, List annotations, int modifiers, String javadocText, JavaDoc javadoc, List features, MultipartId superClassName, List interfaceNames, List typeArguments, List constants); 55 protected abstract JavaEnum super_createJavaEnum(); 56 57 private JavaEnumImpl create(String name, List annotations, int modifiers, String javadocText, JavaDoc javadoc, List features, List interfaceNames, List constants) { 58 boolean fail = true; 59 _lock(true); 60 try { 61 JavaEnumImpl result = create(name, modifiers, false); 62 result.setNew(); 63 result.setData(annotations, javadocText, javadoc, constants, features, interfaceNames); 64 fail = false; 65 return result; 66 } finally { 67 _unlock(fail); 68 } 69 } 70 71 protected SemiPersistentElement createTransient() { 72 try { 73 StorableBaseObject s = _getDelegate(); 74 DeferredObject o = new DeferredObject(null, s.getMdrStorage(), s.getImmediatePackageId(), s.getOutermostPackageId(), s.getMetaObject(), (StorableClass) s, null, true); 75 SemiPersistentElement result = (SemiPersistentElement) _getRepository().getHandler(o); 76 return result; 77 } catch (StorageException e) { 78 throw new RuntimeException (); 79 } 80 } 81 82 public JavaEnumImpl create(String name, int modifiers, boolean isTransient) { 83 JavaEnumImpl result; 84 if (isTransient) { 85 result = (JavaEnumImpl) createTransient(); 86 boolean changes = result.disableChanges; 87 result.disableChanges = true; 88 try { 89 result.setName(name); 90 result.setModifiers(modifiers); 91 } finally { 92 result.disableChanges = changes; 93 } 94 } else { 95 result = (JavaEnumImpl) super_createJavaEnum(name, null, modifiers, null, null, null, null, null, null, null); 96 if (name != null) { 97 JavaModelPackage srcExtent = (JavaModelPackage) refImmediatePackage(); 98 ClassIndex index = ClassIndex.getIndex(srcExtent); 99 index.addClass(result, name, result.getSimpleName()); 100 } 101 } 102 return result; 103 } 104 105 public org.netbeans.jmi.javamodel.Type resolve(java.lang.String name) { 106 JavaModelPackage pkg = (JavaModelPackage) refImmediatePackage(); 107 return pkg.getType().resolve(name); 108 } 109 } 110 | Popular Tags |