Path: blob/aarch64-shenandoah-jdk8u272-b10/langtools/src/share/classes/javax/tools/ForwardingFileObject.java
38900 views
/*1* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.tools;2627import java.io.IOException;28import java.io.InputStream;29import java.io.OutputStream;30import java.io.Reader;31import java.io.Writer;32import java.net.URI;3334/**35* Forwards calls to a given file object. Subclasses of this class36* might override some of these methods and might also provide37* additional fields and methods.38*39* @param <F> the kind of file object forwarded to by this object40* @author Peter von der Ahé41* @since 1.642*/43public class ForwardingFileObject<F extends FileObject> implements FileObject {4445/**46* The file object which all methods are delegated to.47*/48protected final F fileObject;4950/**51* Creates a new instance of ForwardingFileObject.52* @param fileObject delegate to this file object53*/54protected ForwardingFileObject(F fileObject) {55fileObject.getClass(); // null check56this.fileObject = fileObject;57}5859public URI toUri() {60return fileObject.toUri();61}6263public String getName() {64return fileObject.getName();65}6667/**68* @throws IllegalStateException {@inheritDoc}69* @throws UnsupportedOperationException {@inheritDoc}70* @throws IOException {@inheritDoc}71*/72public InputStream openInputStream() throws IOException {73return fileObject.openInputStream();74}7576/**77* @throws IllegalStateException {@inheritDoc}78* @throws UnsupportedOperationException {@inheritDoc}79* @throws IOException {@inheritDoc}80*/81public OutputStream openOutputStream() throws IOException {82return fileObject.openOutputStream();83}8485/**86* @throws IllegalStateException {@inheritDoc}87* @throws UnsupportedOperationException {@inheritDoc}88* @throws IOException {@inheritDoc}89*/90public Reader openReader(boolean ignoreEncodingErrors) throws IOException {91return fileObject.openReader(ignoreEncodingErrors);92}9394/**95* @throws IllegalStateException {@inheritDoc}96* @throws UnsupportedOperationException {@inheritDoc}97* @throws IOException {@inheritDoc}98*/99public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {100return fileObject.getCharContent(ignoreEncodingErrors);101}102103/**104* @throws IllegalStateException {@inheritDoc}105* @throws UnsupportedOperationException {@inheritDoc}106* @throws IOException {@inheritDoc}107*/108public Writer openWriter() throws IOException {109return fileObject.openWriter();110}111112public long getLastModified() {113return fileObject.getLastModified();114}115116public boolean delete() {117return fileObject.delete();118}119}120121122