FileBasedBuilderProperties.java

  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. import java.io.File;
  19. import java.net.URL;

  20. import org.apache.commons.configuration2.io.FileLocationStrategy;
  21. import org.apache.commons.configuration2.io.FileSystem;
  22. import org.apache.commons.configuration2.io.URLConnectionOptions;

  23. /**
  24.  * <p>
  25.  * Definition of a properties interface for parameters of file-based configurations.
  26.  * </p>
  27.  * <p>
  28.  * This interface defines a set of properties which can be used to specify the location of a configuration source.
  29.  * </p>
  30.  *
  31.  * @param <T> the type of the result of all set methods for method chaining
  32.  */
  33. public interface FileBasedBuilderProperties<T> {
  34.     /**
  35.      * Sets the base path of the associated {@code FileHandler}.
  36.      *
  37.      * @param path the base path
  38.      * @return a reference to this object for method chaining
  39.      */
  40.     T setBasePath(String path);

  41.     /**
  42.      * Sets the encoding of the associated {@code FileHandler}.
  43.      *
  44.      * @param enc the encoding
  45.      * @return a reference to this object for method chaining
  46.      */
  47.     T setEncoding(String enc);

  48.     /**
  49.      * Sets the location of the associated {@code FileHandler} as a {@code File} object.
  50.      *
  51.      * @param file the {@code File} location
  52.      * @return a reference to this object for method chaining
  53.      */
  54.     T setFile(File file);

  55.     /**
  56.      * Sets the file name of the associated {@code FileHandler}.
  57.      *
  58.      * @param name the file name
  59.      * @return a reference to this object for method chaining
  60.      */
  61.     T setFileName(String name);

  62.     /**
  63.      * Sets the {@code FileSystem} of the associated {@code FileHandler}.
  64.      *
  65.      * @param fs the {@code FileSystem}
  66.      * @return a reference to this object for method chaining
  67.      */
  68.     T setFileSystem(FileSystem fs);

  69.     /**
  70.      * Sets the {@code FileLocationStrategy} for resolving the referenced file.
  71.      *
  72.      * @param strategy the {@code FileLocationStrategy}
  73.      * @return a reference to this object for method chaining
  74.      */
  75.     T setLocationStrategy(FileLocationStrategy strategy);

  76.     /**
  77.      * Sets the location of the associated {@code FileHandler} as an absolute file path.
  78.      *
  79.      * @param path the path location
  80.      * @return a reference to this object for method chaining
  81.      */
  82.     T setPath(String path);

  83.     /**
  84.      * Sets the factory for creating {@code ReloadingDetector} objects. With this method a custom factory for reloading
  85.      * detectors can be installed. Per default, a factory creating {@code FileHandlerReloadingDetector} objects is used.
  86.      *
  87.      * @param factory the {@code ReloadingDetectorFactory}
  88.      * @return a reference to this object for method chaining
  89.      */
  90.     T setReloadingDetectorFactory(ReloadingDetectorFactory factory);

  91.     /**
  92.      * Sets the refresh delay for reloading support
  93.      *
  94.      * @param reloadingRefreshDelay the refresh delay (in milliseconds)
  95.      * @return a reference to this object for method chaining
  96.      */
  97.     T setReloadingRefreshDelay(Long reloadingRefreshDelay);

  98.     /**
  99.      * Sets the location of the associated {@code FileHandler} as a {@code URL} object.
  100.      *
  101.      * @param url the {@code URL} location
  102.      * @return a reference to this object for method chaining
  103.      */
  104.     T setURL(URL url);

  105.     /**
  106.      * Sets the location of the associated {@code FileHandler} as a {@code URL} object.
  107.      *
  108.      * @param url the {@code URL} location
  109.      * @param urlConnectionOptions options
  110.      * @return a reference to this object for method chaining
  111.      * @since 2.8.0
  112.      */
  113.     default T setURL(final URL url, final URLConnectionOptions urlConnectionOptions) {
  114.         return setURL(url);
  115.     }
  116. }