WebObjects 5.1

com.webobjects.eoapplication
Class EODefaults

java.lang.Object
  |
  +--com.webobjects.eoapplication.EODefaults
All Implemented Interfaces:
NSDisposable

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.

EODefaults works together with the server side of Java Client applications: When the client starts up, it tries to receive values from the distribution context on the server side, and when the application terminates, it asks the distribution context to store all the persistent values. The distribution context in turn sends out notifications to read or write the default values, so you can register for these notifications on the server side and implement your own storage mechanism (for example to store the user defaults in the database).

See Also:
EODistributionContext

Constructor Summary
EODefaults()
          Creates a new defaults manager object.
 
Method Summary
 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 loadPersistentValues()
          Loads the persistent user defaults.
 void savePersistentValues()
          Saves the persistent user defaults by asking the server to store them.
 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
 

Constructor Detail

EODefaults

public EODefaults()
Creates a new defaults manager object.
Method Detail

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

loadPersistentValues

public void loadPersistentValues()
Loads the persistent user defaults. The first time this method is invoked (or the next time after clearing out all values), it tries to load the persistent values from the server and then caches the values retrieved. On the server side you need to register for EODistribution context notifications to fill in the values, otherwise nothing happens.
See Also:
savePersistentValues(), EODistributionContext

savePersistentValues

public void savePersistentValues()
Saves the persistent user defaults by asking the server to store them. On the server side you need to register for EODistribution context notifications to save the values, otherwise nothing happens.
See Also:
loadPersistentValues(), EODistributionContext

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()

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 Jan 10 18:10:21 PST 2002.

Copyright © 2002 Apple Computer, Inc.