Path: blob/aarch64-shenandoah-jdk8u272-b10/langtools/src/share/classes/javax/tools/StandardLocation.java
38900 views
/*1* Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.tools;2627import javax.tools.JavaFileManager.Location;2829import java.util.concurrent.*;3031/**32* Standard locations of file objects.33*34* @author Peter von der Ahé35* @since 1.636*/37public enum StandardLocation implements Location {3839/**40* Location of new class files.41*/42CLASS_OUTPUT,4344/**45* Location of new source files.46*/47SOURCE_OUTPUT,4849/**50* Location to search for user class files.51*/52CLASS_PATH,5354/**55* Location to search for existing source files.56*/57SOURCE_PATH,5859/**60* Location to search for annotation processors.61*/62ANNOTATION_PROCESSOR_PATH,6364/**65* Location to search for platform classes. Sometimes called66* the boot class path.67*/68PLATFORM_CLASS_PATH,6970/**71* Location of new native header files.72* @since 1.873*/74NATIVE_HEADER_OUTPUT;7576/**77* Gets a location object with the given name. The following78* property must hold: {@code locationFor(x) ==79* locationFor(y)} if and only if {@code x.equals(y)}.80* The returned location will be an output location if and only if81* name ends with {@code "_OUTPUT"}.82*83* @param name a name84* @return a location85*/86public static Location locationFor(final String name) {87if (locations.isEmpty()) {88// can't use valueOf which throws IllegalArgumentException89for (Location location : values())90locations.putIfAbsent(location.getName(), location);91}92locations.putIfAbsent(name.toString(/* null-check */), new Location() {93public String getName() { return name; }94public boolean isOutputLocation() { return name.endsWith("_OUTPUT"); }95});96return locations.get(name);97}98//where99private static final ConcurrentMap<String,Location> locations100= new ConcurrentHashMap<String,Location>();101102public String getName() { return name(); }103104public boolean isOutputLocation() {105switch (this) {106case CLASS_OUTPUT:107case SOURCE_OUTPUT:108case NATIVE_HEADER_OUTPUT:109return true;110default:111return false;112}113}114}115116117