Class BasePathLocationStrategy

All Implemented Interfaces:

public class BasePathLocationStrategy extends Object implements FileLocationStrategy

A specialized implementation of FileLocationStrategy which tries to construct a file path from the locator's base path and file name.

This strategies ignores the URL stored in the passed in FileLocator. It generates a path by concatenating the base path (if present) and the file name. If the resulting path points to a valid file, the corresponding URL is returned.

  • Constructor Details

  • Method Details

    • 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 uses utility methods from FileLocatorUtils to generate a File from the locator's base path and file name. If this File exists, its URL is returned.
      Specified by:
      locate in interface FileLocationStrategy
      fileSystem - the FileSystem to be used for this operation
      locator - the object describing the file to be located
      a URL pointing to the referenced file if location was successful; null if the file could not be resolved