Class ExternalResource
java.lang.Object
com.jackmeng.halcyoninae.halcyon.utils.ExternalResource
ResourceFolder is a general class that holds information about
the external resource folder.
The resource folder is named under the name "halcyon-mp4j".
- Since:
- 2.1
- Author:
- Jack Meng
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PropertiesManager
Represents the global instance of the PropertiesManager for the user-modifiable "halcyon.properties" file -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
Creates a cache file in the standard usr folder that is for this program.static void
checkResourceFolder
(String folderName) Based on provided folders it checks if these subfolders exists from within the main resource folder.static boolean
createFolder
(String name) Creates a folder in the standard external resource folder.static void
dispatchLog
(Exception... ex) Creates a log file with a varargs of exceptions to be logged.static File
getCacheFile
(String fileName) static String
getRandomString
(int length) An internal method used to retrieve a random string of letters based on the parameterized length.static String
writeBufferedImageCacheFile
(BufferedImage bi, String cacheFolder, String fileName) Writes a buffered-image to the resource folder.static void
This is a standard method to write a log file to the resource's log folder.
-
Field Details
-
pm
Represents the global instance of the PropertiesManager for the user-modifiable "halcyon.properties" fileThe program has one global instance to reduce overhead.
-
-
Constructor Details
-
ExternalResource
private ExternalResource()
-
-
Method Details
-
getRandomString
An internal method used to retrieve a random string of letters based on the parameterized length.- Parameters:
length
- The length of the random string- Returns:
- String The random string
-
checkResourceFolder
Based on provided folders it checks if these subfolders exists from within the main resource folder.If a folder does not exist, it will be created under the main resource folder.
3.0: Changed to have a parameter being taken
- Parameters:
folderName
- The folder to be checked
-
writeLog
This is a standard method to write a log file to the resource's log folder.This can be used for anything, however is not a place for things that are cached to be written to.
It will only write String based files to the files.
- Parameters:
folderName
- The name of the folder to write tof
- The file to write
-
writeBufferedImageCacheFile
public static String writeBufferedImageCacheFile(BufferedImage bi, String cacheFolder, String fileName) Writes a buffered-image to the resource folder.Planned: - Make it so that it will write to the "cache" folder of the main resource folder.
- Parameters:
bi
- The buffered image to write- Returns:
- String the absolute path of the image
-
createFolder
Creates a folder in the standard external resource folder.- Parameters:
name
- The name of the folder (can be a subdirectory)- Returns:
- File The folder that was created
-
cacheFile
Creates a cache file in the standard usr folder that is for this program.- Parameters:
fileName
- The file to be created, just file name.content
- The contents of the file as a varargs of Objects- Returns:
- (true | | false) depending on if the creation process was a success or not.
-
getCacheFile
- Parameters:
fileName
-- Returns:
- File
-
dispatchLog
Creates a log file with a varargs of exceptions to be logged. This is done asyncronously, however, the user may be alerted.- Parameters:
ex
- The exceptions to be logged
-