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 * http://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 * Sets the base path of the associated {@code FileHandler}. 39 * 40 * @param path the base path 41 * @return a reference to this object for method chaining 42 */ 43 T setBasePath(String path); 44 45 /** 46 * Sets the encoding of the associated {@code FileHandler}. 47 * 48 * @param enc the encoding 49 * @return a reference to this object for method chaining 50 */ 51 T setEncoding(String enc); 52 53 /** 54 * Sets the location of the associated {@code FileHandler} as a {@code File} object. 55 * 56 * @param file the {@code File} location 57 * @return a reference to this object for method chaining 58 */ 59 T setFile(File file); 60 61 /** 62 * Sets the file name of the associated {@code FileHandler}. 63 * 64 * @param name the file name 65 * @return a reference to this object for method chaining 66 */ 67 T setFileName(String name); 68 69 /** 70 * Sets the {@code FileSystem} of the associated {@code FileHandler}. 71 * 72 * @param fs the {@code FileSystem} 73 * @return a reference to this object for method chaining 74 */ 75 T setFileSystem(FileSystem fs); 76 77 /** 78 * Sets the {@code FileLocationStrategy} for resolving the referenced file. 79 * 80 * @param strategy the {@code FileLocationStrategy} 81 * @return a reference to this object for method chaining 82 */ 83 T setLocationStrategy(FileLocationStrategy strategy); 84 85 /** 86 * Sets the location of the associated {@code FileHandler} as an absolute file path. 87 * 88 * @param path the path location 89 * @return a reference to this object for method chaining 90 */ 91 T setPath(String path); 92 93 /** 94 * Sets the factory for creating {@code ReloadingDetector} objects. With this method a custom factory for reloading 95 * detectors can be installed. Per default, a factory creating {@code FileHandlerReloadingDetector} objects is used. 96 * 97 * @param factory the {@code ReloadingDetectorFactory} 98 * @return a reference to this object for method chaining 99 */ 100 T setReloadingDetectorFactory(ReloadingDetectorFactory factory); 101 102 /** 103 * Sets the refresh delay for reloading support 104 * 105 * @param reloadingRefreshDelay the refresh delay (in milliseconds) 106 * @return a reference to this object for method chaining 107 */ 108 T setReloadingRefreshDelay(Long reloadingRefreshDelay); 109 110 /** 111 * Sets the location of the associated {@code FileHandler} as a {@code URL} object. 112 * 113 * @param url the {@code URL} location 114 * @return a reference to this object for method chaining 115 */ 116 T setURL(URL url); 117 118 /** 119 * Sets the location of the associated {@code FileHandler} as a {@code URL} object. 120 * 121 * @param url the {@code URL} location 122 * @param urlConnectionOptions options 123 * @return a reference to this object for method chaining 124 * @since 2.8.0 125 */ 126 default T setURL(final URL url, final URLConnectionOptions urlConnectionOptions) { 127 return setURL(url); 128 } 129 }