|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.javacore.jmiimpl.javamodel; import java.util.List; import org.netbeans.jmi.javamodel.*; import org.netbeans.mdr.handlers.ClassProxyHandler; import org.netbeans.mdr.persistence.StorageException; import org.netbeans.mdr.storagemodel.StorableBaseObject; import org.netbeans.mdr.storagemodel.StorableClass; import org.netbeans.modules.javacore.ClassIndex; /** * * @author Martin Matula */ public abstract class JavaEnumClassImpl extends ClassProxyHandler implements JavaEnumClass { // [TODO] this class should probably extend SemiPersistentClass, since not all enumerations // are persistent (local enumerations are not) /** Creates a new instance of JavaClassClassImpl */ public JavaEnumClassImpl(StorableClass s) { super(s); } /** * The default factory operation used to create an instance object. * @return The created instance object. */ public JavaEnum createJavaEnum() { return create(null, null, 0, null, null, null, null, null); } public JavaEnum createJavaEnum(String name, List annotations, int modifiers, String javadocText, JavaDoc javadoc, List features, MultipartId superClassName, List interfaceNames, List typeArguments, List constants) { return create(name, annotations, modifiers, javadocText, javadoc, features, interfaceNames, constants); } 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); protected abstract JavaEnum super_createJavaEnum(); private JavaEnumImpl create(String name, List annotations, int modifiers, String javadocText, JavaDoc javadoc, List features, List interfaceNames, List constants) { boolean fail = true; _lock(true); try { JavaEnumImpl result = create(name, modifiers, false); result.setNew(); result.setData(annotations, javadocText, javadoc, constants, features, interfaceNames); fail = false; return result; } finally { _unlock(fail); } } protected SemiPersistentElement createTransient() { try { StorableBaseObject s = _getDelegate(); DeferredObject o = new DeferredObject(null, s.getMdrStorage(), s.getImmediatePackageId(), s.getOutermostPackageId(), s.getMetaObject(), (StorableClass) s, null, true); SemiPersistentElement result = (SemiPersistentElement) _getRepository().getHandler(o); return result; } catch (StorageException e) { throw new RuntimeException(); } } public JavaEnumImpl create(String name, int modifiers, boolean isTransient) { JavaEnumImpl result; if (isTransient) { result = (JavaEnumImpl) createTransient(); boolean changes = result.disableChanges; result.disableChanges = true; try { result.setName(name); result.setModifiers(modifiers); } finally { result.disableChanges = changes; } } else { result = (JavaEnumImpl) super_createJavaEnum(name, null, modifiers, null, null, null, null, null, null, null); if (name != null) { JavaModelPackage srcExtent = (JavaModelPackage) refImmediatePackage(); ClassIndex index = ClassIndex.getIndex(srcExtent); index.addClass(result, name, result.getSimpleName()); } } return result; } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.