src/java.compiler/share/classes/javax/tools/FileObject.java
author erikj
Tue, 12 Sep 2017 19:03:39 +0200
changeset 47216 71c04702a3d5
parent 25874 langtools/src/java.compiler/share/classes/javax/tools/FileObject.java@83c19f00452c
permissions -rw-r--r--
8187443: Forest Consolidation: Move files to unified layout Reviewed-by: darcy, ihse
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 5520
diff changeset
     2
 * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1652
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1652
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1652
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1652
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1652
diff changeset
    23
 * questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
package javax.tools;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
import java.io.IOException;
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
import java.io.InputStream;
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
import java.io.OutputStream;
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
import java.io.Reader;
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
import java.io.Writer;
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
import java.net.URI;
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 * File abstraction for tools.  In this context, <em>file</em> means
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 * an abstraction of regular files and other sources of data.  For
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 * example, a file object can be used to represent regular files,
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 * memory cache, or data in databases.
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 * <p>All methods in this interface might throw a SecurityException if
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
 * a security exception occurs.
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
 * <p>Unless explicitly allowed, all methods in this interface might
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
 * throw a NullPointerException if given a {@code null} argument.
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
 * @author Peter von der Ah&eacute;
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
 * @author Jonathan Gibbons
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
 * @since 1.6
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
public interface FileObject {
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
     * Returns a URI identifying this file object.
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
     * @return a URI
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
    URI toUri();
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
    /**
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 5520
diff changeset
    60
     * Returns a user-friendly name for this file object.  The exact
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
     * value returned is not specified but implementations should take
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
     * care to preserve names as given by the user.  For example, if
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
     * the user writes the filename {@code "BobsApp\Test.java"} on
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
     * the command line, this method should return {@code
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
     * "BobsApp\Test.java"} whereas the {@linkplain #toUri toUri}
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
     * method might return {@code
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
     * file:///C:/Documents%20and%20Settings/UncleBob/BobsApp/Test.java}.
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
     * @return a user-friendly name
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
    String getName();
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
    /**
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 5520
diff changeset
    74
     * Returns an InputStream for this file object.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
     * @return an InputStream
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
     * @throws IllegalStateException if this file object was
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
     * opened for writing and does not support reading
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
     * @throws UnsupportedOperationException if this kind of file
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
     * object does not support byte access
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
     * @throws IOException if an I/O error occurred
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
    InputStream openInputStream() throws IOException;
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
    /**
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 5520
diff changeset
    86
     * Returns an OutputStream for this file object.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
     * @return an OutputStream
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
     * @throws IllegalStateException if this file object was
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
     * opened for reading and does not support writing
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
     * @throws UnsupportedOperationException if this kind of
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
     * file object does not support byte access
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
     * @throws IOException if an I/O error occurred
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
    OutputStream openOutputStream() throws IOException;
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
    /**
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 5520
diff changeset
    98
     * Returns a reader for this object.  The returned reader will
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
     * replace bytes that cannot be decoded with the default
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
     * translation character.  In addition, the reader may report a
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
     * diagnostic unless {@code ignoreEncodingErrors} is true.
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
     * @param ignoreEncodingErrors ignore encoding errors if true
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
     * @return a Reader
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
     * @throws IllegalStateException if this file object was
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
     * opened for writing and does not support reading
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
     * @throws UnsupportedOperationException if this kind of
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
     * file object does not support character access
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
     * @throws IOException if an I/O error occurred
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
    Reader openReader(boolean ignoreEncodingErrors) throws IOException;
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
    /**
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 5520
diff changeset
   114
     * Returns the character content of this file object, if available.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
     * Any byte that cannot be decoded will be replaced by the default
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
     * translation character.  In addition, a diagnostic may be
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
     * reported unless {@code ignoreEncodingErrors} is true.
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
     * @param ignoreEncodingErrors ignore encoding errors if true
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
     * @return a CharSequence if available; {@code null} otherwise
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
     * @throws IllegalStateException if this file object was
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
     * opened for writing and does not support reading
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
     * @throws UnsupportedOperationException if this kind of
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
     * file object does not support character access
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
     * @throws IOException if an I/O error occurred
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
    CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException;
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
    /**
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 5520
diff changeset
   130
     * Returns a Writer for this file object.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
     * @return a Writer
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
     * @throws IllegalStateException if this file object was
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
     * opened for reading and does not support writing
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
     * @throws UnsupportedOperationException if this kind of
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
     * file object does not support character access
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
     * @throws IOException if an I/O error occurred
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
    Writer openWriter() throws IOException;
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
    /**
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 5520
diff changeset
   142
     * Returns the time this file object was last modified.  The time is
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
     * measured in milliseconds since the epoch (00:00:00 GMT, January
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
     * 1, 1970).
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
     * @return the time this file object was last modified; or 0 if
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
     * the file object does not exist, if an I/O error occurred, or if
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
     * the operation is not supported
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
    long getLastModified();
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
     * Deletes this file object.  In case of errors, returns false.
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
     * @return true if and only if this file object is successfully
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
     * deleted; false otherwise
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
    boolean delete();
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
}