Class FileSettingStore
- java.lang.Object
-
- org.eclipse.rap.rwt.service.FileSettingStore
-
- All Implemented Interfaces:
SettingStore
public final class FileSettingStore extends java.lang.Object implements SettingStore
A setting store implementation that persists all settings on the file system using JavaPropertiesfiles.- Since:
- 2.0
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringFILE_SETTING_STORE_DIRThis key (value "org.eclipse.rap.rwt.service.FileSettingStore.dir") can be used to configure the working directory for file settings stores.
-
Constructor Summary
Constructors Constructor Description FileSettingStore(java.io.File baseDirectory)Creates an empty instance with a random unique ID.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSettingStoreListener(SettingStoreListener listener)Attaches the given listener to this setting store.java.lang.StringgetAttribute(java.lang.String name)Returns the attribute stored under the specified name in this setting store.java.util.Enumeration<java.lang.String>getAttributeNames()Returns anEnumerationof strings with the names of all attributes in this setting store.java.lang.StringgetId()Returns the unique identifier of this setting store.voidloadById(java.lang.String id)Replaces the contents of this setting store with the persisted contents associated with the given ID.voidremoveAttribute(java.lang.String name)Removes the attribute stored under the specified name from this setting store.voidremoveSettingStoreListener(SettingStoreListener listener)Removes the given listener from this setting store.voidsetAttribute(java.lang.String name, java.lang.String value)Stores a given attribute in this setting store, using the name specified.
-
-
-
Field Detail
-
FILE_SETTING_STORE_DIR
public static final java.lang.String FILE_SETTING_STORE_DIR
This key (value "org.eclipse.rap.rwt.service.FileSettingStore.dir") can be used to configure the working directory for file settings stores. SeeFileSettingStoreFactory.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
FileSettingStore
public FileSettingStore(java.io.File baseDirectory)
Creates an empty instance with a random unique ID. UseloadById(String)to initialize an existing store with previously persisted attributes.- Parameters:
baseDirectory- an existing directory to persist this store's settings in- Throws:
java.lang.IllegalArgumentException- if the givenworkDiris not a directory- See Also:
loadById(String)
-
-
Method Detail
-
getId
public java.lang.String getId()
Description copied from interface:SettingStoreReturns the unique identifier of this setting store.- Specified by:
getIdin interfaceSettingStore- Returns:
- a non-empty string, never
null
-
getAttribute
public java.lang.String getAttribute(java.lang.String name)
Description copied from interface:SettingStoreReturns the attribute stored under the specified name in this setting store.- Specified by:
getAttributein interfaceSettingStore- Parameters:
name- a non-null String specifying the name of the attribute- Returns:
- the attribute stored under the given name or
nullif no attribute is stored under that name
-
setAttribute
public void setAttribute(java.lang.String name, java.lang.String value) throws java.io.IOExceptionDescription copied from interface:SettingStoreStores a given attribute in this setting store, using the name specified. If an attribute with the same name is already stored in this setting store, the previous value is replaced. The attribute is considered persisted when after this method completes.If the value is
null, this has the same effect as callingSettingStore.removeAttribute(String).SettingStoreListeners attached to this instance will be notified after an attribute has been stored.- Specified by:
setAttributein interfaceSettingStore- Parameters:
name- the name of the attribute, must not benullor emptyvalue- the attribute to store, may benull- Throws:
java.io.IOException- if the load operation failed to complete normally
-
getAttributeNames
public java.util.Enumeration<java.lang.String> getAttributeNames()
Description copied from interface:SettingStoreReturns anEnumerationof strings with the names of all attributes in this setting store.- Specified by:
getAttributeNamesin interfaceSettingStore- Returns:
- an enumeration with the attribute names in this setting store, never
null
-
loadById
public void loadById(java.lang.String id) throws java.io.IOExceptionDescription copied from interface:SettingStoreReplaces the contents of this setting store with the persisted contents associated with the given ID.The attributes of this setting store will remain associated with the old id, but will be removed from this store instance.
SettingStoreListeners attached to this store will receive a notification for each removed attribute.During the load operation this store will be filled with the attributes associated with the new ID.
SettingStoreListeners attached to this store will receive a notification for each added attribute.After the load operation this store will only hold attributes associated with the new id value.
- Specified by:
loadByIdin interfaceSettingStore- Parameters:
id- the ID of the settings to load, must not benullor empty- Throws:
java.io.IOException- if the load operation failed to complete normally
-
removeAttribute
public void removeAttribute(java.lang.String name) throws java.io.IOExceptionDescription copied from interface:SettingStoreRemoves the attribute stored under the specified name from this setting store. If no attribute is stored under the specified name, this method does nothing.SettingStoreListeners attached to this instance will be notified after an attribute has been removed.- Specified by:
removeAttributein interfaceSettingStore- Parameters:
name- the name of the attribute to remove, must not benull- Throws:
java.io.IOException- if the remove operation failed to complete normally
-
addSettingStoreListener
public void addSettingStoreListener(SettingStoreListener listener)
Description copied from interface:SettingStoreAttaches the given listener to this setting store. Listeners will be notified of changes in the store. If the listener has already been added to this store, this method does nothing.- Specified by:
addSettingStoreListenerin interfaceSettingStore- Parameters:
listener- the listener to add, must not benull
-
removeSettingStoreListener
public void removeSettingStoreListener(SettingStoreListener listener)
Description copied from interface:SettingStoreRemoves the given listener from this setting store. If the listener has not been added, this method does nothing.- Specified by:
removeSettingStoreListenerin interfaceSettingStore- Parameters:
listener- the listener to remove, must not benull
-
-