1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.configuration2.io;
18
19 import java.io.File;
20 import java.io.InputStream;
21 import java.io.OutputStream;
22 import java.net.MalformedURLException;
23 import java.net.URL;
24
25 import org.apache.commons.configuration2.ex.ConfigurationException;
26
27
28
29
30
31
32 public abstract class FileSystem {
33
34 private static final ConfigurationLogger DEFAULT_LOG = ConfigurationLogger.newDummyLogger();
35
36
37 private volatile ConfigurationLogger log;
38
39
40 private volatile FileOptionsProvider optionsProvider;
41
42 public abstract String getBasePath(String path);
43
44 public abstract String getFileName(String path);
45
46 public FileOptionsProvider getFileOptionsProvider() {
47 return this.optionsProvider;
48 }
49
50 public abstract InputStream getInputStream(URL url) throws ConfigurationException;
51
52
53
54
55
56
57
58
59
60
61
62 public InputStream getInputStream(final URL url, final URLConnectionOptions urlConnectionOptions) throws ConfigurationException {
63 return getInputStream(url);
64 }
65
66
67
68
69
70
71 public ConfigurationLogger getLogger() {
72 final ConfigurationLogger result = log;
73 return result != null ? result : DEFAULT_LOG;
74 }
75
76 public abstract OutputStream getOutputStream(File file) throws ConfigurationException;
77
78 public abstract OutputStream getOutputStream(URL url) throws ConfigurationException;
79
80 public abstract String getPath(File file, URL url, String basePath, String fileName);
81
82 public abstract URL getURL(String basePath, String fileName) throws MalformedURLException;
83
84 public abstract URL locateFromURL(String basePath, String fileName);
85
86
87
88
89
90
91 public void setFileOptionsProvider(final FileOptionsProvider provider) {
92 this.optionsProvider = provider;
93 }
94
95
96
97
98
99
100
101
102
103 public void setLogger(final ConfigurationLogger log) {
104 this.log = log;
105 }
106 }