DataFileModule
The DataFileModule handles DataFiles. DataFiles are wrappers around a File and a DataFormat. Current supported DataFormats are: YML, JSON and JSON_UNINDENTED.
The DataFileModule depends on the SerializationModule.
Loading
The DataFile simplifies loading and saving data to a file. A file is read and converted to String-Object mappings with the load() method. If the file is not found, an empty map is returned instead. If there is any problem reading the map, a DataFileException is thrown with a clear message detailing what has gone wrong. This message can be safely displayed to and understood by the user. Common cases are an error in configuration syntax of file read/write permissions. The user will then be able to fix these.
Saving
Objects can be saved to a DataFile. The Object is first serialized through the SerializationModule, then saved to the file in the associated DataFormat. A common use case it to schedule auto-saving of an Object. This will associate the Object with the DataFile. A WeakReference to the Object is kept to avoid maintaining a reference.
Auto-saving
By default the DataPathModule has a scheduled auto-save every 30 minutes. Auto-saving can be disabled and/or the delay can be changed. Saved can also be performed manually. All changes to scheduled objects are guaranteed to be maintained in their associated DataFile through proper application shut downs and between auto-saves. If an Application crashes in-between auto-saves the unsaved data is lost.
Jackson
Loading/saving of files happens through the Jackson library. In some cases, such as the DataFormat enum, the DataFileModule only simplifies or translates Jackson functions. In this way the DataFileModule acts as an adapter between LBTools concepts, and Jackson concepts as well as allowing implementations other than Jackson in the future.