1 /* 2 * Copyright 2009 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 */ 25 26 package com.sun.tools.javac.nio; 27 28 import java.io.IOException; 29 import java.nio.file.FileSystem; 30 import java.nio.file.Path; 31 import javax.tools.FileObject; 32 import javax.tools.JavaFileManager; 33 import javax.tools.JavaFileObject; 34 35 /** 36 * File manager based on {@linkplain File java.nio.file.Path}. 37 * 38 * Eventually, this should be moved to javax.tools. 39 * Also, JavaCompipler might reasonably provide a method getPathFileManager, 40 * similar to {@link javax.tools.JavaCompiler#getStandardFileManager 41 * getStandardFileManager}. 42 * 43 * <p><b>This is NOT part of any API supported by Sun Microsystems. If 44 * you write code that depends on this, you do so at your own risk. 45 * This code and its internal interfaces are subject to change or 46 * deletion without notice.</b> 47 */ 48 public interface PathFileManager extends JavaFileManager { 49 /** 50 * Get the default file system used to create paths. If no value has been 51 * set, the default file system is {@link FileSystems#getDefault}. 52 */ 53 FileSystem getDefaultFileSystem(); 54 55 /** 56 * Set the default file system used to create paths. 57 * @param fs the default file system used to create any new paths. 58 */ 59 void setDefaultFileSystem(FileSystem fs); 60 61 /** 62 * Get file objects representing the given files. 63 * 64 * @param paths a list of paths 65 * @return a list of file objects 66 * @throws IllegalArgumentException if the list of paths includes 67 * a directory 68 */ 69 Iterable<? extends JavaFileObject> getJavaFileObjectsFromPaths( 70 Iterable<? extends Path> paths); 71 72 /** 73 * Get file objects representing the given paths. 74 * Convenience method equivalent to: 75 * 76 * <pre> 77 * getJavaFileObjectsFromPaths({@linkplain java.util.Arrays#asList Arrays.asList}(paths)) 78 * </pre> 79 * 80 * @param paths an array of paths 81 * @return a list of file objects 82 * @throws IllegalArgumentException if the array of files includes 83 * a directory 84 * @throws NullPointerException if the given array contains null 85 * elements 86 */ 87 Iterable<? extends JavaFileObject> getJavaFileObjects(Path... paths); 88 89 /** 90 * Return the Path for a file object that has been obtained from this 91 * file manager. 92 * 93 * @param fo A file object that has been obtained from this file manager. 94 * @return The underlying Path object. 95 * @throws IllegalArgumentException is the file object was not obtained from 96 * from this file manager. 97 */ 98 Path getPath(FileObject fo); 99 100 /** 101 * Get the search path associated with the given location. 102 * 103 * @param location a location 104 * @return a list of paths or {@code null} if this location has no 105 * associated search path 106 * @see #setLocation 107 */ 108 Iterable<? extends Path> getLocation(Location location); 109 110 /** 111 * Associate the given search path with the given location. Any 112 * previous value will be discarded. 113 * 114 * @param location a location 115 * @param searchPath a list of files, if {@code null} use the default 116 * search path for this location 117 * @see #getLocation 118 * @throws IllegalArgumentException if location is an output 119 * location and searchpath does not contain exactly one element 120 * @throws IOException if location is an output location and searchpath 121 * does not represent an existing directory 122 */ 123 void setLocation(Location location, Iterable<? extends Path> searchPath) throws IOException; 124 }