Class FileSettingStore

java.lang.Object
org.eclipse.rap.rwt.service.FileSettingStore
All Implemented Interfaces:
SettingStore

public final class FileSettingStore extends Object implements SettingStore
A setting store implementation that persists all settings on the file system using Java Properties files.
Since:
2.0
  • Field Details

    • FILE_SETTING_STORE_DIR

      public static final 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. See FileSettingStoreFactory.
      See Also:
  • Constructor Details

    • FileSettingStore

      public FileSettingStore(File baseDirectory)
      Creates an empty instance with a random unique ID. Use loadById(String) to initialize an existing store with previously persisted attributes.
      Parameters:
      baseDirectory - an existing directory to persist this store's settings in
      Throws:
      IllegalArgumentException - if the given workDir is not a directory
      See Also:
  • Method Details

    • getId

      public String getId()
      Description copied from interface: SettingStore
      Returns the unique identifier of this setting store.
      Specified by:
      getId in interface SettingStore
      Returns:
      a non-empty string, never null
    • getAttribute

      public String getAttribute(String name)
      Description copied from interface: SettingStore
      Returns the attribute stored under the specified name in this setting store.
      Specified by:
      getAttribute in interface SettingStore
      Parameters:
      name - a non-null String specifying the name of the attribute
      Returns:
      the attribute stored under the given name or null if no attribute is stored under that name
    • setAttribute

      public void setAttribute(String name, String value) throws IOException
      Description copied from interface: SettingStore
      Stores 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 calling SettingStore.removeAttribute(String).

      SettingStoreListeners attached to this instance will be notified after an attribute has been stored.

      Specified by:
      setAttribute in interface SettingStore
      Parameters:
      name - the name of the attribute, must not be null or empty
      value - the attribute to store, may be null
      Throws:
      IOException - if the load operation failed to complete normally
    • getAttributeNames

      public Enumeration<String> getAttributeNames()
      Description copied from interface: SettingStore
      Returns an Enumeration of strings with the names of all attributes in this setting store.
      Specified by:
      getAttributeNames in interface SettingStore
      Returns:
      an enumeration with the attribute names in this setting store, never null
    • loadById

      public void loadById(String id) throws IOException
      Description copied from interface: SettingStore
      Replaces 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:
      loadById in interface SettingStore
      Parameters:
      id - the ID of the settings to load, must not be null or empty
      Throws:
      IOException - if the load operation failed to complete normally
    • removeAttribute

      public void removeAttribute(String name) throws IOException
      Description copied from interface: SettingStore
      Removes 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:
      removeAttribute in interface SettingStore
      Parameters:
      name - the name of the attribute to remove, must not be null
      Throws:
      IOException - if the remove operation failed to complete normally
    • addSettingStoreListener

      public void addSettingStoreListener(SettingStoreListener listener)
      Description copied from interface: SettingStore
      Attaches 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:
      addSettingStoreListener in interface SettingStore
      Parameters:
      listener - the listener to add, must not be null
    • removeSettingStoreListener

      public void removeSettingStoreListener(SettingStoreListener listener)
      Description copied from interface: SettingStore
      Removes the given listener from this setting store. If the listener has not been added, this method does nothing.
      Specified by:
      removeSettingStoreListener in interface SettingStore
      Parameters:
      listener - the listener to remove, must not be null