src/share/classes/com/sun/tools/javac/nio/PathFileManager.java

changeset 450
4011f49b4af8
child 554
9d9f26857129
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/classes/com/sun/tools/javac/nio/PathFileManager.java	Fri Dec 11 14:26:27 2009 -0800
     1.3 @@ -0,0 +1,125 @@
     1.4 +/*
     1.5 + * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.  Sun designates this
    1.11 + * particular file as subject to the "Classpath" exception as provided
    1.12 + * by Sun in the LICENSE file that accompanied this code.
    1.13 + *
    1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 + * version 2 for more details (a copy is included in the LICENSE file that
    1.18 + * accompanied this code).
    1.19 + *
    1.20 + * You should have received a copy of the GNU General Public License version
    1.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 + *
    1.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    1.25 + * CA 95054 USA or visit www.sun.com if you need additional information or
    1.26 + * have any questions.
    1.27 + */
    1.28 +
    1.29 +package com.sun.tools.javac.nio;
    1.30 +
    1.31 +import java.io.IOException;
    1.32 +import java.nio.file.FileSystem;
    1.33 +import java.nio.file.Path;
    1.34 +import javax.tools.FileObject;
    1.35 +import javax.tools.JavaFileManager;
    1.36 +import javax.tools.JavaFileObject;
    1.37 +
    1.38 +/**
    1.39 + *  File manager based on {@linkplain File java.nio.file.Path}.
    1.40 + *
    1.41 + *  Eventually, this should be moved to javax.tools.
    1.42 + *  Also, JavaCompiler might reasonably provide a method getPathFileManager,
    1.43 + *  similar to {@link javax.tools.JavaCompiler#getStandardFileManager
    1.44 + *  getStandardFileManager}. However, would need to be handled carefully
    1.45 + *  as another forward reference from langtools to jdk.
    1.46 + *
    1.47 + *  <p><b>This is NOT part of any API supported by Sun Microsystems.  If
    1.48 + *  you write code that depends on this, you do so at your own risk.
    1.49 + *  This code and its internal interfaces are subject to change or
    1.50 + *  deletion without notice.</b>
    1.51 + */
    1.52 +public interface PathFileManager extends JavaFileManager {
    1.53 +    /**
    1.54 +     * Get the default file system used to create paths. If no value has been
    1.55 +     * set, the default file system is {@link FileSystems#getDefault}.
    1.56 +     */
    1.57 +    FileSystem getDefaultFileSystem();
    1.58 +
    1.59 +    /**
    1.60 +     * Set the default file system used to create paths.
    1.61 +     * @param fs the default file system used to create any new paths.
    1.62 +     */
    1.63 +    void setDefaultFileSystem(FileSystem fs);
    1.64 +
    1.65 +    /**
    1.66 +     * Get file objects representing the given files.
    1.67 +     *
    1.68 +     * @param paths a list of paths
    1.69 +     * @return a list of file objects
    1.70 +     * @throws IllegalArgumentException if the list of paths includes
    1.71 +     * a directory
    1.72 +     */
    1.73 +    Iterable<? extends JavaFileObject> getJavaFileObjectsFromPaths(
    1.74 +        Iterable<? extends Path> paths);
    1.75 +
    1.76 +    /**
    1.77 +     * Get file objects representing the given paths.
    1.78 +     * Convenience method equivalent to:
    1.79 +     *
    1.80 +     * <pre>
    1.81 +     *     getJavaFileObjectsFromPaths({@linkplain java.util.Arrays#asList Arrays.asList}(paths))
    1.82 +     * </pre>
    1.83 +     *
    1.84 +     * @param paths an array of paths
    1.85 +     * @return a list of file objects
    1.86 +     * @throws IllegalArgumentException if the array of files includes
    1.87 +     * a directory
    1.88 +     * @throws NullPointerException if the given array contains null
    1.89 +     * elements
    1.90 +     */
    1.91 +    Iterable<? extends JavaFileObject> getJavaFileObjects(Path... paths);
    1.92 +
    1.93 +    /**
    1.94 +     * Return the Path for a file object that has been obtained from this
    1.95 +     * file manager.
    1.96 +     *
    1.97 +     * @param fo A file object that has been obtained from this file manager.
    1.98 +     * @return The underlying Path object.
    1.99 +     * @throws IllegalArgumentException is the file object was not obtained from
   1.100 +     * from this file manager.
   1.101 +     */
   1.102 +    Path getPath(FileObject fo);
   1.103 +
   1.104 +    /**
   1.105 +     * Get the search path associated with the given location.
   1.106 +     *
   1.107 +     * @param location a location
   1.108 +     * @return a list of paths or {@code null} if this location has no
   1.109 +     * associated search path
   1.110 +     * @see #setLocation
   1.111 +     */
   1.112 +    Iterable<? extends Path> getLocation(Location location);
   1.113 +
   1.114 +    /**
   1.115 +     * Associate the given search path with the given location.  Any
   1.116 +     * previous value will be discarded.
   1.117 +     *
   1.118 +     * @param location a location
   1.119 +     * @param searchPath a list of files, if {@code null} use the default
   1.120 +     * search path for this location
   1.121 +     * @see #getLocation
   1.122 +     * @throws IllegalArgumentException if location is an output
   1.123 +     * location and searchpath does not contain exactly one element
   1.124 +     * @throws IOException if location is an output location and searchpath
   1.125 +     * does not represent an existing directory
   1.126 +     */
   1.127 +    void setLocation(Location location, Iterable<? extends Path> searchPath) throws IOException;
   1.128 +}

mercurial