/**
  * Creates a copy of this configuration. The new configuration object will contain the same
  * properties as the original, but it will lose any connection to a source file (if one exists);
  * this includes setting the source URL, base path, and file name to <b>null</b>. This is done to
  * avoid race conditions if both the original and the copy are modified and then saved.
  *
  * @return the copy
  * @since 1.3
  */
 public Object clone() {
   AbstractFileConfiguration copy = (AbstractFileConfiguration) super.clone();
   copy.setBasePath(null);
   copy.setFileName(null);
   copy.initReloadingStrategy();
   return copy;
 }
  /**
   * Load the configuration from the specified URL. This does not change the source of the
   * configuration (i.e. the internally maintained file name). Use on of the setter methods for this
   * purpose.
   *
   * @param url the URL of the file to be loaded
   * @throws ConfigurationException if an error occurs
   */
  public void load(URL url) throws ConfigurationException {
    if (sourceURL == null) {
      if (StringUtils.isEmpty(getBasePath())) {
        // ensure that we have a valid base path
        setBasePath(url.toString());
      }
      sourceURL = url;
    }

    // throw an exception if the target URL is a directory
    File file = ConfigurationUtils.fileFromURL(url);
    if (file != null && file.isDirectory()) {
      throw new ConfigurationException("Cannot load a configuration from a directory");
    }

    InputStream in = null;

    try {
      in = url.openStream();
      load(in);
    } catch (ConfigurationException e) {
      throw e;
    } catch (Exception e) {
      throw new ConfigurationException("Unable to load the configuration from the URL " + url, e);
    } finally {
      // close the input stream
      try {
        if (in != null) {
          in.close();
        }
      } catch (IOException e) {
        getLogger().warn("Could not close input stream", e);
      }
    }
  }
 /**
  * Set the location of this configuration as a URL. For loading this can be an arbitrary URL with
  * a supported protocol. If the configuration is to be saved, too, a URL with the &quot;file&quot;
  * protocol should be provided.
  *
  * @param url the location of this configuration as URL
  */
 public void setURL(URL url) {
   setBasePath(ConfigurationUtils.getBasePath(url));
   setFileName(ConfigurationUtils.getFileName(url));
   sourceURL = url;
 }
 /**
  * Set the file where the configuration is stored. The passed in file is made absolute if it is
  * not yet. Then the file's path component becomes the base path and its name component becomes
  * the file name.
  *
  * @param file the file where the configuration is stored
  */
 public void setFile(File file) {
   sourceURL = null;
   setFileName(file.getName());
   setBasePath((file.getParentFile() != null) ? file.getParentFile().getAbsolutePath() : null);
 }