/*
* @(#)StandardJavaFileManager.java 1.13 06/09/25
*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package javax.tools;
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.*;
/**
* File manager based on {@linkplain File java.io.File}. A common way
* to obtain an instance of this class is using {@linkplain
* JavaCompiler#getStandardFileManager
* getStandardFileManager}, for example:
*
* <pre>
* JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
* {@code DiagnosticCollector<JavaFileObject>} diagnostics =
* new {@code DiagnosticCollector<JavaFileObject>()};
* StandardJavaFileManager fm = compiler.getStandardFileManager(diagnostics, null, null);
* </pre>
*
* This file manager creates file objects representing regular
* {@linkplain File files},
* {@linkplain java.util.zip.ZipEntry zip file entries}, or entries in
* similar file system based containers. Any file object returned
* from a file manager implementing this interface must observe the
* following behavior:
*
* <ul>
* <li>
* File names need not be canonical.
* </li>
* <li>
* For file objects representing regular files
* <ul>
* <li>
* the method <code>{@linkplain FileObject#delete()}</code>
* is equivalent to <code>{@linkplain File#delete()}</code>,
* </li>
* <li>
* the method <code>{@linkplain FileObject#getLastModified()}</code>
* is equivalent to <code>{@linkplain File#lastModified()}</code>,
* </li>
* <li>
* the methods <code>{@linkplain FileObject#getCharContent(boolean)}</code>,
* <code>{@linkplain FileObject#openInputStream()}</code>, and
* <code>{@linkplain FileObject#openReader(boolean)}</code>
* must succeed if the following would succeed (ignoring
* encoding issues):
* <blockquote>
* <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>
* </blockquote>
* </li>
* <li>
* and the methods
* <code>{@linkplain FileObject#openOutputStream()}</code>, and
* <code>{@linkplain FileObject#openWriter()}</code> must
* succeed if the following would succeed (ignoring encoding
* issues):
* <blockquote>
* <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>
* </blockquote>
* </li>
* </ul>
* </li>
* <li>
* The {@linkplain java.net.URI URI} returned from
* <code>{@linkplain FileObject#toUri()}</code>
* <ul>
* <li>
* must be {@linkplain java.net.URI#isAbsolute() absolute} (have a schema), and
* </li>
* <li>
* must have a {@linkplain java.net.URI#normalize() normalized}
* {@linkplain java.net.URI#getPath() path component} which
* can be resolved without any process-specific context such
* as the current directory (file names must be absolute).
* </li>
* </ul>
* </li>
* </ul>
*
* According to these rules, the following URIs, for example, are
* allowed:
* <ul>
* <li>
* <code>file:///C:/Documents%20and%20Settings/UncleBob/BobsApp/Test.java</code>
* </li>
* <li>
* <code>jar:///C:/Documents%20and%20Settings/UncleBob/lib/vendorA.jar!com/vendora/LibraryClass.class</code>
* </li>
* </ul>
* Whereas these are not (reason in parentheses):
* <ul>
=1= |