src/share/classes/com/sun/tools/javac/nio/PathFileManager.java

Thu, 31 Aug 2017 15:17:03 +0800

author
aoqi
date
Thu, 31 Aug 2017 15:17:03 +0800
changeset 2525
2eb010b6cb22
parent 1358
fc123bdeddb8
parent 0
959103a6100f
permissions
-rw-r--r--

merge

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation. Oracle designates this
aoqi@0 8 * particular file as subject to the "Classpath" exception as provided
aoqi@0 9 * by Oracle in the LICENSE file that accompanied this code.
aoqi@0 10 *
aoqi@0 11 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 14 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 15 * accompanied this code).
aoqi@0 16 *
aoqi@0 17 * You should have received a copy of the GNU General Public License version
aoqi@0 18 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 20 *
aoqi@0 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 22 * or visit www.oracle.com if you need additional information or have any
aoqi@0 23 * questions.
aoqi@0 24 */
aoqi@0 25
aoqi@0 26 package com.sun.tools.javac.nio;
aoqi@0 27
aoqi@0 28 import java.io.IOException;
aoqi@0 29 import java.nio.file.FileSystem;
aoqi@0 30 import java.nio.file.FileSystems;
aoqi@0 31 import java.nio.file.Path;
aoqi@0 32 import javax.tools.FileObject;
aoqi@0 33 import javax.tools.JavaFileManager;
aoqi@0 34 import javax.tools.JavaFileObject;
aoqi@0 35
aoqi@0 36 /**
aoqi@0 37 * File manager based on {@link java.nio.file.Path}.
aoqi@0 38 *
aoqi@0 39 * Eventually, this should be moved to javax.tools.
aoqi@0 40 * Also, JavaCompiler might reasonably provide a method getPathFileManager,
aoqi@0 41 * similar to {@link javax.tools.JavaCompiler#getStandardFileManager
aoqi@0 42 * getStandardFileManager}. However, would need to be handled carefully
aoqi@0 43 * as another forward reference from langtools to jdk.
aoqi@0 44 *
aoqi@0 45 * <p><b>This is NOT part of any supported API.
aoqi@0 46 * If you write code that depends on this, you do so at your own risk.
aoqi@0 47 * This code and its internal interfaces are subject to change or
aoqi@0 48 * deletion without notice.</b>
aoqi@0 49 */
aoqi@0 50 public interface PathFileManager extends JavaFileManager {
aoqi@0 51 /**
aoqi@0 52 * Get the default file system used to create paths. If no value has been
aoqi@0 53 * set, the default file system is {@link FileSystems#getDefault}.
aoqi@0 54 */
aoqi@0 55 FileSystem getDefaultFileSystem();
aoqi@0 56
aoqi@0 57 /**
aoqi@0 58 * Set the default file system used to create paths.
aoqi@0 59 * @param fs the default file system used to create any new paths.
aoqi@0 60 */
aoqi@0 61 void setDefaultFileSystem(FileSystem fs);
aoqi@0 62
aoqi@0 63 /**
aoqi@0 64 * Get file objects representing the given files.
aoqi@0 65 *
aoqi@0 66 * @param paths a list of paths
aoqi@0 67 * @return a list of file objects
aoqi@0 68 * @throws IllegalArgumentException if the list of paths includes
aoqi@0 69 * a directory
aoqi@0 70 */
aoqi@0 71 Iterable<? extends JavaFileObject> getJavaFileObjectsFromPaths(
aoqi@0 72 Iterable<? extends Path> paths);
aoqi@0 73
aoqi@0 74 /**
aoqi@0 75 * Get file objects representing the given paths.
aoqi@0 76 * Convenience method equivalent to:
aoqi@0 77 *
aoqi@0 78 * <pre>
aoqi@0 79 * getJavaFileObjectsFromPaths({@linkplain java.util.Arrays#asList Arrays.asList}(paths))
aoqi@0 80 * </pre>
aoqi@0 81 *
aoqi@0 82 * @param paths an array of paths
aoqi@0 83 * @return a list of file objects
aoqi@0 84 * @throws IllegalArgumentException if the array of files includes
aoqi@0 85 * a directory
aoqi@0 86 * @throws NullPointerException if the given array contains null
aoqi@0 87 * elements
aoqi@0 88 */
aoqi@0 89 Iterable<? extends JavaFileObject> getJavaFileObjects(Path... paths);
aoqi@0 90
aoqi@0 91 /**
aoqi@0 92 * Return the Path for a file object that has been obtained from this
aoqi@0 93 * file manager.
aoqi@0 94 *
aoqi@0 95 * @param fo A file object that has been obtained from this file manager.
aoqi@0 96 * @return The underlying Path object.
aoqi@0 97 * @throws IllegalArgumentException is the file object was not obtained from
aoqi@0 98 * from this file manager.
aoqi@0 99 */
aoqi@0 100 Path getPath(FileObject fo);
aoqi@0 101
aoqi@0 102 /**
aoqi@0 103 * Get the search path associated with the given location.
aoqi@0 104 *
aoqi@0 105 * @param location a location
aoqi@0 106 * @return a list of paths or {@code null} if this location has no
aoqi@0 107 * associated search path
aoqi@0 108 * @see #setLocation
aoqi@0 109 */
aoqi@0 110 Iterable<? extends Path> getLocation(Location location);
aoqi@0 111
aoqi@0 112 /**
aoqi@0 113 * Associate the given search path with the given location. Any
aoqi@0 114 * previous value will be discarded.
aoqi@0 115 *
aoqi@0 116 * @param location a location
aoqi@0 117 * @param searchPath a list of files, if {@code null} use the default
aoqi@0 118 * search path for this location
aoqi@0 119 * @see #getLocation
aoqi@0 120 * @throws IllegalArgumentException if location is an output
aoqi@0 121 * location and searchpath does not contain exactly one element
aoqi@0 122 * @throws IOException if location is an output location and searchpath
aoqi@0 123 * does not represent an existing directory
aoqi@0 124 */
aoqi@0 125 void setLocation(Location location, Iterable<? extends Path> searchPath) throws IOException;
aoqi@0 126 }

mercurial