org.erowid.sperowider
Class FileNameManager

java.lang.Object
  extended byorg.erowid.sperowider.FileNameManager

public class FileNameManager
extends Object

Maps URLs to file names.

Version:
$Header: /cvsroot/sperowider/SPEROWIDER_MODULE/javasource/org/erowid/sperowider/FileNameManager.java,v 1.14 2005/05/11 06:41:59 gurustu Exp $
Author:
Stu Statman

Constructor Summary
FileNameManager(String root)
          Creates a new FileNameManager, with the passed in String indicating the root of the download tree.
 
Method Summary
static URL fixURL(URL foundURL)
          Cleans up URLs
 String getFileNameForURL(URL realURL, String requiredPrefix, String requiredSuffix, String[] replaceableSuffixes)
          Returns a calculated filename for the passed in URL.
 String getFilenameRelativeToRoot(String filename)
          Returns the filename relative to the download root, as returned by getRoot().
 String getPathToArchiveRoot(String filename)
          Returns the path from the passed in filename to the download root, as returned by getRoot().
 String getPathToDocRoot(String filename)
          Returns a path to the document root for the passed in filename.
 String getRelativeFilename(String source, String destination)
          Gets a relative filename from the source file to the destination file.
 String getRoot()
          Returns the root of the download tree.
 String getSearchIndexRoot()
          Returns the directory that the search indexes will be created in.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileNameManager

public FileNameManager(String root)
Creates a new FileNameManager, with the passed in String indicating the root of the download tree.

Method Detail

fixURL

public static URL fixURL(URL foundURL)
                  throws MalformedURLException
Cleans up URLs

Throws:
MalformedURLException

getRoot

public String getRoot()
Returns the root of the download tree.


getSearchIndexRoot

public String getSearchIndexRoot()
Returns the directory that the search indexes will be created in.


getFilenameRelativeToRoot

public String getFilenameRelativeToRoot(String filename)
Returns the filename relative to the download root, as returned by getRoot().


getPathToArchiveRoot

public String getPathToArchiveRoot(String filename)
Returns the path from the passed in filename to the download root, as returned by getRoot().


getPathToDocRoot

public String getPathToDocRoot(String filename)
Returns a path to the document root for the passed in filename. Typically, this is two directories below the root as return by getRoot(). For example, if the download root is at /var/output, the docroot will be /var/output/http80/erowid (or something like that, based on what server and protocol is being used.)


getRelativeFilename

public String getRelativeFilename(String source,
                                  String destination)
Gets a relative filename from the source file to the destination file.


getFileNameForURL

public String getFileNameForURL(URL realURL,
                                String requiredPrefix,
                                String requiredSuffix,
                                String[] replaceableSuffixes)
Returns a calculated filename for the passed in URL. This file will be in the download structure, have a valid name for the filesystem, and will definitely start with the required prefix and end with the required suffix. This method does not always have to return the same filename for the same input parameters, which is why ISperowiderModel maintains a URL->filename mapping.


spero logo small Sperowider is
© 2005 Erowid.org