org.apache.commons.configuration2.io

## Class ProvidedURLLocationStrategy

- java.lang.Object
- - org.apache.commons.configuration2.io.ProvidedURLLocationStrategy

- All Implemented Interfaces:
    FileLocationStrategy

      public class ProvidedURLLocationStrategy
      extends Object
      implements FileLocationStrategy

  A specialized implementation of `FileLocationStrategy` which checks whether a passed in `FileLocator` already has a defined URL.

  `FileLocator` objects that have a URL already reference a file in an unambiguous way. Therefore, this strategy just returns the URL of the passed in `FileLocator`. It can be used as a first step of the file resolving process. If it fails, more sophisticated attempts for resolving the file can be made.

  Since:
    2.0
  Version:
    $Id: ProvidedURLLocationStrategy.java 1624601 2014-09-12 18:04:36Z oheger $

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ProvidedURLLocationStrategy()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `URL` | `locate(FileSystem fileSystem, FileLocator locator)` Tries to locate the specified file.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ProvidedURLLocationStrategy

          public ProvidedURLLocationStrategy()

  - ### Method Detail

    - #### locate

          public URL locate(FileSystem fileSystem,
                            FileLocator locator)

      Tries to locate the specified file. The method also expects the `FileSystem` to be used. Note that the `FileLocator` object may also contain a `FileSystem`, but this is optional. The passed in `FileSystem` should be used, and callers must not pass a null reference for this argument. A concrete implementation has to evaluate the properties stored in the `FileLocator` object and try to match them to an existing file. If this can be done, a corresponding URL is returned. Otherwise, result is null. Implementations should not throw an exception (unless parameters are null) as there might be alternative strategies which can find the file in question. This implementation just returns the URL stored in the given `FileLocator`.
      Specified by:
        `locate` in interface `FileLocationStrategy`
      Parameters:
        `fileSystem` - the `FileSystem` to be used for this operation
        `locator` - the object describing the file to be located
      Returns:
        a URL pointing to the referenced file if location was successful; null if the file could not be resolved

Copyright © 2001–2015 The Apache Software Foundation. All rights reserved.