1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package org.apache.commons.configuration2.builder;
18
19 import java.io.File;
20 import java.net.URL;
21
22 import org.apache.commons.configuration2.io.FileLocationStrategy;
23 import org.apache.commons.configuration2.io.FileSystem;
24 import org.apache.commons.configuration2.io.URLConnectionOptions;
25
26 /**
27 * <p>
28 * Definition of a properties interface for parameters of file-based configurations.
29 * </p>
30 * <p>
31 * This interface defines a set of properties which can be used to specify the location of a configuration source.
32 * </p>
33 *
34 * @param <T> the type of the result of all set methods for method chaining
35 */
36 public interface FileBasedBuilderProperties<T> {
37
38 /**
39 * Sets the base path of the associated {@code FileHandler}.
40 *
41 * @param path the base path
42 * @return a reference to this object for method chaining
43 */
44 T setBasePath(String path);
45
46 /**
47 * Sets the encoding of the associated {@code FileHandler}.
48 *
49 * @param enc the encoding
50 * @return a reference to this object for method chaining
51 */
52 T setEncoding(String enc);
53
54 /**
55 * Sets the location of the associated {@code FileHandler} as a {@code File} object.
56 *
57 * @param file the {@code File} location
58 * @return a reference to this object for method chaining
59 */
60 T setFile(File file);
61
62 /**
63 * Sets the file name of the associated {@code FileHandler}.
64 *
65 * @param name the file name
66 * @return a reference to this object for method chaining
67 */
68 T setFileName(String name);
69
70 /**
71 * Sets the {@code FileSystem} of the associated {@code FileHandler}.
72 *
73 * @param fs the {@code FileSystem}
74 * @return a reference to this object for method chaining
75 */
76 T setFileSystem(FileSystem fs);
77
78 /**
79 * Sets the {@code FileLocationStrategy} for resolving the referenced file.
80 *
81 * @param strategy the {@code FileLocationStrategy}
82 * @return a reference to this object for method chaining
83 */
84 T setLocationStrategy(FileLocationStrategy strategy);
85
86 /**
87 * Sets the location of the associated {@code FileHandler} as an absolute file path.
88 *
89 * @param path the path location
90 * @return a reference to this object for method chaining
91 */
92 T setPath(String path);
93
94 /**
95 * Sets the factory for creating {@code ReloadingDetector} objects. With this method a custom factory for reloading
96 * detectors can be installed. Per default, a factory creating {@code FileHandlerReloadingDetector} objects is used.
97 *
98 * @param factory the {@code ReloadingDetectorFactory}
99 * @return a reference to this object for method chaining
100 */
101 T setReloadingDetectorFactory(ReloadingDetectorFactory factory);
102
103 /**
104 * Sets the refresh delay for reloading support
105 *
106 * @param reloadingRefreshDelay the refresh delay (in milliseconds)
107 * @return a reference to this object for method chaining
108 */
109 T setReloadingRefreshDelay(Long reloadingRefreshDelay);
110
111 /**
112 * Sets the location of the associated {@code FileHandler} as a {@code URL} object.
113 *
114 * @param url the {@code URL} location
115 * @return a reference to this object for method chaining
116 */
117 T setURL(URL url);
118
119 /**
120 * Sets the location of the associated {@code FileHandler} as a {@code URL} object.
121 *
122 * @param url the {@code URL} location
123 * @param urlConnectionOptions options
124 * @return a reference to this object for method chaining
125 * @since 2.8.0
126 */
127 default T setURL(final URL url, final URLConnectionOptions urlConnectionOptions) {
128 return setURL(url);
129 }
130 }