0N/A/*
553N/A * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
553N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
553N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
553N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
553N/A * or visit www.oracle.com if you need additional information or have any
553N/A * questions.
0N/A */
0N/A
0N/Apackage javax.tools;
0N/A
0N/Aimport java.io.File;
0N/Aimport java.io.IOException;
0N/Aimport java.util.*;
0N/A
0N/A/**
0N/A * File manager based on {@linkplain File java.io.File}. A common way
0N/A * to obtain an instance of this class is using {@linkplain
0N/A * JavaCompiler#getStandardFileManager
0N/A * getStandardFileManager}, for example:
0N/A *
0N/A * <pre>
0N/A * JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
0N/A * {@code DiagnosticCollector<JavaFileObject>} diagnostics =
0N/A * new {@code DiagnosticCollector<JavaFileObject>()};
0N/A * StandardJavaFileManager fm = compiler.getStandardFileManager(diagnostics, null, null);
0N/A * </pre>
0N/A *
0N/A * This file manager creates file objects representing regular
0N/A * {@linkplain File files},
0N/A * {@linkplain java.util.zip.ZipEntry zip file entries}, or entries in
0N/A * similar file system based containers. Any file object returned
0N/A * from a file manager implementing this interface must observe the
0N/A * following behavior:
0N/A *
0N/A * <ul>
0N/A * <li>
0N/A * File names need not be canonical.
0N/A * </li>
0N/A * <li>
0N/A * For file objects representing regular files
0N/A * <ul>
0N/A * <li>
0N/A * the method <code>{@linkplain FileObject#delete()}</code>
0N/A * is equivalent to <code>{@linkplain File#delete()}</code>,
0N/A * </li>
0N/A * <li>
0N/A * the method <code>{@linkplain FileObject#getLastModified()}</code>
0N/A * is equivalent to <code>{@linkplain File#lastModified()}</code>,
0N/A * </li>
0N/A * <li>
0N/A * the methods <code>{@linkplain FileObject#getCharContent(boolean)}</code>,
0N/A * <code>{@linkplain FileObject#openInputStream()}</code>, and
0N/A * <code>{@linkplain FileObject#openReader(boolean)}</code>
0N/A * must succeed if the following would succeed (ignoring
0N/A * encoding issues):
0N/A * <blockquote>
0N/A * <pre>new {@linkplain java.io.FileInputStream#FileInputStream(File) FileInputStream}(new {@linkplain File#File(java.net.URI) File}({@linkplain FileObject fileObject}.{@linkplain FileObject#toUri() toUri}()))</pre>
0N/A * </blockquote>
0N/A * </li>
0N/A * <li>
0N/A * and the methods
0N/A * <code>{@linkplain FileObject#openOutputStream()}</code>, and
0N/A * <code>{@linkplain FileObject#openWriter()}</code> must
0N/A * succeed if the following would succeed (ignoring encoding
0N/A * issues):
0N/A * <blockquote>
0N/A * <pre>new {@linkplain java.io.FileOutputStream#FileOutputStream(File) FileOutputStream}(new {@linkplain File#File(java.net.URI) File}({@linkplain FileObject fileObject}.{@linkplain FileObject#toUri() toUri}()))</pre>
0N/A * </blockquote>
0N/A * </li>
0N/A * </ul>
0N/A * </li>
0N/A * <li>
0N/A * The {@linkplain java.net.URI URI} returned from
0N/A * <code>{@linkplain FileObject#toUri()}</code>
0N/A * <ul>
0N/A * <li>
0N/A * must be {@linkplain java.net.URI#isAbsolute() absolute} (have a schema), and
0N/A * </li>
0N/A * <li>
0N/A * must have a {@linkplain java.net.URI#normalize() normalized}
0N/A * {@linkplain java.net.URI#getPath() path component} which
0N/A * can be resolved without any process-specific context such
0N/A * as the current directory (file names must be absolute).
0N/A * </li>
0N/A * </ul>
0N/A * </li>
0N/A * </ul>
0N/A *
0N/A * According to these rules, the following URIs, for example, are
0N/A * allowed:
0N/A * <ul>
0N/A * <li>
0N/A * <code>file:///C:/Documents%20and%20Settings/UncleBob/BobsApp/Test.java</code>
0N/A * </li>
0N/A * <li>
0N/A * <code>jar:///C:/Documents%20and%20Settings/UncleBob/lib/vendorA.jar!com/vendora/LibraryClass.class</code>
0N/A * </li>
0N/A * </ul>
0N/A * Whereas these are not (reason in parentheses):
0N/A * <ul>
0N/A * <li>
0N/A * <code>file:BobsApp/Test.java</code> (the file name is relative
0N/A * and depend on the current directory)
0N/A * </li>
0N/A * <li>
0N/A * <code>jar:lib/vendorA.jar!com/vendora/LibraryClass.class</code>
0N/A * (the first half of the path depends on the current directory,
0N/A * whereas the component after ! is legal)
0N/A * </li>
0N/A * <li>
0N/A * <code>Test.java</code> (this URI depends on the current
0N/A * directory and does not have a schema)
0N/A * </li>
0N/A * <li>
0N/A * <code>jar:///C:/Documents%20and%20Settings/UncleBob/BobsApp/../lib/vendorA.jar!com/vendora/LibraryClass.class</code>
0N/A * (the path is not normalized)
0N/A * </li>
0N/A * </ul>
0N/A *
0N/A * @author Peter von der Ah&eacute;
0N/A * @since 1.6
0N/A */
0N/Apublic interface StandardJavaFileManager extends JavaFileManager {
0N/A
0N/A /**
0N/A * Compares two file objects and return true if they represent the
0N/A * same canonical file, zip file entry, or entry in any file
0N/A * system based container.
0N/A *
0N/A * @param a a file object
0N/A * @param b a file object
0N/A * @return true if the given file objects represent the same
0N/A * canonical file or zip file entry; false otherwise
0N/A *
0N/A * @throws IllegalArgumentException if either of the arguments
0N/A * were created with another file manager implementation
0N/A */
0N/A boolean isSameFile(FileObject a, FileObject b);
0N/A
0N/A /**
0N/A * Gets file objects representing the given files.
0N/A *
0N/A * @param files a list of files
0N/A * @return a list of file objects
0N/A * @throws IllegalArgumentException if the list of files includes
0N/A * a directory
0N/A */
0N/A Iterable<? extends JavaFileObject> getJavaFileObjectsFromFiles(
0N/A Iterable<? extends File> files);
0N/A
0N/A /**
0N/A * Gets file objects representing the given files.
0N/A * Convenience method equivalent to:
0N/A *
0N/A * <pre>
0N/A * getJavaFileObjectsFromFiles({@linkplain java.util.Arrays#asList Arrays.asList}(files))
0N/A * </pre>
0N/A *
0N/A * @param files an array of files
0N/A * @return a list of file objects
0N/A * @throws IllegalArgumentException if the array of files includes
0N/A * a directory
0N/A * @throws NullPointerException if the given array contains null
0N/A * elements
0N/A */
0N/A Iterable<? extends JavaFileObject> getJavaFileObjects(File... files);
0N/A
0N/A /**
0N/A * Gets file objects representing the given file names.
0N/A *
0N/A * @param names a list of file names
0N/A * @return a list of file objects
0N/A * @throws IllegalArgumentException if the list of file names
0N/A * includes a directory
0N/A */
0N/A Iterable<? extends JavaFileObject> getJavaFileObjectsFromStrings(
0N/A Iterable<String> names);
0N/A
0N/A /**
0N/A * Gets file objects representing the given file names.
0N/A * Convenience method equivalent to:
0N/A *
0N/A * <pre>
0N/A * getJavaFileObjectsFromStrings({@linkplain java.util.Arrays#asList Arrays.asList}(names))
0N/A * </pre>
0N/A *
0N/A * @param names a list of file names
0N/A * @return a list of file objects
0N/A * @throws IllegalArgumentException if the array of file names
0N/A * includes a directory
0N/A * @throws NullPointerException if the given array contains null
0N/A * elements
0N/A */
0N/A Iterable<? extends JavaFileObject> getJavaFileObjects(String... names);
0N/A
0N/A /**
0N/A * Associates the given path with the given location. Any
0N/A * previous value will be discarded.
0N/A *
0N/A * @param location a location
0N/A * @param path a list of files, if {@code null} use the default
0N/A * path for this location
0N/A * @see #getLocation
0N/A * @throws IllegalArgumentException if location is an output
0N/A * location and path does not contain exactly one element
0N/A * @throws IOException if location is an output location and path
0N/A * does not represent an existing directory
0N/A */
0N/A void setLocation(Location location, Iterable<? extends File> path)
0N/A throws IOException;
0N/A
0N/A /**
0N/A * Gets the path associated with the given location.
0N/A *
0N/A * @param location a location
0N/A * @return a list of files or {@code null} if this location has no
0N/A * associated path
0N/A * @see #setLocation
0N/A */
0N/A Iterable<? extends File> getLocation(Location location);
0N/A
0N/A}