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 DiagnosticCollectoraoqi@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: *} diagnostics = aoqi@0: * new {@code DiagnosticCollector ()}; aoqi@0: * StandardJavaFileManager fm = compiler.getStandardFileManager(diagnostics, null, null); aoqi@0: *
{@linkplain FileObject#delete()}
aoqi@0: * is equivalent to {@linkplain File#delete()}
,
aoqi@0: * {@linkplain FileObject#getLastModified()}
aoqi@0: * is equivalent to {@linkplain File#lastModified()}
,
aoqi@0: * {@linkplain FileObject#getCharContent(boolean)}
,
aoqi@0: * {@linkplain FileObject#openInputStream()}
, and
aoqi@0: * {@linkplain FileObject#openReader(boolean)}
aoqi@0: * must succeed if the following would succeed (ignoring
aoqi@0: * encoding issues):
aoqi@0: * aoqi@0: *aoqi@0: *new {@linkplain java.io.FileInputStream#FileInputStream(File) FileInputStream}(new {@linkplain File#File(java.net.URI) File}({@linkplain FileObject fileObject}.{@linkplain FileObject#toUri() toUri}()))aoqi@0: *
{@linkplain FileObject#openOutputStream()}
, and
aoqi@0: * {@linkplain FileObject#openWriter()}
must
aoqi@0: * succeed if the following would succeed (ignoring encoding
aoqi@0: * issues):
aoqi@0: * aoqi@0: *aoqi@0: *new {@linkplain java.io.FileOutputStream#FileOutputStream(File) FileOutputStream}(new {@linkplain File#File(java.net.URI) File}({@linkplain FileObject fileObject}.{@linkplain FileObject#toUri() toUri}()))aoqi@0: *
{@linkplain FileObject#toUri()}
aoqi@0: * file:///C:/Documents%20and%20Settings/UncleBob/BobsApp/Test.java
aoqi@0: * jar:///C:/Documents%20and%20Settings/UncleBob/lib/vendorA.jar!com/vendora/LibraryClass.class
aoqi@0: * file:BobsApp/Test.java
(the file name is relative
aoqi@0: * and depend on the current directory)
aoqi@0: * jar:lib/vendorA.jar!com/vendora/LibraryClass.class
aoqi@0: * (the first half of the path depends on the current directory,
aoqi@0: * whereas the component after ! is legal)
aoqi@0: * Test.java
(this URI depends on the current
aoqi@0: * directory and does not have a schema)
aoqi@0: * jar:///C:/Documents%20and%20Settings/UncleBob/BobsApp/../lib/vendorA.jar!com/vendora/LibraryClass.class
aoqi@0: * (the path is not normalized)
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 extends JavaFileObject> 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 extends JavaFileObject> getJavaFileObjectsFromStrings( aoqi@0: Iterable
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 extends JavaFileObject> 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 extends File> 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 extends File> getLocation(Location location); aoqi@0: aoqi@0: }