WebObjects 5.2.3

com.webobjects.eoapplication
Class EODefaults

java.lang.Object
  extended bycom.webobjects.eoapplication.EODefaults
All Implemented Interfaces:
NSDisposable
Direct Known Subclasses:
EORemoteStorageDefaults, EOUserFileDefaults

public class EODefaults
extends Object
implements NSDisposable

EODefaults objects are used to collect user defaults like window sizes and positions. The EOApplication object of the application has a defaults method which returns the shared instance used by all controllers to register values.


Field Summary
static String DefaultsKey
          The key through which you can access the (mutable) dictionary of default values to be loaded or saved in the userInfo of the LoadUserDefaultsNotification and SaveUserDefaultsNotification notifications.
static String LoadUserDefaultsNotification
          The name of the notification sent by default managers which rely on other objects to load default values (default implementation of EODefaults, but commonly overridden by subclasses).
static String SaveUserDefaultsNotification
          The name of the notification sent by default managers which rely on other objects to store default values (default implementation of EODefaults, but commonly overridden by subclasses).
 
Constructor Summary
EODefaults()
          Creates a new defaults manager object.
 
Method Summary
 NSDictionary allValues()
          Returns a dictionary with all key/value pairs stored in the defaults manager (both transient and persistent values).
 void clearAllValues()
          Clears out all default values collected so far.
 void dispose()
          Prepares the receiver so it is disposed when Java performs garbage collection.
 void flushDefaultsToPersistentStore()
          Saves the persistent user defaults, but only if there have been any changes that would require saving.
protected  NSDictionary loadPersistentValues()
          Loads the persistent user defaults.
protected  void savePersistentValues(NSDictionary values)
          Saves the persistent user defaults.
 void setPersistentValueForKey(Object value, String key)
          Stores a value with the key key as persistent in the defaults manager.
 void setTransientValueForKey(Object value, String key)
          Stores a value with the key key as transient in the defaults manager.
 Object valueForKey(String key)
          Returns the value stored in the defaults manager with the key key or null if no value is stored with that key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DefaultsKey

public static final String DefaultsKey
The key through which you can access the (mutable) dictionary of default values to be loaded or saved in the userInfo of the LoadUserDefaultsNotification and SaveUserDefaultsNotification notifications.


LoadUserDefaultsNotification

public static final String LoadUserDefaultsNotification
The name of the notification sent by default managers which rely on other objects to load default values (default implementation of EODefaults, but commonly overridden by subclasses). If the defaults manager your application uses supports it, you can register for this notification and fill in the user defaults in the mutable dictionary (NSMutableDictionary) provided through the the DefaultsKey key in the userInfo of the notification.


SaveUserDefaultsNotification

public static final String SaveUserDefaultsNotification
The name of the notification sent by default managers which rely on other objects to store default values (default implementation of EODefaults, but commonly overridden by subclasses). If the defaults manager your application uses supports it, you can register for this notification and store the user defaults provided as a dictionary with the DefaultsKey key in the userInfo of the notification.

Constructor Detail

EODefaults

public EODefaults()
Creates a new defaults manager object.

Method Detail

allValues

public NSDictionary allValues()
Returns a dictionary with all key/value pairs stored in the defaults manager (both transient and persistent values).

Returns:
a dictionary with all defaults values

clearAllValues

public void clearAllValues()
Clears out all default values collected so far.


dispose

public void dispose()
Prepares the receiver so it is disposed when Java performs garbage collection.

Specified by:
dispose in interface NSDisposable

flushDefaultsToPersistentStore

public void flushDefaultsToPersistentStore()
Saves the persistent user defaults, but only if there have been any changes that would require saving.

See Also:
savePersistentValues(NSDictionary values)

loadPersistentValues

protected NSDictionary loadPersistentValues()
Loads the persistent user defaults. The default implementation posts a LoadUserDefaultsNotification notification to give other objects an opportunity to fill in values.

Returns:
the defaults loaded
See Also:
savePersistentValues(NSDictionary values)

savePersistentValues

protected void savePersistentValues(NSDictionary values)
Saves the persistent user defaults. The default implementation posts a SaveUserDefaultsNotification notification to give other objects an opportunity to store the values.

Parameters:
values - the persistent values to save
See Also:
loadPersistentValues()

setPersistentValueForKey

public void setPersistentValueForKey(Object value,
                                     String key)
Stores a value with the key key as persistent in the defaults manager. The receiver attempts to save the values with the help of the server when the client application terminates. If you just want to collect temporary values which should not be stored, use the setTransientValueForKey method.

Parameters:
value - the defaults value
key - the key with which to store the value
See Also:
setTransientValueForKey(Object, String), savePersistentValues(NSDictionary values)

setTransientValueForKey

public void setTransientValueForKey(Object value,
                                    String key)
Stores a value with the key key as transient in the defaults manager. Transient values will be forgotten completely when the client application terminates. If you want to store a value for the next time the application is started, use the setPersistentValueForKey method.

Parameters:
value - the defaults value
key - the key with which to store the value
See Also:
setPersistentValueForKey(Object, String)

valueForKey

public Object valueForKey(String key)
Returns the value stored in the defaults manager with the key key or null if no value is stored with that key. First checks in the persistent values and then in the transient values.

Parameters:
key - the key to look up
Returns:
the defaults value or null if no value is stored with the key

Last updated Thu Oct 21 15:04:16 PDT 2004.

Copyright © 2004 Apple Computer, Inc.