001    /*
002     * Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
003     * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004     *
005     * This code is free software; you can redistribute it and/or modify it
006     * under the terms of the GNU General Public License version 2 only, as
007     * published by the Free Software Foundation.  Sun designates this
008     * particular file as subject to the "Classpath" exception as provided
009     * by Sun in the LICENSE file that accompanied this code.
010     *
011     * This code is distributed in the hope that it will be useful, but WITHOUT
012     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013     * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014     * version 2 for more details (a copy is included in the LICENSE file that
015     * accompanied this code).
016     *
017     * You should have received a copy of the GNU General Public License version
018     * 2 along with this work; if not, write to the Free Software Foundation,
019     * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020     *
021     * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022     * CA 95054 USA or visit www.sun.com if you need additional information or
023     * have any questions.
024     */
025    
026    package com.sun.mirror.declaration;
027    
028    
029    /**
030     * Represents a modifier on the declaration of a program element such
031     * as a class, method, or field.
032     *
033     * <p> Not all modifiers are applicable to all kinds of declarations.
034     * When two or more modifiers appear in the source code of a declaration,
035     * then it is customary, though not required, that they appear in the same
036     * order as the constants listed in the detail section below.
037     *
038     * @author Joseph D. Darcy
039     * @author Scott Seligman
040     * @since 1.5
041     */
042    
043    public enum Modifier {
044    
045        // See JLS2 sections 8.1.1, 8.3.1, 8.4.3, 8.8.3, and 9.1.1.
046        // java.lang.reflect.Modifier includes INTERFACE, but that's a VMism.
047    
048        /** The modifier <tt>public</tt> */         PUBLIC,
049        /** The modifier <tt>protected</tt> */      PROTECTED,
050        /** The modifier <tt>private</tt> */        PRIVATE,
051        /** The modifier <tt>abstract</tt> */       ABSTRACT,
052        /** The modifier <tt>static</tt> */         STATIC,
053        /** The modifier <tt>final</tt> */          FINAL,
054        /** The modifier <tt>transient</tt> */      TRANSIENT,
055        /** The modifier <tt>volatile</tt> */       VOLATILE,
056        /** The modifier <tt>synchronized</tt> */   SYNCHRONIZED,
057        /** The modifier <tt>native</tt> */         NATIVE,
058        /** The modifier <tt>strictfp</tt> */       STRICTFP;
059    
060    
061        private String lowercase = null;    // modifier name in lowercase
062    
063        /**
064         * Returns this modifier's name in lowercase.
065         */
066        public String toString() {
067            if (lowercase == null) {
068               lowercase = name().toLowerCase(java.util.Locale.US);
069            }
070            return lowercase;
071        }
072    }