Class JarResourceModule
java.lang.Object
com.juliewoolie.delphi.resource.JarResourceModule
- All Implemented Interfaces:
IoModule,ResourceModule
-
Constructor Summary
ConstructorsConstructorDescriptionJarResourceModule(ClassLoader loader, String directory) Constructs a new jar resource module. -
Method Summary
Modifier and TypeMethodDescription@NotNull Collection<String> getModulePaths(@NotNull ResourcePath pathSoFar) Gets a collection of files/documents contained in this module.@NotNull StringBufferloadString(@NotNull ResourcePath path) Load a string buffer from the file pointed to by the specified path.voidsetCharset(@NotNull Charset charset) Sets the charset used to read resource files.voidsetFilePaths(@Nullable List<String> filePaths) Sets the file paths returned bygetModulePaths(ResourcePath).
-
Constructor Details
-
JarResourceModule
Constructs a new jar resource module.- Parameters:
loader- The class loader used for accessing resourcesdirectory- The path of the directory in the jar's resources to load from. Leave blank to use the jar's root directory.
-
-
Method Details
-
getLoader
-
getDirectory
-
setCharset
Sets the charset used to read resource files.- Parameters:
charset- Charset- Throws:
NullPointerException- Ifcharsetisnull
-
getCharset
-
getFilePaths
-
setFilePaths
Sets the file paths returned bygetModulePaths(ResourcePath).Since it's difficult to reliably get a list of files in a java class path (or plugin class path), this method sets the list of files
getModulePaths(ResourcePath)will filter through.- Parameters:
filePaths- File path list.
-
loadString
@NotNull public @NotNull StringBuffer loadString(@NotNull @NotNull ResourcePath path) throws IOException Description copied from interface:IoModuleLoad a string buffer from the file pointed to by the specified path.- Specified by:
loadStringin interfaceIoModule- Parameters:
path- File path- Returns:
- The read file contents
- Throws:
IOException- If an IO exception ocurred while reading the file
-
getModulePaths
@NotNull public @NotNull Collection<String> getModulePaths(@NotNull @NotNull ResourcePath pathSoFar) Description copied from interface:ResourceModuleGets a collection of files/documents contained in this module.The resulting file paths are used mainly for suggestions in the
/delphi open <player> <path>command.Assuming we have the following files in the module:
The following inputs should yield these results:index.xml item-data.json global-style.scss admin-tab/index.xml admin-tab/head-item.json admin-tab/confirm/dialogue.xml admin-tab/confirm/style.scss spectator-tab/index.xmlInput Expected result Empty input Returns the entire file list admin-tab/index.xml,head-item.json,confirm/dialogue.xml,confirm/style.scssadmin-tab/confirm/dialogue.xml,style.scssspectator-tab/index.xml- Specified by:
getModulePathsin interfaceResourceModule- Parameters:
pathSoFar- The current page path.- Returns:
- A list of files contained in the directory specified by
pathSoFar.
-