author | amurillo |
Fri, 10 Jun 2016 15:13:40 -0700 | |
changeset 38958 | d8a4ce6d05ad |
parent 29291 | 076c277565f7 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
5520 | 2 |
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. |
10 | 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 |
|
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
10 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
10 | 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 |
* |
|
5520 | 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. |
|
10 | 24 |
*/ |
25 |
||
26 |
package javax.tools; |
|
27 |
||
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; |
|
29291
076c277565f7
8073550: java* tools: replace obj.getClass hacks with Assert.checkNonNull or Objects.requireNonNull
mcimadamore
parents:
25874
diff
changeset
|
34 |
import java.util.Objects; |
10 | 35 |
|
36 |
/** |
|
37 |
* Forwards calls to a given file object. Subclasses of this class |
|
38 |
* might override some of these methods and might also provide |
|
39 |
* additional fields and methods. |
|
40 |
* |
|
41 |
* @param <F> the kind of file object forwarded to by this object |
|
42 |
* @author Peter von der Ahé |
|
43 |
* @since 1.6 |
|
44 |
*/ |
|
45 |
public class ForwardingFileObject<F extends FileObject> implements FileObject { |
|
46 |
||
47 |
/** |
|
48 |
* The file object which all methods are delegated to. |
|
49 |
*/ |
|
50 |
protected final F fileObject; |
|
51 |
||
52 |
/** |
|
53 |
* Creates a new instance of ForwardingFileObject. |
|
54 |
* @param fileObject delegate to this file object |
|
55 |
*/ |
|
56 |
protected ForwardingFileObject(F fileObject) { |
|
29291
076c277565f7
8073550: java* tools: replace obj.getClass hacks with Assert.checkNonNull or Objects.requireNonNull
mcimadamore
parents:
25874
diff
changeset
|
57 |
this.fileObject = Objects.requireNonNull(fileObject); |
10 | 58 |
} |
59 |
||
60 |
public URI toUri() { |
|
61 |
return fileObject.toUri(); |
|
62 |
} |
|
63 |
||
64 |
public String getName() { |
|
65 |
return fileObject.getName(); |
|
66 |
} |
|
67 |
||
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 |
} |
|
76 |
||
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 |
} |
|
85 |
||
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 |
} |
|
94 |
||
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 |
} |
|
103 |
||
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 |
} |
|
112 |
||
113 |
public long getLastModified() { |
|
114 |
return fileObject.getLastModified(); |
|
115 |
} |
|
116 |
||
117 |
public boolean delete() { |
|
118 |
return fileObject.delete(); |
|
119 |
} |
|
120 |
} |