/
IOService.java
342 lines (275 loc) · 14.3 KB
/
IOService.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
/*
* Copyright 2015 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.uberfire.io;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
import java.nio.charset.Charset;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.uberfire.commons.lifecycle.PriorityDisposable;
import org.uberfire.java.nio.IOException;
import org.uberfire.java.nio.channels.SeekableByteChannel;
import org.uberfire.java.nio.file.AtomicMoveNotSupportedException;
import org.uberfire.java.nio.file.CopyOption;
import org.uberfire.java.nio.file.DeleteOption;
import org.uberfire.java.nio.file.DirectoryNotEmptyException;
import org.uberfire.java.nio.file.DirectoryStream;
import org.uberfire.java.nio.file.FileAlreadyExistsException;
import org.uberfire.java.nio.file.FileSystem;
import org.uberfire.java.nio.file.FileSystemAlreadyExistsException;
import org.uberfire.java.nio.file.FileSystemMetadata;
import org.uberfire.java.nio.file.FileSystemNotFoundException;
import org.uberfire.java.nio.file.NoSuchFileException;
import org.uberfire.java.nio.file.NotDirectoryException;
import org.uberfire.java.nio.file.OpenOption;
import org.uberfire.java.nio.file.Option;
import org.uberfire.java.nio.file.Path;
import org.uberfire.java.nio.file.ProviderNotFoundException;
import org.uberfire.java.nio.file.attribute.FileAttribute;
import org.uberfire.java.nio.file.attribute.FileAttributeView;
import org.uberfire.java.nio.file.attribute.FileTime;
/**
*
*/
public interface IOService extends PriorityDisposable {
public static Set<OpenOption> EMPTY_OPTIONS = new HashSet<OpenOption>();
void startBatch(final FileSystem fs);
void startBatch(final FileSystem fs,
final Option... options);
void endBatch();
FileAttribute<?>[] convert(final Map<String, ?> attrs);
Path get(final String first,
final String... more)
throws IllegalArgumentException;
Path get(final URI uri)
throws IllegalArgumentException, FileSystemNotFoundException, SecurityException;
Iterable<FileSystemMetadata> getFileSystemMetadata();
FileSystem getFileSystem(final URI uri)
throws IllegalArgumentException, FileSystemNotFoundException,
ProviderNotFoundException, SecurityException;
FileSystem newFileSystem(final URI uri,
final Map<String, ?> env)
throws IllegalArgumentException, FileSystemAlreadyExistsException,
ProviderNotFoundException, IOException, SecurityException;
void onNewFileSystem(final NewFileSystemListener listener);
InputStream newInputStream(final Path path,
final OpenOption... options)
throws IllegalArgumentException, NoSuchFileException,
UnsupportedOperationException, IOException, SecurityException;
OutputStream newOutputStream(final Path path,
final OpenOption... options)
throws IllegalArgumentException, UnsupportedOperationException,
IOException, SecurityException;
SeekableByteChannel newByteChannel(final Path path,
final OpenOption... options)
throws IllegalArgumentException, UnsupportedOperationException, FileAlreadyExistsException,
IOException, SecurityException;
SeekableByteChannel newByteChannel(final Path path,
final Set<? extends OpenOption> options,
final FileAttribute<?>... attrs)
throws IllegalArgumentException, UnsupportedOperationException, FileAlreadyExistsException,
IOException, SecurityException;
DirectoryStream<Path> newDirectoryStream(final Path dir)
throws IllegalArgumentException, NotDirectoryException, IOException, SecurityException;
DirectoryStream<Path> newDirectoryStream(final Path dir,
final DirectoryStream.Filter<Path> filter)
throws IllegalArgumentException, NotDirectoryException, IOException, SecurityException;
Path createFile(final Path path,
final FileAttribute<?>... attrs)
throws IllegalArgumentException, UnsupportedOperationException,
FileAlreadyExistsException, IOException, SecurityException;
Path createDirectory(final Path dir,
final FileAttribute<?>... attrs)
throws IllegalArgumentException, UnsupportedOperationException,
FileAlreadyExistsException, IOException, SecurityException;
Path createDirectories(final Path dir,
final FileAttribute<?>... attrs)
throws UnsupportedOperationException, FileAlreadyExistsException,
IOException, SecurityException;
Path createDirectory(final Path dir,
final Map<String, ?> attrs)
throws IllegalArgumentException, UnsupportedOperationException,
FileAlreadyExistsException, IOException, SecurityException;
Path createDirectories(final Path dir,
final Map<String, ?> attrs)
throws UnsupportedOperationException, FileAlreadyExistsException,
IOException, SecurityException;
void delete(final Path path,
final DeleteOption... options)
throws IllegalArgumentException, NoSuchFileException,
DirectoryNotEmptyException, IOException, SecurityException;
boolean deleteIfExists(final Path path,
final DeleteOption... options)
throws IllegalArgumentException, DirectoryNotEmptyException,
IOException, SecurityException;
Path createTempFile(final String prefix,
final String suffix,
final FileAttribute<?>... attrs)
throws IllegalArgumentException, UnsupportedOperationException,
IOException, SecurityException;
Path createTempFile(final Path dir,
final String prefix,
final String suffix,
final FileAttribute<?>... attrs)
throws IllegalArgumentException, UnsupportedOperationException,
IOException, SecurityException;
Path createTempDirectory(final String prefix,
final FileAttribute<?>... attrs)
throws IllegalArgumentException, UnsupportedOperationException,
IOException, SecurityException;
Path createTempDirectory(final Path dir,
final String prefix,
final FileAttribute<?>... attrs)
throws IllegalArgumentException, UnsupportedOperationException,
IOException, SecurityException;
Path copy(final Path source,
final Path target,
final CopyOption... options)
throws UnsupportedOperationException, FileAlreadyExistsException,
DirectoryNotEmptyException, IOException, SecurityException;
Path move(final Path source,
final Path target,
final CopyOption... options)
throws UnsupportedOperationException, FileAlreadyExistsException,
DirectoryNotEmptyException, AtomicMoveNotSupportedException,
IOException, SecurityException;
<V extends FileAttributeView> V getFileAttributeView(final Path path,
final Class<V> type)
throws IllegalArgumentException;
Map<String, Object> readAttributes(final Path path)
throws UnsupportedOperationException, NoSuchFileException,
IllegalArgumentException, IOException, SecurityException;
Map<String, Object> readAttributes(final Path path,
final String attributes)
throws UnsupportedOperationException, NoSuchFileException,
IllegalArgumentException, IOException, SecurityException;
Path setAttributes(final Path path,
final FileAttribute<?>... attrs)
throws UnsupportedOperationException, IllegalArgumentException,
ClassCastException, IOException, SecurityException;
Path setAttributes(final Path path,
final Map<String, Object> attrs)
throws UnsupportedOperationException, IllegalArgumentException,
ClassCastException, IOException, SecurityException;
Path setAttribute(final Path path,
final String attribute,
final Object value)
throws UnsupportedOperationException, IllegalArgumentException,
ClassCastException, IOException, SecurityException;
Object getAttribute(final Path path,
final String attribute)
throws UnsupportedOperationException, IllegalArgumentException,
IOException, SecurityException;
FileTime getLastModifiedTime(final Path path)
throws IllegalArgumentException, IOException, SecurityException;
long size(final Path path)
throws IllegalArgumentException, IOException, SecurityException;
boolean exists(final Path path)
throws IllegalArgumentException, SecurityException;
boolean notExists(final Path path)
throws IllegalArgumentException, SecurityException;
boolean isSameFile(final Path path,
final Path path2)
throws IllegalArgumentException, IOException, SecurityException;
BufferedReader newBufferedReader(final Path path,
final Charset cs)
throws IllegalArgumentException, NoSuchFileException, IOException, SecurityException;
BufferedWriter newBufferedWriter(final Path path,
final Charset cs,
final OpenOption... options)
throws IllegalArgumentException, IOException, UnsupportedOperationException, SecurityException;
long copy(final InputStream in,
final Path target,
final CopyOption... options)
throws IOException, FileAlreadyExistsException, DirectoryNotEmptyException,
UnsupportedOperationException, SecurityException;
long copy(final Path source,
final OutputStream out)
throws IOException, SecurityException;
byte[] readAllBytes(final Path path)
throws IOException, OutOfMemoryError, SecurityException;
List<String> readAllLines(final Path path)
throws IllegalArgumentException, NoSuchFileException, IOException, SecurityException;
List<String> readAllLines(final Path path,
final Charset cs)
throws IllegalArgumentException, NoSuchFileException, IOException, SecurityException;
String readAllString(final Path path,
final Charset cs)
throws IllegalArgumentException, NoSuchFileException, IOException;
String readAllString(final Path path)
throws IllegalArgumentException, NoSuchFileException, IOException;
Path write(final Path path,
final byte[] bytes,
final OpenOption... options)
throws IOException, UnsupportedOperationException, SecurityException;
Path write(final Path path,
final byte[] bytes,
final Map<String, ?> attrs,
final OpenOption... options)
throws IOException, UnsupportedOperationException, SecurityException;
Path write(final Path path,
final byte[] bytes,
final Set<? extends OpenOption> options,
final FileAttribute<?>... attrs)
throws IllegalArgumentException, IOException, UnsupportedOperationException;
Path write(final Path path,
final Iterable<? extends CharSequence> lines,
final Charset cs,
final OpenOption... options)
throws IllegalArgumentException, IOException, UnsupportedOperationException, SecurityException;
Path write(final Path path,
final String content,
final OpenOption... options)
throws IllegalArgumentException, IOException, UnsupportedOperationException;
Path write(final Path path,
final String content,
final Charset cs,
final OpenOption... options)
throws IllegalArgumentException, IOException, UnsupportedOperationException;
Path write(final Path path,
final String content,
final Set<? extends OpenOption> options,
final FileAttribute<?>... attrs)
throws IllegalArgumentException, IOException, UnsupportedOperationException;
Path write(final Path path,
final String content,
final Charset cs,
final Set<? extends OpenOption> options,
final FileAttribute<?>... attrs)
throws IllegalArgumentException, IOException, UnsupportedOperationException;
Path write(final Path path,
final String content,
final Map<String, ?> attrs,
final OpenOption... options)
throws IllegalArgumentException, IOException, UnsupportedOperationException;
Path write(final Path path,
final String content,
final Charset cs,
final Map<String, ?> attrs,
final OpenOption... options)
throws IllegalArgumentException, IOException, UnsupportedOperationException;
public abstract static class NewFileSystemListener {
public abstract void execute(final FileSystem newFileSystem,
final String scheme,
final String name,
final Map<String, ?> env);
}
}