Interface ResourceManager

All Known Implementing Classes:
DefaultResourceManager

public interface ResourceManager
Version:
$Id$
Author:
Trygve Laugstøl, Jason van Zyl
  • Method Details

    • getResourceAsInputStream

      InputStream getResourceAsInputStream(String name) throws ResourceNotFoundException
      Retrieves a resource as an InputStream using the specified resource name.
      Parameters:
      name - the name of the resource to retrieve
      Returns:
      an InputStream representing the resource's contents
      Throws:
      ResourceNotFoundException - if the resource cannot be found
    • getResourceAsFile

      Retrieves a resource as a File using the specified resource name.
      Parameters:
      name - the name of the resource to retrieve
      Returns:
      a File object representing the resource's contents
      Throws:
      ResourceNotFoundException - if the resource cannot be found
      FileResourceCreationException - if there is an error creating the File
    • getResourceAsFile

      File getResourceAsFile(String name, String outputFile) throws ResourceNotFoundException, FileResourceCreationException
      Retrieves a resource as a File and saves it with the specified output filename.
      Parameters:
      name - the name of the resource to retrieve
      outputFile - the name to save the resource as
      Returns:
      a File object representing the resource's contents
      Throws:
      ResourceNotFoundException - if the resource cannot be found
      FileResourceCreationException - if there is an error creating the File
    • setOutputDirectory

      void setOutputDirectory(File outputDirectory)
      Sets the output directory where resources will be stored.
      Parameters:
      outputDirectory - the directory to set as the output location for resources
    • addSearchPath

      void addSearchPath(String resourceLoaderId, String searchPath)
      Adds a search path for the resource loader with the specified ID.
      Parameters:
      resourceLoaderId - the ID of the resource loader
      searchPath - the path to add to the resource loader's search paths
    • getResource

      Searches for a resource with the given name and returns a corresponding LuteceResource object.
      Parameters:
      name - the name of the resource to search for
      Returns:
      the LuteceResource found with the specified name
      Throws:
      ResourceNotFoundException - if the resource cannot be found
    • getResourceAsFile

      File getResourceAsFile(LuteceResource resource) throws FileResourceCreationException
      Retrieves a file with the given resource's contents. If the resource is already available as a file, returns that file. Otherwise, a file in the resource manager's output directory is created, and the resource is downloaded to that file.
      Parameters:
      resource - the LuteceResource to retrieve as a file
      Returns:
      a File object representing the resource's contents
      Throws:
      FileResourceCreationException - if there is an error creating the File
    • createResourceAsFile

      void createResourceAsFile(LuteceResource resource, File outputFile) throws FileResourceCreationException
      Downloads the specified resource to the given output file.
      Parameters:
      resource - the LuteceResource to download
      outputFile - the File to which the resource will be downloaded
      Throws:
      FileResourceCreationException - if there is an error creating the File
    • getResourceURL

      Set<URL> getResourceURL(String path) throws ResourceNotFoundException
      Retrieves the resource paths as a Set from a given directory. This method reads the files in the specified directory, converts their paths to URLs, and returns them in a Set. If no resources are found, a ResourceNotFoundException will be thrown.
      Parameters:
      path - The base path in the file system, which can be either relative or absolute. This path is used to locate the directory containing the resources. The path must start with a "/".
      Returns:
      A Set containing the URLs of the resources found in the directory.
      Throws:
      ResourceNotFoundException - If no resources are found or if an error occurs while reading the directory or converting paths to URLs.