src/share/classes/javax/tools/ForwardingFileObject.java

Mon, 10 Dec 2012 16:21:26 +0000

author
vromero
date
Mon, 10 Dec 2012 16:21:26 +0000
changeset 1442
fcf89720ae71
parent 554
9d9f26857129
child 2525
2eb010b6cb22
permissions
-rw-r--r--

8003967: detect and remove all mutable implicit static enum fields in langtools
Reviewed-by: jjg

     1 /*
     2  * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     8  * particular file as subject to the "Classpath" exception as provided
     9  * by Oracle in the LICENSE file that accompanied this code.
    10  *
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    14  * version 2 for more details (a copy is included in the LICENSE file that
    15  * accompanied this code).
    16  *
    17  * You should have received a copy of the GNU General Public License version
    18  * 2 along with this work; if not, write to the Free Software Foundation,
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    20  *
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22  * or visit www.oracle.com if you need additional information or have any
    23  * questions.
    24  */
    26 package javax.tools;
    28 import java.io.IOException;
    29 import java.io.InputStream;
    30 import java.io.OutputStream;
    31 import java.io.Reader;
    32 import java.io.Writer;
    33 import java.net.URI;
    35 /**
    36  * Forwards calls to a given file object.  Subclasses of this class
    37  * might override some of these methods and might also provide
    38  * additional fields and methods.
    39  *
    40  * @param <F> the kind of file object forwarded to by this object
    41  * @author Peter von der Ah&eacute;
    42  * @since 1.6
    43  */
    44 public class ForwardingFileObject<F extends FileObject> implements FileObject {
    46     /**
    47      * The file object which all methods are delegated to.
    48      */
    49     protected final F fileObject;
    51     /**
    52      * Creates a new instance of ForwardingFileObject.
    53      * @param fileObject delegate to this file object
    54      */
    55     protected ForwardingFileObject(F fileObject) {
    56         fileObject.getClass(); // null check
    57         this.fileObject = fileObject;
    58     }
    60     public URI toUri() {
    61         return fileObject.toUri();
    62     }
    64     public String getName() {
    65         return fileObject.getName();
    66     }
    68     /**
    69      * @throws IllegalStateException {@inheritDoc}
    70      * @throws UnsupportedOperationException {@inheritDoc}
    71      * @throws IOException {@inheritDoc}
    72      */
    73     public InputStream openInputStream() throws IOException {
    74         return fileObject.openInputStream();
    75     }
    77     /**
    78      * @throws IllegalStateException {@inheritDoc}
    79      * @throws UnsupportedOperationException {@inheritDoc}
    80      * @throws IOException {@inheritDoc}
    81      */
    82     public OutputStream openOutputStream() throws IOException {
    83         return fileObject.openOutputStream();
    84     }
    86     /**
    87      * @throws IllegalStateException {@inheritDoc}
    88      * @throws UnsupportedOperationException {@inheritDoc}
    89      * @throws IOException {@inheritDoc}
    90      */
    91     public Reader openReader(boolean ignoreEncodingErrors) throws IOException {
    92         return fileObject.openReader(ignoreEncodingErrors);
    93     }
    95     /**
    96      * @throws IllegalStateException {@inheritDoc}
    97      * @throws UnsupportedOperationException {@inheritDoc}
    98      * @throws IOException {@inheritDoc}
    99      */
   100     public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
   101         return fileObject.getCharContent(ignoreEncodingErrors);
   102     }
   104     /**
   105      * @throws IllegalStateException {@inheritDoc}
   106      * @throws UnsupportedOperationException {@inheritDoc}
   107      * @throws IOException {@inheritDoc}
   108      */
   109     public Writer openWriter() throws IOException {
   110         return fileObject.openWriter();
   111     }
   113     public long getLastModified() {
   114         return fileObject.getLastModified();
   115     }
   117     public boolean delete() {
   118         return fileObject.delete();
   119     }
   120 }

mercurial