Eclipse Rich Ajax Platform

org.eclipse.rwt.service
Interface ISettingStore

All Known Implementing Classes:
FileSettingStore

public interface ISettingStore

An ISettingStore is a mechanism persisting settings (i.e. key/value pairs) beyond the scope of a single session.

A setting store instance is always associated with the current session. Any settings being put into the store (via setAttribute(String, String)) are considered persisted from that point on.

To retrieve data stored in a previous session, client can invoke the loadById(String) method with an appropriate id. This will load any data stored under that id into the current setting store.

This mechanism is intended to be used as follows: by default RWT will assign a new setting store to each new session, based on the current session id. After the user has authenticated, application developers can use the loadById(String) method to initialize the store with persisted data stored under that id during a previous session. Obviously, any data that is set into the store from that point on, will also be persisted under the current id and will also be available in the future.

Clients who wish to implement own setting store must also provide a corresponding ISettingStoreFactory.

Since:
1.1
See Also:
FileSettingStore

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.
 

Method Detail

getAttribute

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.

Parameters:
name - a non-null String specifying the name of the attribute
Returns:
a String value or null

getAttributeNames

java.util.Enumeration getAttributeNames()
Returns an Enumeration of String objects with the names of all attributes in this ISettingStore.

Returns:
an Enumeration; never null

setAttribute

void setAttribute(java.lang.String name,
                  java.lang.String value)
                  throws SettingStoreException
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 removeAttribute(String).

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

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
java.lang.NullPointerException - if name is null

removeAttribute

void removeAttribute(java.lang.String name)
                     throws SettingStoreException
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.

Parameters:
name - the name of the attribute to remove; cannot be null
Throws:
SettingStoreException - if the remove operation failed to complete normally
java.lang.NullPointerException - if name is null

loadById

void loadById(java.lang.String id)
              throws SettingStoreException
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.

Parameters:
id - a non-null; non-empty; non-whitespace-only String
Throws:
SettingStoreException - if the load operation failed to complete normally
java.lang.NullPointerException - if id is null
java.lang.IllegalArgumentException - if id is empty or composed entirely of whitespace

getId

java.lang.String getId()
Returns the unique identifier of this setting store

Returns:
a non-empty String value; never null

addSettingStoreListener

void addSettingStoreListener(SettingStoreListener listener)
Attaches an SettingStoreListener to this ISettingStore.

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

Parameters:
listener - the SettingStoreListener to add; non-null

removeSettingStoreListener

void removeSettingStoreListener(SettingStoreListener listener)
Removes an SettingStoreListener from this ISettingStore.

Parameters:
listener - the SettingStoreListener to remove; non-null

Eclipse Rich Ajax Platform

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