public class PreferencesService extends AbstractPreferencesService
IPreferencesService.
System preferences are stored in a common location depending on the OS. User
preferences are stored in a hidden directory of the user's home directory.AbstractPreferencesService.FlushingThread| Modifier and Type | Field and Description |
|---|---|
static IPreferencesService |
INSTANCE
The default global preference service
|
| Modifier and Type | Method and Description |
|---|---|
protected IPreferences |
createRootNode()
Creates the root node.
|
protected void |
flushSystemPreferences(IPreferences node,
String applicationName)
Flushes the system preferences from the given node.
|
protected void |
flushUserPreferences(IPreferences node,
String applicationName)
Flushes the user preferences from the given node.
|
protected InputStream |
getInputStream(File f)
Returns an input stream that can be safely read.
|
protected OutputStream |
getOutputStream(File f)
Returns an output stream that can be written to.
|
protected File |
getSystemHome()
Returns the system home dir to store system prefs at.
|
protected File |
getSystemPreferencesFile(String applicationName)
Returns the application's preferences file of the system.
|
File |
getSystemPreferencesHome(String applicationName)
Returns the home directory for system preferences of the given application.
|
protected File |
getUserHome()
Returns the home directory of the user.
|
protected File |
getUserPreferencesFile(String applicationName)
Returns the application's preferences file of the user.
|
File |
getUserPreferencesHome(String applicationName)
Returns the home directory for user preferences of the given application.
|
protected void |
load(IPreferences node,
InputStream in)
Loads the information from the stream into the node
|
protected void |
loadSystemPreferences(IPreferences node,
String applicationName)
Loads the system preferences into the given node.
|
protected void |
loadUserPreferences(IPreferences node,
String applicationName)
Loads the user preferences into the given node.
|
protected void |
put(IPreferences node,
String key,
String value)
Stores the key at the appropriate sub-node.
|
protected void |
save(IPreferences node,
OutputStream out)
Saves the node information into the stream
|
protected void |
save(String prefix,
IPreferences node,
PrintWriter out)
Recursively stores the given node into the writer.
|
checkNodeName, createReadWriteLock, flush, getApplicationName, getApplicationNode, getApplicationPreferences, getLockNode, getReadLock, getReadWriteLock, getSystemPreferences, getUserPreferences, getWriteLock, nodeChanged, syncpublic static final IPreferencesService INSTANCE
protected IPreferences createRootNode()
createRootNode in class AbstractPreferencesServiceprotected void loadUserPreferences(IPreferences node, String applicationName) throws BackingStoreException
loadUserPreferences in class AbstractPreferencesServicenode - node that shall be populatedapplicationName - name of application to be loadedBackingStoreExceptionprotected void loadSystemPreferences(IPreferences node, String applicationName) throws BackingStoreException
loadSystemPreferences in class AbstractPreferencesServicenode - node that shall be populatedapplicationName - name of application to be loadedBackingStoreExceptionprotected void flushUserPreferences(IPreferences node, String applicationName) throws BackingStoreException
flushUserPreferences in class AbstractPreferencesServicenode - node that shall be flushedapplicationName - name of application to be flushedBackingStoreExceptionprotected void flushSystemPreferences(IPreferences node, String applicationName) throws BackingStoreException
flushSystemPreferences in class AbstractPreferencesServicenode - node that shall be flushedapplicationName - name of application to be flushedBackingStoreExceptionprotected InputStream getInputStream(File f) throws BackingStoreException
f - fileBackingStoreException - when the file cannot be openedprotected OutputStream getOutputStream(File f) throws BackingStoreException
f - fileBackingStoreException - when the file cannot be openedprotected void load(IPreferences node, InputStream in) throws BackingStoreException
node - node to be filledin - input streamBackingStoreException - when the stream contains errorsprotected void put(IPreferences node, String key, String value)
node - nodekey - path of key (including node)value - value of keyprotected void save(IPreferences node, OutputStream out) throws BackingStoreException
node - node to be savedout - output streamBackingStoreException - when the stream produces errorsprotected void save(String prefix, IPreferences node, PrintWriter out) throws BackingStoreException
prefix - prefix to be used for keys (can be null)node - node to be writtenout - print writerBackingStoreException - when a node cannot be writtenpublic File getUserPreferencesHome(String applicationName)
applicationName - name of applicationprotected File getUserHome()
protected File getUserPreferencesFile(String applicationName)
public File getSystemPreferencesHome(String applicationName)
applicationName - name of applicationprotected File getSystemPreferencesFile(String applicationName)
protected File getSystemHome()
Copyright © 2014. All rights reserved.