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