src/share/classes/javax/tools/StandardLocation.java

Thu, 02 Oct 2008 19:58:40 -0700

author
xdono
date
Thu, 02 Oct 2008 19:58:40 -0700
changeset 117
24a47c3062fe
parent 103
e571266ae14f
child 554
9d9f26857129
permissions
-rw-r--r--

6754988: Update copyright year
Summary: Update for files that have been modified starting July 2008
Reviewed-by: ohair, tbell

     1 /*
     2  * Copyright 2006-2008 Sun Microsystems, Inc.  All Rights Reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Sun designates this
     8  * particular file as subject to the "Classpath" exception as provided
     9  * by Sun in the LICENSE file that accompanied this code.
    10  *
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    14  * version 2 for more details (a copy is included in the LICENSE file that
    15  * accompanied this code).
    16  *
    17  * You should have received a copy of the GNU General Public License version
    18  * 2 along with this work; if not, write to the Free Software Foundation,
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    20  *
    21  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    22  * CA 95054 USA or visit www.sun.com if you need additional information or
    23  * have any questions.
    24  */
    26 package javax.tools;
    28 import javax.tools.JavaFileManager.Location;
    30 import java.util.concurrent.*;
    32 /**
    33  * Standard locations of file objects.
    34  *
    35  * @author Peter von der Ahé
    36  * @since 1.6
    37  */
    38 public enum StandardLocation implements Location {
    40     /**
    41      * Location of new class files.
    42      */
    43     CLASS_OUTPUT,
    45     /**
    46      * Location of new source files.
    47      */
    48     SOURCE_OUTPUT,
    50     /**
    51      * Location to search for user class files.
    52      */
    53     CLASS_PATH,
    55     /**
    56      * Location to search for existing source files.
    57      */
    58     SOURCE_PATH,
    60     /**
    61      * Location to search for annotation processors.
    62      */
    63     ANNOTATION_PROCESSOR_PATH,
    65     /**
    66      * Location to search for platform classes.  Sometimes called
    67      * the boot class path.
    68      */
    69     PLATFORM_CLASS_PATH;
    71     /**
    72      * Gets a location object with the given name.  The following
    73      * property must hold: {@code locationFor(x) ==
    74      * locationFor(y)} if and only if {@code x.equals(y)}.
    75      * The returned location will be an output location if and only if
    76      * name ends with {@code "_OUTPUT"}.
    77      *
    78      * @param name a name
    79      * @return a location
    80      */
    81     public static Location locationFor(final String name) {
    82         if (locations.isEmpty()) {
    83             // can't use valueOf which throws IllegalArgumentException
    84             for (Location location : values())
    85                 locations.putIfAbsent(location.getName(), location);
    86         }
    87         locations.putIfAbsent(name.toString(/* null-check */), new Location() {
    88                 public String getName() { return name; }
    89                 public boolean isOutputLocation() { return name.endsWith("_OUTPUT"); }
    90             });
    91         return locations.get(name);
    92     }
    93     //where
    94         private static ConcurrentMap<String,Location> locations
    95             = new ConcurrentHashMap<String,Location>();
    97     public String getName() { return name(); }
    99     public boolean isOutputLocation() {
   100         return this == CLASS_OUTPUT || this == SOURCE_OUTPUT;
   101     }
   102 }

mercurial