Eclipse Remote Application Platform

org.eclipse.rap.rwt.service
Class FileSettingStore

java.lang.Object
  extended by org.eclipse.rap.rwt.service.FileSettingStore
All Implemented Interfaces:
ISettingStore, SettingStore

public final class FileSettingStore
extends java.lang.Object
implements SettingStore

A setting store implementation that persists all settings on the file system using Java Properties files.

Since:
2.0

Field Summary
static 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.
 
Constructor Summary
FileSettingStore(java.io.File baseDirectory)
          Creates an empty instance with a random unique ID.
 
Method Summary
 void addSettingStoreListener(SettingStoreListener listener)
          Attaches the given listener to this setting store.
 java.lang.String getAttribute(java.lang.String name)
          Returns the attribute stored under the specified name in this setting store.
 java.util.Enumeration<java.lang.String> getAttributeNames()
          Returns an Enumeration of strings with the names of all attributes in this setting store.
 java.lang.String getId()
          Returns the unique identifier of this setting store.
 void loadById(java.lang.String id)
          Replaces the contents of this setting store with the persisted contents associated with the given ID.
 void removeAttribute(java.lang.String name)
          Removes the attribute stored under the specified name from this setting store.
 void removeSettingStoreListener(SettingStoreListener listener)
          Removes the given listener from this setting store.
 void setAttribute(java.lang.String name, java.lang.String value)
          Stores a given attribute in this setting store, using the name specified.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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. See FileSettingStoreFactory.

See Also:
Constant Field Values
Constructor Detail

FileSettingStore

public FileSettingStore(java.io.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:
java.lang.IllegalArgumentException - if the given workDir is not a directory
See Also:
loadById(String)
Method Detail

getId

public java.lang.String getId()
Description copied from interface: SettingStore
Returns the unique identifier of this setting store.

Specified by:
getId in interface ISettingStore
Specified by:
getId in interface SettingStore
Returns:
a non-empty string, never null

getAttribute

public java.lang.String getAttribute(java.lang.String name)
Description copied from interface: SettingStore
Returns the attribute stored under the specified name in this setting store.

Specified by:
getAttribute in interface ISettingStore
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(java.lang.String name,
                         java.lang.String value)
                  throws java.io.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 ISettingStore
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:
java.io.IOException - if the load operation failed to complete normally

getAttributeNames

public java.util.Enumeration<java.lang.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 ISettingStore
Specified by:
getAttributeNames in interface SettingStore
Returns:
an enumeration with the attribute names in this setting store, never null

loadById

public void loadById(java.lang.String id)
              throws java.io.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 ISettingStore
Specified by:
loadById in interface SettingStore
Parameters:
id - the ID of the settings to load, must not be null or empty
Throws:
java.io.IOException - if the load operation failed to complete normally

removeAttribute

public void removeAttribute(java.lang.String name)
                     throws java.io.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 ISettingStore
Specified by:
removeAttribute in interface SettingStore
Parameters:
name - the name of the attribute to remove, must not be null
Throws:
java.io.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 ISettingStore
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 ISettingStore
Specified by:
removeSettingStoreListener in interface SettingStore
Parameters:
listener - the listener to remove, must not be null

Eclipse Remote Application Platform

Copyright (c) EclipseSource and others 2002, 2012. All rights reserved.