public class

FileDispenser

extends Observable
java.lang.Object
   ↳ java.util.Observable
     ↳ com.microstrategy.utils.FileDispenser

Class Overview

FileDispenser is a utility that locates a user customizable file. If the file is unavailable in a specified path, it will be duplicated from a defined resource. The class also extends the java.util.Observable class to notify Observers when a new file path is dispensed.

Summary

Public Constructors
FileDispenser(String originalResourcePath)
This constructor takes in the location of the resource used to duplicate the dispensed files.
FileDispenser()
This constructor assumes that the original resource used to make the duplicates has the same file name as the one used in setOriginalResourcePath(String).
Public Methods
synchronized void dispense(String path)
If the specified file is not found, a duplicate is made from a master copy residing in the classpath.
synchronized String getDirectory()
Returns the canonical directory of the current file path.
synchronized String getFilePath()
Location of the file.
synchronized String getOriginalResourcePath()
Returns the location of the master copy.
synchronized void setOriginalResourcePath(String path)
Sets the path of the master copy.
[Expand]
Inherited Methods
From class java.util.Observable
From class java.lang.Object

Public Constructors

public FileDispenser (String originalResourcePath)

This constructor takes in the location of the resource used to duplicate the dispensed files.

Parameters
originalResourcePath Location of the master copy.
Throws
MissingResourceException Thrown if the resource could not be found.

public FileDispenser ()

This constructor assumes that the original resource used to make the duplicates has the same file name as the one used in setOriginalResourcePath(String).

Public Methods

public synchronized void dispense (String path)

If the specified file is not found, a duplicate is made from a master copy residing in the classpath. If no master copy is specified, the file name as given in the path is used for the master copy lookup. This method notifies its observers.

Parameters
path The path of the customizable/duplicated file.
Throws
IllegalArgumentException Thrown if path is empty.
IOException Thrown if a problem occurs duplicating the file.
MissingResourceException Thrown if the master copy could not be found during duplication.

public synchronized String getDirectory ()

Returns the canonical directory of the current file path. Returns null if the file path isn't defined.

Returns
  • The enclosing directory of the file.

public synchronized String getFilePath ()

Location of the file. This returns the path that was set verbatim, or null if undefined.

Returns
  • The file path.

public synchronized String getOriginalResourcePath ()

Returns the location of the master copy. This will return null if not previously set.

Returns
  • Location of the master copy.

public synchronized void setOriginalResourcePath (String path)

Sets the path of the master copy.

Parameters
path Location of the master copy.
Throws
MissingResourceException Thrown if the resource cannot be found.