duke@1: /* ohair@554: * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. duke@1: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@1: * duke@1: * This code is free software; you can redistribute it and/or modify it duke@1: * under the terms of the GNU General Public License version 2 only, as ohair@554: * published by the Free Software Foundation. Oracle designates this duke@1: * particular file as subject to the "Classpath" exception as provided ohair@554: * by Oracle in the LICENSE file that accompanied this code. duke@1: * duke@1: * This code is distributed in the hope that it will be useful, but WITHOUT duke@1: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@1: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@1: * version 2 for more details (a copy is included in the LICENSE file that duke@1: * accompanied this code). duke@1: * duke@1: * You should have received a copy of the GNU General Public License version duke@1: * 2 along with this work; if not, write to the Free Software Foundation, duke@1: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@1: * ohair@554: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@554: * or visit www.oracle.com if you need additional information or have any ohair@554: * questions. duke@1: */ duke@1: duke@1: package javax.tools; duke@1: duke@1: import java.io.File; duke@1: import java.io.IOException; duke@1: import java.util.*; duke@1: duke@1: /** duke@1: * File manager based on {@linkplain File java.io.File}. A common way duke@1: * to obtain an instance of this class is using {@linkplain duke@1: * JavaCompiler#getStandardFileManager duke@1: * getStandardFileManager}, for example: duke@1: * duke@1: *
duke@1:  *   JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
duke@1:  *   {@code DiagnosticCollector} diagnostics =
duke@1:  *       new {@code DiagnosticCollector()};
duke@1:  *   StandardJavaFileManager fm = compiler.getStandardFileManager(diagnostics, null, null);
duke@1:  * 
duke@1: * duke@1: * This file manager creates file objects representing regular duke@1: * {@linkplain File files}, duke@1: * {@linkplain java.util.zip.ZipEntry zip file entries}, or entries in duke@1: * similar file system based containers. Any file object returned duke@1: * from a file manager implementing this interface must observe the duke@1: * following behavior: duke@1: * duke@1: * duke@1: * duke@1: * According to these rules, the following URIs, for example, are duke@1: * allowed: duke@1: * duke@1: * Whereas these are not (reason in parentheses): duke@1: * duke@1: * duke@1: * @author Peter von der Ahé duke@1: * @since 1.6 duke@1: */ duke@1: public interface StandardJavaFileManager extends JavaFileManager { duke@1: duke@1: /** duke@1: * Compares two file objects and return true if they represent the duke@1: * same canonical file, zip file entry, or entry in any file duke@1: * system based container. duke@1: * duke@1: * @param a a file object duke@1: * @param b a file object duke@1: * @return true if the given file objects represent the same duke@1: * canonical file or zip file entry; false otherwise duke@1: * duke@1: * @throws IllegalArgumentException if either of the arguments duke@1: * were created with another file manager implementation duke@1: */ duke@1: boolean isSameFile(FileObject a, FileObject b); duke@1: duke@1: /** duke@1: * Gets file objects representing the given files. duke@1: * duke@1: * @param files a list of files duke@1: * @return a list of file objects duke@1: * @throws IllegalArgumentException if the list of files includes duke@1: * a directory duke@1: */ duke@1: Iterable getJavaFileObjectsFromFiles( duke@1: Iterable files); duke@1: duke@1: /** duke@1: * Gets file objects representing the given files. duke@1: * Convenience method equivalent to: duke@1: * duke@1: *
duke@1:      *     getJavaFileObjectsFromFiles({@linkplain java.util.Arrays#asList Arrays.asList}(files))
duke@1:      * 
duke@1: * duke@1: * @param files an array of files duke@1: * @return a list of file objects duke@1: * @throws IllegalArgumentException if the array of files includes duke@1: * a directory duke@1: * @throws NullPointerException if the given array contains null duke@1: * elements duke@1: */ duke@1: Iterable getJavaFileObjects(File... files); duke@1: duke@1: /** duke@1: * Gets file objects representing the given file names. duke@1: * duke@1: * @param names a list of file names duke@1: * @return a list of file objects duke@1: * @throws IllegalArgumentException if the list of file names duke@1: * includes a directory duke@1: */ duke@1: Iterable getJavaFileObjectsFromStrings( duke@1: Iterable names); duke@1: duke@1: /** duke@1: * Gets file objects representing the given file names. duke@1: * Convenience method equivalent to: duke@1: * duke@1: *
duke@1:      *     getJavaFileObjectsFromStrings({@linkplain java.util.Arrays#asList Arrays.asList}(names))
duke@1:      * 
duke@1: * duke@1: * @param names a list of file names duke@1: * @return a list of file objects duke@1: * @throws IllegalArgumentException if the array of file names duke@1: * includes a directory duke@1: * @throws NullPointerException if the given array contains null duke@1: * elements duke@1: */ duke@1: Iterable getJavaFileObjects(String... names); duke@1: duke@1: /** duke@1: * Associates the given path with the given location. Any duke@1: * previous value will be discarded. duke@1: * duke@1: * @param location a location duke@1: * @param path a list of files, if {@code null} use the default duke@1: * path for this location duke@1: * @see #getLocation duke@1: * @throws IllegalArgumentException if location is an output duke@1: * location and path does not contain exactly one element duke@1: * @throws IOException if location is an output location and path duke@1: * does not represent an existing directory duke@1: */ duke@1: void setLocation(Location location, Iterable path) duke@1: throws IOException; duke@1: duke@1: /** duke@1: * Gets the path associated with the given location. duke@1: * duke@1: * @param location a location duke@1: * @return a list of files or {@code null} if this location has no duke@1: * associated path duke@1: * @see #setLocation duke@1: */ duke@1: Iterable getLocation(Location location); duke@1: duke@1: }