Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.compiler/share/classes/javax/tools/ForwardingFileObject.java
41152 views
1
/*
2
* Copyright (c) 2006, 2020, 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
*/
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;
34
import java.util.Objects;
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&eacute;
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 {@code ForwardingFileObject}.
54
* @param fileObject delegate to this file object
55
*/
56
protected ForwardingFileObject(F fileObject) {
57
this.fileObject = Objects.requireNonNull(fileObject);
58
}
59
60
@Override
61
public URI toUri() {
62
return fileObject.toUri();
63
}
64
65
@Override
66
public String getName() {
67
return fileObject.getName();
68
}
69
70
/**
71
* @throws IllegalStateException {@inheritDoc}
72
* @throws UnsupportedOperationException {@inheritDoc}
73
* @throws IOException {@inheritDoc}
74
*/
75
@Override
76
public InputStream openInputStream() throws IOException {
77
return fileObject.openInputStream();
78
}
79
80
/**
81
* @throws IllegalStateException {@inheritDoc}
82
* @throws UnsupportedOperationException {@inheritDoc}
83
* @throws IOException {@inheritDoc}
84
*/
85
@Override
86
public OutputStream openOutputStream() throws IOException {
87
return fileObject.openOutputStream();
88
}
89
90
/**
91
* @throws IllegalStateException {@inheritDoc}
92
* @throws UnsupportedOperationException {@inheritDoc}
93
* @throws IOException {@inheritDoc}
94
*/
95
@Override
96
public Reader openReader(boolean ignoreEncodingErrors) throws IOException {
97
return fileObject.openReader(ignoreEncodingErrors);
98
}
99
100
/**
101
* @throws IllegalStateException {@inheritDoc}
102
* @throws UnsupportedOperationException {@inheritDoc}
103
* @throws IOException {@inheritDoc}
104
*/
105
@Override
106
public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
107
return fileObject.getCharContent(ignoreEncodingErrors);
108
}
109
110
/**
111
* @throws IllegalStateException {@inheritDoc}
112
* @throws UnsupportedOperationException {@inheritDoc}
113
* @throws IOException {@inheritDoc}
114
*/
115
@Override
116
public Writer openWriter() throws IOException {
117
return fileObject.openWriter();
118
}
119
120
@Override
121
public long getLastModified() {
122
return fileObject.getLastModified();
123
}
124
125
@Override
126
public boolean delete() {
127
return fileObject.delete();
128
}
129
}
130
131