Eclipse Rich Ajax Platform

org.eclipse.rwt.service
Class FileSettingStore

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

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

This ISettingStore implementation persists all settings on the file system using Java Properties.

Since:
1.1

Field Summary
static java.lang.String FILE_SETTING_STORE_DIR
          This key (value "org.eclipse.rwt.service.FileSettingStore.dir") can be used to configure the working directory for file settings stores.
 
Constructor Summary
FileSettingStore(java.io.File workDir)
          Create a FileSettingStore instance.
 
Method Summary
 void addSettingStoreListener(SettingStoreListener listener)
          Attaches an SettingStoreListener to this ISettingStore.
 java.lang.String getAttribute(java.lang.String name)
          Returns the attribute stored under the specified name in this ISettingStore, or null if no attribute is stored under that name.
 java.util.Enumeration getAttributeNames()
          Returns an Enumeration of String objects with the names of all attributes in this ISettingStore.
 java.lang.String getId()
          Returns the unique identifier of this setting store
 void loadById(java.lang.String id)
          Replace the contents of this setting store with all attributes persisted under the given id.
 void removeAttribute(java.lang.String name)
          Removes the attribute stored under the specified name from this ISettingStore.
 void removeSettingStoreListener(SettingStoreListener listener)
          Removes an SettingStoreListener from this ISettingStore.
 void setAttribute(java.lang.String name, java.lang.String value)
          Stores an attribute to this ISettingStore, 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.rwt.service.FileSettingStore.dir") can be used to configure the working directory for file settings stores. See RWTFileSettingStoreFactory and WorkbenchFileSettingStoreFactory.

See Also:
Constant Field Values
Constructor Detail

FileSettingStore

public FileSettingStore(java.io.File workDir)
Create a FileSettingStore instance. The store will be initialized with a unique random id and will contain no attributes. Use loadById(String) to initialize an existing store with previously persisted attributes.

Parameters:
workDir - a non-null File instance denoting an existing directory, which will be used by this class persist its settings.
Throws:
java.lang.NullPointerException - if the argument workDir is null
java.lang.IllegalArgumentException - if the argument workDir is not a directory
See Also:
loadById(String)
Method Detail

getId

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

Specified by:
getId in interface ISettingStore
Returns:
a non-empty String value; never null

getAttribute

public java.lang.String getAttribute(java.lang.String name)
Description copied from interface: ISettingStore
Returns the attribute stored under the specified name in this ISettingStore, or null if no attribute is stored under that name.

Specified by:
getAttribute in interface ISettingStore
Parameters:
name - a non-null String specifying the name of the attribute
Returns:
a String value or null

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.String value)
                  throws SettingStoreException
Description copied from interface: ISettingStore
Stores an attribute to this ISettingStore, using the name specified. If an attribute with the same name is already stored in that ISettingStore the previous value is replaced.

Any attribute stored to this ISettingStore using this method is considered persisted from that point on.

If the value argument is null, this has the same effect as calling ISettingStore.removeAttribute(String).

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

Specified by:
setAttribute in interface ISettingStore
Parameters:
name - the name of the attribute; cannot be null
value - the String to store; may be null
Throws:
SettingStoreException - if the load operation failed to complete normally

getAttributeNames

public java.util.Enumeration getAttributeNames()
Description copied from interface: ISettingStore
Returns an Enumeration of String objects with the names of all attributes in this ISettingStore.

Specified by:
getAttributeNames in interface ISettingStore
Returns:
an Enumeration; never null

loadById

public void loadById(java.lang.String id)
              throws SettingStoreException
Description copied from interface: ISettingStore
Replace the contents of this setting store with all attributes persisted under the given id.

The attributes of this setting store before the load operation 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 value. 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.

It is important to note that this operation does not create a new setting store, so that listeners still remain associated with the same store instance. Instead the contents of this setting store are replaced with the contents associated with the given id.

Specified by:
loadById in interface ISettingStore
Parameters:
id - a non-null; non-empty; non-whitespace-only String
Throws:
SettingStoreException - if the load operation failed to complete normally

removeAttribute

public void removeAttribute(java.lang.String name)
                     throws SettingStoreException
Description copied from interface: ISettingStore
Removes the attribute stored under the specified name from this ISettingStore. 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
Parameters:
name - the name of the attribute to remove; cannot be null
Throws:
SettingStoreException - if the remove operation failed to complete normally

addSettingStoreListener

public void addSettingStoreListener(SettingStoreListener listener)
Description copied from interface: ISettingStore
Attaches an SettingStoreListener to this ISettingStore.

Listeners attached to this instance will notified of changes in the store.

Specified by:
addSettingStoreListener in interface ISettingStore
Parameters:
listener - the SettingStoreListener to add; non-null

removeSettingStoreListener

public void removeSettingStoreListener(SettingStoreListener listener)
Description copied from interface: ISettingStore
Removes an SettingStoreListener from this ISettingStore.

Specified by:
removeSettingStoreListener in interface ISettingStore
Parameters:
listener - the SettingStoreListener to remove; non-null

Eclipse Rich Ajax Platform

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