    001/*
    002 * Licensed to the Apache Software Foundation (ASF) under one or more
    003 * contributor license agreements.  See the NOTICE file distributed with
    004 * this work for additional information regarding copyright ownership.
    005 * The ASF licenses this file to You under the Apache License, Version 2.0
    006 * (the "License"); you may not use this file except in compliance with
    007 * the License.  You may obtain a copy of the License at
    008 *
    009 *     http://www.apache.org/licenses/LICENSE-2.0
    010 *
    011 * Unless required by applicable law or agreed to in writing, software
    012 * distributed under the License is distributed on an "AS IS" BASIS,
    013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    014 * See the License for the specific language governing permissions and
    015 * limitations under the License.
    016 */
    017package org.apache.commons.configuration2.builder;
    018
    019import java.io.File;
    020import java.net.URL;
    021
    022import org.apache.commons.configuration2.io.FileLocationStrategy;
    023import org.apache.commons.configuration2.io.FileSystem;
    024import org.apache.commons.configuration2.io.URLConnectionOptions;
    025
    026/**
    027 * <p>
    028 * Definition of a properties interface for parameters of file-based configurations.
    029 * </p>
    030 * <p>
    031 * This interface defines a set of properties which can be used to specify the location of a configuration source.
    032 * </p>
    033 *
    034 * @param <T> the type of the result of all set methods for method chaining
    035 */
    036public interface FileBasedBuilderProperties<T> {
    037    /**
    038     * Sets the base path of the associated {@code FileHandler}.
    039     *
    040     * @param path the base path
    041     * @return a reference to this object for method chaining
    042     */
    043    T setBasePath(String path);
    044
    045    /**
    046     * Sets the encoding of the associated {@code FileHandler}.
    047     *
    048     * @param enc the encoding
    049     * @return a reference to this object for method chaining
    050     */
    051    T setEncoding(String enc);
    052
    053    /**
    054     * Sets the location of the associated {@code FileHandler} as a {@code File} object.
    055     *
    056     * @param file the {@code File} location
    057     * @return a reference to this object for method chaining
    058     */
    059    T setFile(File file);
    060
    061    /**
    062     * Sets the file name of the associated {@code FileHandler}.
    063     *
    064     * @param name the file name
    065     * @return a reference to this object for method chaining
    066     */
    067    T setFileName(String name);
    068
    069    /**
    070     * Sets the {@code FileSystem} of the associated {@code FileHandler}.
    071     *
    072     * @param fs the {@code FileSystem}
    073     * @return a reference to this object for method chaining
    074     */
    075    T setFileSystem(FileSystem fs);
    076
    077    /**
    078     * Sets the {@code FileLocationStrategy} for resolving the referenced file.
    079     *
    080     * @param strategy the {@code FileLocationStrategy}
    081     * @return a reference to this object for method chaining
    082     */
    083    T setLocationStrategy(FileLocationStrategy strategy);
    084
    085    /**
    086     * Sets the location of the associated {@code FileHandler} as an absolute file path.
    087     *
    088     * @param path the path location
    089     * @return a reference to this object for method chaining
    090     */
    091    T setPath(String path);
    092
    093    /**
    094     * Sets the factory for creating {@code ReloadingDetector} objects. With this method a custom factory for reloading
    095     * detectors can be installed. Per default, a factory creating {@code FileHandlerReloadingDetector} objects is used.
    096     *
    097     * @param factory the {@code ReloadingDetectorFactory}
    098     * @return a reference to this object for method chaining
    099     */
    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}