public interface Files
Modifier and Type | Method and Description |
---|---|
void |
createDefaultFile(String defaultFilePath,
String initMessage)
Creates a default File in case it does not exist yet.
|
File |
getLibLocation()
gets the File pointing towards the location of the lib-folder
|
File |
getLogsLocation()
gets the File pointing towards the location of the logs-folder
|
File |
getPropertiesLocation()
gets the File pointing towards the location of the properties-folder
|
File |
getResourceLocation()
gets the File pointing towards the location of the resource-folder
|
void |
register(FileSubscriber fileSubscriber,
Identification identification)
Registers a
FileSubscriber so that whenever any file is reloaded, the fileSubscriber is notified. |
void |
register(ReloadableFile reloadableFile,
FileSubscriber fileSubscriber,
Identification identification)
Registers a
FileSubscriber with a ReloadableFile . |
void |
registerFileDir(Path dir,
String fileType,
ReloadableFile reloadableFile)
Use this method to register a file with the watcherService
|
void |
unregister(FileSubscriber fileSubscriber)
Unregisters all instances of fileSubscriber found.
|
boolean |
writeToFile(String defaultFilePath,
String realFilePath)
Writes default file to real file
The default file would be a file that can be packaged along with the code, from which a real file (say a
properties file for example) can be loaded.
|
void registerFileDir(Path dir, String fileType, ReloadableFile reloadableFile) throws IOException
dir
- directory of filefileType
- the name/extension of the file
IMPORTANT: Please try to always enter the full name with extension of the file (Ex: "test.txt"),
it would be best if the fileType is the full file name, and that the file name is clearly
distinguishable from other files.
For example, the property files are stored with the ID of the addon they belong too. That way
every property file is easily distinguishable.reloadableFile
- object of interface that file belongs toIOException
- exception thrown by watcher serviceboolean writeToFile(String defaultFilePath, String realFilePath)
defaultFilePath
- path to default file (or where it should be created)realFilePath
- path to real file (that should be filled with content of default file)void createDefaultFile(String defaultFilePath, String initMessage) throws IOException
defaultFilePath
- path to default file.txt (or where it should be created)initMessage
- the string to write in default fileIOException
- is thrown by bufferedWritervoid register(ReloadableFile reloadableFile, FileSubscriber fileSubscriber, Identification identification) throws IllegalIDException
FileSubscriber
with a ReloadableFile
. So when the reloadableFile
is
reloaded, the fileSubscriber will be notified. Multiple file subscribers can be registered with the same
reloadable file.reloadableFile
- the reloadable file that should be observedfileSubscriber
- the fileSubscriber that should be notified when the reloadable file is reloadedidentification
- the Identification of the requesting instanceIllegalIDException
- not yet implementedvoid register(FileSubscriber fileSubscriber, Identification identification) throws IllegalIDException
FileSubscriber
so that whenever any file is reloaded, the fileSubscriber is notified.fileSubscriber
- the fileSubscriber that should be notified when the reloadable file is reloadedidentification
- the Identification of the requesting instanceIllegalIDException
- not yet implementedvoid unregister(FileSubscriber fileSubscriber)
fileSubscriber
- the fileSubscriber to unregisterFile getLibLocation()
File getResourceLocation()
File getPropertiesLocation()
File getLogsLocation()
Copyright © 2016. All rights reserved.