0N/A/*
2273N/A * Copyright (c) 2006, 2008, 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
0N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
0N/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,
1472N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1472N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0N/A * or visit www.oracle.com if you need additional information or have any
0N/A * questions.
0N/A */
1879N/A
1879N/Apackage javax.tools;
1879N/A
1879N/Aimport java.io.IOException;
1879N/Aimport java.io.InputStream;
1879N/Aimport java.io.OutputStream;
1879N/Aimport java.io.Reader;
1879N/Aimport java.io.Writer;
1879N/Aimport java.net.URI;
1879N/A
1879N/A/**
1879N/A * File abstraction for tools. In this context, <em>file</em> means
1879N/A * an abstraction of regular files and other sources of data. For
1879N/A * example, a file object can be used to represent regular files,
1879N/A * memory cache, or data in databases.
1879N/A *
1879N/A * <p>All methods in this interface might throw a SecurityException if
1879N/A * a security exception occurs.
1879N/A *
1879N/A * <p>Unless explicitly allowed, all methods in this interface might
2073N/A * throw a NullPointerException if given a {@code null} argument.
2073N/A *
2073N/A * @author Peter von der Ah&eacute;
2073N/A * @author Jonathan Gibbons
2073N/A * @since 1.6
2073N/A */
0N/Apublic interface FileObject {
0N/A
0N/A /**
0N/A * Returns a URI identifying this file object.
0N/A * @return a URI
0N/A */
0N/A URI toUri();
0N/A
0N/A /**
0N/A * Gets a user-friendly name for this file object. The exact
0N/A * value returned is not specified but implementations should take
0N/A * care to preserve names as given by the user. For example, if
0N/A * the user writes the filename {@code "BobsApp\Test.java"} on
0N/A * the command line, this method should return {@code
0N/A * "BobsApp\Test.java"} whereas the {@linkplain #toUri toUri}
0N/A * method might return {@code
0N/A * file:///C:/Documents%20and%20Settings/UncleBob/BobsApp/Test.java}.
0N/A *
0N/A * @return a user-friendly name
0N/A */
0N/A String getName();
0N/A
0N/A /**
0N/A * Gets an InputStream for this file object.
0N/A *
0N/A * @return an InputStream
0N/A * @throws IllegalStateException if this file object was
0N/A * opened for writing and does not support reading
0N/A * @throws UnsupportedOperationException if this kind of file
0N/A * object does not support byte access
0N/A * @throws IOException if an I/O error occurred
0N/A */
0N/A InputStream openInputStream() throws IOException;
0N/A
0N/A /**
0N/A * Gets an OutputStream for this file object.
0N/A *
0N/A * @return an OutputStream
0N/A * @throws IllegalStateException if this file object was
0N/A * opened for reading and does not support writing
0N/A * @throws UnsupportedOperationException if this kind of
0N/A * file object does not support byte access
0N/A * @throws IOException if an I/O error occurred
0N/A */
0N/A OutputStream openOutputStream() throws IOException;
0N/A
0N/A /**
0N/A * Gets a reader for this object. The returned reader will
0N/A * replace bytes that cannot be decoded with the default
0N/A * translation character. In addition, the reader may report a
0N/A * diagnostic unless {@code ignoreEncodingErrors} is true.
0N/A *
0N/A * @param ignoreEncodingErrors ignore encoding errors if true
0N/A * @return a Reader
0N/A * @throws IllegalStateException if this file object was
0N/A * opened for writing and does not support reading
0N/A * @throws UnsupportedOperationException if this kind of
0N/A * file object does not support character access
0N/A * @throws IOException if an I/O error occurred
0N/A */
0N/A Reader openReader(boolean ignoreEncodingErrors) throws IOException;
0N/A
0N/A /**
0N/A * Gets the character content of this file object, if available.
0N/A * Any byte that cannot be decoded will be replaced by the default
0N/A * translation character. In addition, a diagnostic may be
0N/A * reported unless {@code ignoreEncodingErrors} is true.
0N/A *
0N/A * @param ignoreEncodingErrors ignore encoding errors if true
0N/A * @return a CharSequence if available; {@code null} otherwise
0N/A * @throws IllegalStateException if this file object was
0N/A * opened for writing and does not support reading
0N/A * @throws UnsupportedOperationException if this kind of
0N/A * file object does not support character access
0N/A * @throws IOException if an I/O error occurred
0N/A */
0N/A CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException;
0N/A
0N/A /**
0N/A * Gets a Writer for this file object.
0N/A *
0N/A * @return a Writer
0N/A * @throws IllegalStateException if this file object was
0N/A * opened for reading and does not support writing
0N/A * @throws UnsupportedOperationException if this kind of
0N/A * file object does not support character access
0N/A * @throws IOException if an I/O error occurred
0N/A */
0N/A Writer openWriter() throws IOException;
0N/A
0N/A /**
0N/A * Gets the time this file object was last modified. The time is
0N/A * measured in milliseconds since the epoch (00:00:00 GMT, January
0N/A * 1, 1970).
0N/A *
0N/A * @return the time this file object was last modified; or 0 if
0N/A * the file object does not exist, if an I/O error occurred, or if
0N/A * the operation is not supported
0N/A */
0N/A long getLastModified();
0N/A
0N/A /**
0N/A * Deletes this file object. In case of errors, returns false.
0N/A * @return true if and only if this file object is successfully
0N/A * deleted; false otherwise
0N/A */
0N/A boolean delete();
0N/A
0N/A}
0N/A