Package jadex.platform.service.settings
Class PlatformSettings
- java.lang.Object
-
- jadex.platform.service.settings.PlatformSettings
-
- All Implemented Interfaces:
IPlatformSettings
public class PlatformSettings extends java.lang.Object implements IPlatformSettings
-
-
Field Summary
Fields Modifier and Type Field Description protected RwAutoLocklockLocking mechanism.protected booleanreadonlyRead-only flag.protected java.io.FilesettingsdirThe settings dir.
-
Constructor Summary
Constructors Constructor Description PlatformSettings(IComponentIdentifier id, boolean readonly)Creates the settings manager.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.ObjectfromJson(java.lang.String json)Converts JSON to object.byte[]loadFile(java.lang.String filename)Directly loads a file from the settings directory.java.lang.ObjectloadState(java.lang.String id)Loads arbitrary state form a persistent directory.voidsaveFile(java.lang.String filename, byte[] content)Directly saves a file in the settings directory.voidsaveState(java.lang.String id, java.lang.Object state)Saves arbitrary state to a persistent directory as JSON.static java.lang.StringtoJson(java.lang.Object object)Converts object to JSON.
-
-
-
Field Detail
-
settingsdir
protected java.io.File settingsdir
The settings dir.
-
readonly
protected boolean readonly
Read-only flag.
-
lock
protected RwAutoLock lock
Locking mechanism.
-
-
Constructor Detail
-
PlatformSettings
public PlatformSettings(IComponentIdentifier id, boolean readonly)
Creates the settings manager.
-
-
Method Detail
-
saveState
public void saveState(java.lang.String id, java.lang.Object state)Saves arbitrary state to a persistent directory as JSON. Object must be serializable and the ID must be unique.- Specified by:
saveStatein interfaceIPlatformSettings- Parameters:
id- Unique ID for the saved state.state- The state being saved.
-
loadState
public java.lang.Object loadState(java.lang.String id)
Loads arbitrary state form a persistent directory.- Specified by:
loadStatein interfaceIPlatformSettings- Parameters:
id- Unique ID for the saved state.- Returns:
- The state or null if none was found or corrupt.
-
saveFile
public void saveFile(java.lang.String filename, byte[] content)Directly saves a file in the settings directory.- Specified by:
saveFilein interfaceIPlatformSettings- Parameters:
filename- Name of the file.content- The file content.
-
loadFile
public byte[] loadFile(java.lang.String filename)
Directly loads a file from the settings directory.- Specified by:
loadFilein interfaceIPlatformSettings- Parameters:
filename- Name of the file.- Returns:
- Content of the file or null if not found.
-
toJson
public static final java.lang.String toJson(java.lang.Object object)
Converts object to JSON.- Parameters:
object- Object.- Returns:
- JSON string.
-
fromJson
public static final java.lang.Object fromJson(java.lang.String json)
Converts JSON to object.- Parameters:
json- JSON.- Returns:
- Object.
-
-