Package com.microstrategy.utils
Class FileDispenser
- java.lang.Object
-
- java.util.Observable
-
- com.microstrategy.utils.FileDispenser
-
public class FileDispenser extends java.util.Observable
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.- Since:
- MicroStrategy Web 7.3.1 or earlier
-
-
Constructor Summary
Constructors Constructor Description FileDispenser()
This constructor assumes that the original resource used to make the duplicates has the same file name as the one used insetOriginalResourcePath(String)
.FileDispenser(java.lang.String originalResourcePath)
This constructor takes in the location of the resource used to duplicate the dispensed files.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dispense(java.lang.String path)
If the specified file is not found, a duplicate is made from a master copy residing in the classpath.java.lang.String
getDirectory()
Returns the canonical directory of the current file path.java.lang.String
getFilePath()
Location of the file.java.lang.String
getOriginalResourcePath()
Returns the location of the master copy.void
setOriginalResourcePath(java.lang.String path)
Sets the path of the master copy.
-
-
-
Constructor Detail
-
FileDispenser
public FileDispenser(java.lang.String originalResourcePath) throws java.util.MissingResourceException
This constructor takes in the location of the resource used to duplicate the dispensed files.- Parameters:
originalResourcePath
- Location of the master copy.- Throws:
java.util.MissingResourceException
- Thrown if the resource could not be found.
-
FileDispenser
public FileDispenser()
This constructor assumes that the original resource used to make the duplicates has the same file name as the one used insetOriginalResourcePath(String)
.
-
-
Method Detail
-
setOriginalResourcePath
public void setOriginalResourcePath(java.lang.String path) throws java.util.MissingResourceException
Sets the path of the master copy.- Parameters:
path
- Location of the master copy.- Throws:
java.util.MissingResourceException
- Thrown if the resource cannot be found.
-
getOriginalResourcePath
public java.lang.String getOriginalResourcePath()
Returns the location of the master copy. This will return null if not previously set.- Returns:
- Location of the master copy.
-
getFilePath
public java.lang.String getFilePath()
Location of the file. This returns the path that was set verbatim, or null if undefined.- Returns:
- The file path.
-
getDirectory
public java.lang.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.
-
dispense
public void dispense(java.lang.String path) throws java.lang.IllegalArgumentException, java.util.MissingResourceException, java.io.IOException
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:
java.lang.IllegalArgumentException
- Thrown if path is empty.java.io.IOException
- Thrown if a problem occurs duplicating the file.java.util.MissingResourceException
- Thrown if the master copy could not be found during duplication.
-
-