public class NetworkPreferencesFactory extends Object implements PreferencesFactory
This ensures that the preferences will follow a "nomad" user.
A NetworkPreferencesFactory is unique and have the following characteristics :NetworkPreferences
must be stored.
If the corresponding file is null, the user.home directory will be usedNetworkPreferences
must be stored.
If the corresponding file is null, the system.home directory will be used
The effective backing stores will only be created after the invocation of systemRoot()
or userRoot()
For a user preference :
For a system preference :
Examples:
NetworkPreferencesFactory(null, null, null, "test")
:
NetworkPreferencesFactory(new File("c:/user"), new File("c:/system"), "subDir", "test")
:
NetworkPreferencesFactory(null, null, "subDir", "test")
:
Modifier and Type | Method and Description |
---|---|
String |
getApplicationName()
Return the name that tag the factory for the application.
|
static NetworkPreferencesFactory |
getFactory()
Return the uniquely defined factory.
|
File |
getSystemDirectory()
Return the system root directory.
|
File |
getUserDirectory()
Return the user root directory.
|
static NetworkPreferencesFactory |
newFactory(File userDir,
File systemDir,
String subDir,
String appli)
Create the factory.
|
static void |
reset()
Reset the factory.
|
static Preferences |
systemNodeForPackage(Class<?> c) |
Preferences |
systemRoot()
Returns the system root preference node.
|
NetworkPreferences |
systemRootAsNetwork()
Convenience method that return the same object as
systemRoot() . |
Preferences |
userRoot()
Returns the user root preference node corresponding to the calling
user (Multiple calls on this method will return the same object reference).
|
NetworkPreferences |
userRootAsNetwork()
Convenience method that return the same object as
userRoot() . |
public static NetworkPreferencesFactory newFactory(File userDir, File systemDir, String subDir, String appli) throws BackingStoreException
userDir
- the root directory under which will be stored the user preferences (null if it is the user.home directory)systemDir
- the root directory under which will be stored the system preferences (null if it is the user.dir directory)subDir
- the sub-directory of userDir or systemDir, under which to create the application preferences
file (if null, there will be no sub-directory definition)appli
- the name that will tag the factory to create. This name is useful for the
user root creation, as the user preferences are serialized in an xml file in the user.home directory,
under a directory construted with the name of the applicationBackingStoreException
- if the factory have already been created, or if the userDir or
systemDir are not null and are not valid or are not already existingpublic static void reset()
getFactory()
to null.public static NetworkPreferencesFactory getFactory()
public String getApplicationName()
public File getSystemDirectory()
public File getUserDirectory()
public Preferences systemRoot()
The backing store of the user preferences will be a file in a directory with the following name ".prefs", in the user.dir directory
systemRoot
in interface PreferencesFactory
NetworkPreferences
public static Preferences systemNodeForPackage(Class<?> c)
public NetworkPreferences systemRootAsNetwork()
systemRoot()
.public Preferences userRoot()
The backing store of the user preferences will be a file in a directory with the following name "." <application name>, in the user.home directory. The application name is the name wich has been defined at the creation of the factory.
userRoot
in interface PreferencesFactory
NetworkPreferences
public NetworkPreferences userRootAsNetwork()
userRoot()
.