Package rife.resources
Class DirectoryResources
java.lang.Object
rife.resources.AbstractResourceFinder
rife.resources.ResourceFinderDirectories
rife.resources.DirectoryResources
- All Implemented Interfaces:
ResourceFinder,ResourceWriter
This class offers
ResourceFinder and ResourceWriter
capabilities for resources that are stored as files in a directory on
the file system.
Resource names are relative paths inside the directory, where a
/ separator maps to a sub-directory. The directory is created
when it doesn't exist yet and the content is stored as UTF-8.
- Since:
- 1.10
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDirectoryResources(File directory) Creates a new instance for the provided directory. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddResource(String name, String content) Adds a resource with the provided name and content.booleanremoveResource(String name) Removes the resource with the provided name.booleanupdateResource(String name, String content) Updates the content of the resource with the provided name.Methods inherited from class rife.resources.ResourceFinderDirectories
getContent, getModificationTime, getResource, useStreamMethods inherited from class rife.resources.AbstractResourceFinder
getContent, getContent, getContent, getModificationTime, useStream
-
Constructor Details
-
DirectoryResources
Creates a new instance for the provided directory.The directory will be created when it doesn't exist yet.
- Parameters:
directory- the directory that the resources are stored in- Since:
- 1.10
-
-
Method Details
-
addResource
Description copied from interface:ResourceWriterAdds a resource with the provided name and content.- Specified by:
addResourcein interfaceResourceWriter- Parameters:
name- the name of the resourcecontent- the content of the resource- Throws:
ResourceWriterErrorException- if an error occurred during the resource addition.
-
updateResource
Description copied from interface:ResourceWriterUpdates the content of the resource with the provided name.- Specified by:
updateResourcein interfaceResourceWriter- Parameters:
name- the name of the resourcecontent- the content of the resource- Returns:
truewhen the resource was updated;falseotherwise- Throws:
ResourceWriterErrorException- if an error occurred during the resource update.
-
removeResource
Description copied from interface:ResourceWriterRemoves the resource with the provided name.- Specified by:
removeResourcein interfaceResourceWriter- Parameters:
name- the name of the resource- Returns:
truewhen the resource was removed;falseotherwise- Throws:
ResourceWriterErrorException- if an error occurred during the resource removal.
-