public class PreferencesService extends java.lang.Object implements IPreferencesService
| Modifier and Type | Method and Description |
|---|---|
void |
applyPreferences(IEclipsePreferences tree,
IPreferenceFilter[] filters)
Apply the preference tree rooted at the given node, to the system's preference tree.
|
IStatus |
applyPreferences(IExportedPreferences preferences)
Take the given preference tree and apply it to the Eclipse
global preference hierarchy.
|
java.lang.ref.WeakReference<java.lang.Object> |
applyRuntimeDefaults(java.lang.String name,
java.lang.ref.WeakReference<java.lang.Object> pluginReference) |
IEclipsePreferences |
createNode(java.lang.String key) |
void |
exportPreferences(IEclipsePreferences node,
IPreferenceFilter[] filters,
java.io.OutputStream stream)
Export the preference tree rooted at the given node, to the specified output
stream.
|
IStatus |
exportPreferences(IEclipsePreferences node,
java.io.OutputStream output,
java.lang.String[] excludesList)
Exports all preferences for the given preference node and all its children to the specified
output stream.
|
java.lang.String |
get(java.lang.String key,
java.lang.String defaultValue,
Preferences[] nodes)
Lookup the given key in the specified preference nodes in the given order.
|
boolean |
getBoolean(java.lang.String qualifier,
java.lang.String key,
boolean defaultValue,
IScopeContext[] scopes)
Return the value stored in the preference store for the given key.
|
byte[] |
getByteArray(java.lang.String qualifier,
java.lang.String key,
byte[] defaultValue,
IScopeContext[] scopes)
Return the value stored in the preference store for the given key.
|
static PreferencesService |
getDefault() |
java.lang.String[] |
getDefaultDefaultLookupOrder() |
java.lang.String[] |
getDefaultLookupOrder(java.lang.String qualifier,
java.lang.String key)
Return an array with the default lookup order for the preference keyed by the given
qualifier and simple name.
|
double |
getDouble(java.lang.String qualifier,
java.lang.String key,
double defaultValue,
IScopeContext[] scopes)
Return the value stored in the preference store for the given key.
|
float |
getFloat(java.lang.String qualifier,
java.lang.String key,
float defaultValue,
IScopeContext[] scopes)
Return the value stored in the preference store for the given key.
|
int |
getInt(java.lang.String qualifier,
java.lang.String key,
int defaultValue,
IScopeContext[] scopes)
Return the value stored in the preference store for the given key.
|
long |
getLong(java.lang.String qualifier,
java.lang.String key,
long defaultValue,
IScopeContext[] scopes)
Return the value stored in the preference store for the given key.
|
java.lang.String[] |
getLookupOrder(java.lang.String qualifier,
java.lang.String key)
Return an array with the lookup order for the preference keyed by the given
qualifier and simple name.
|
IEclipsePreferences |
getRootNode()
Return the root node of the Eclipse preference hierarchy.
|
java.lang.String |
getString(java.lang.String qualifier,
java.lang.String key,
java.lang.String defaultValue,
IScopeContext[] scopes)
Return the value stored in the preference store for the given key.
|
IStatus |
importPreferences(java.io.InputStream input)
Loads preferences from the given file and stores them in the preferences store.
|
IPreferenceFilter[] |
matches(IEclipsePreferences tree,
IPreferenceFilter[] filters)
Return a list of filters which match the given tree and is a subset of the given
filter list.
|
IExportedPreferences |
readPreferences(java.io.InputStream input)
Read from the given input stream and create a node hierarchy
representing the preferences and their values.
|
void |
setDefaultDefaultLookupOrder(java.lang.String[] order) |
void |
setDefaultLookupOrder(java.lang.String qualifier,
java.lang.String key,
java.lang.String[] order)
Set the default scope lookup order for the preference keyed by the given
qualifier and simple name.
|
void |
setRegistryHelper(java.lang.Object registryHelper) |
IStatus |
validateVersions(IPath path) |
public static PreferencesService getDefault()
public void applyPreferences(IEclipsePreferences tree, IPreferenceFilter[] filters) throws CoreException
IPreferencesService
If the list of filters is null or empty then do nothing.
Before the tree is applied to the global preference tree,
the registered PreferenceModifyListener objects
are called and given the opportunity to modify the tree.
applyPreferences in interface IPreferencesServicetree - the tree to consider applyingfilters - the filters to useCoreExceptionIPreferencesService.applyPreferences(IExportedPreferences),
IPreferencesService.readPreferences(InputStream),
IPreferenceFilter,
PreferenceModifyListenerpublic IStatus applyPreferences(IExportedPreferences preferences) throws CoreException
IPreferencesService
The given preferences object must not be null.
Before the tree is applied to the global preference tree,
the registered PreferenceModifyListener objects
are called and given the opportunity to modify the tree.
applyPreferences in interface IPreferencesServicepreferences - the preferences to apply globallyCoreException - if there are problems applying the preferencesPreferenceModifyListenerpublic java.lang.ref.WeakReference<java.lang.Object> applyRuntimeDefaults(java.lang.String name,
java.lang.ref.WeakReference<java.lang.Object> pluginReference)
public IEclipsePreferences createNode(java.lang.String key)
public void exportPreferences(IEclipsePreferences node, IPreferenceFilter[] filters, java.io.OutputStream stream) throws CoreException
IPreferencesService
The given node and output stream must not be null.
If the list of filters is null or empty then do nothing.
It is the responsibility of the client to close the given output stream.
exportPreferences in interface IPreferencesServicenode - the tree to exportfilters - the list of filters to exportstream - the stream to export toCoreExceptionIPreferencesService.exportPreferences(IEclipsePreferences, OutputStream, String[]),
IPreferencesService.readPreferences(InputStream),
IPreferencesService.applyPreferences(IEclipsePreferences, IPreferenceFilter[]),
IPreferencesService.applyPreferences(IExportedPreferences),
IPreferenceFilterpublic IStatus exportPreferences(IEclipsePreferences node, java.io.OutputStream output, java.lang.String[] excludesList) throws CoreException
IPreferencesService
If the given export list is null then all preferences for all sub-nodes
of the given node are exported to the given stream. Otherwise the export list is
consulted before exporting each preference value. If there is a string match then
the preference is not exported. The exclusion can also occur at a per-node level.
Wild cards are not accepted in the excludes list as a basic String compare
is done. The basic algorithm is similar to the following:
String fullPath = node.absolutePath() + '/' + key;
if (!fullPath.startsWith(excludesList[i]))
// export preference
The values stored in the resulting stream are suitable for later being read by the
by IPreferencesService.importPreferences(InputStream) or IPreferencesService.readPreferences(InputStream) methods.
exportPreferences in interface IPreferencesServicenode - the node to treat as the root of the exportoutput - the stream to write toexcludesList - a list of path prefixes to exclude from the export, or nullCoreException - if there was a problem exporting the preferencesIPreferencesService.importPreferences(java.io.InputStream),
IPreferencesService.readPreferences(InputStream)public java.lang.String get(java.lang.String key,
java.lang.String defaultValue,
Preferences[] nodes)
IPreferencesService
Immediately returns the default value if the node list is null.
If any of the individual entries in the node list are null then
skip over them and move on to the next node in the list.
get in interface IPreferencesServicekey - the preference keydefaultValue - the default valuenodes - the list of nodes to search, or nullPreferencespublic boolean getBoolean(java.lang.String qualifier,
java.lang.String key,
boolean defaultValue,
IScopeContext[] scopes)
IPreferencesService
The semantics of this method are to calculate the appropriate
Preferences nodes in the preference hierarchy to use
and then call the IPreferencesService.get(String, String, Preferences[])
method. The order of the nodes is calculated by consulting the default
scope lookup order as set by IPreferencesService.setDefaultLookupOrder(String, String, String[]).
The specified key may either refer to a simple key or be the concatenation of the path of a child node and key. If the key contains a slash ("/") character, then a double-slash must be used to denote the end of they child path and the beginning of the key. Otherwise it is assumed that the key is the last segment of the path. The following are some examples of keys and their meanings:
The scope look-up order is determined by the preference service default lookup order, not by the order of the scope contexts that are being passed in. The context objects are only consulted to help determine which nodes to look in, not the order of the nodes.
Callers may specify an array of scope context objects to aid in the determination of the correct nodes. For each entry in the lookup order, the array of contexts is consulted and if one matching the scope exists, then it is used to calculate the node. Otherwise a default calculation algorithm is used.
An example of a qualifier for an Eclipse 2.1 preference is the plug-in identifier. (e.g. "org.eclipse.core.resources" for "description.autobuild")
getBoolean in interface IPreferencesServicequalifier - a namespace qualifier for the preferencekey - the name of the preference (optionally including its path)defaultValue - the value to use if the preference is not definedscopes - optional context objects to help scopes determine which nodes to search, or nullIScopeContext,
IPreferencesService.get(java.lang.String, java.lang.String, org.osgi.service.prefs.Preferences[]),
IPreferencesService.getLookupOrder(java.lang.String, java.lang.String),
IPreferencesService.getDefaultLookupOrder(java.lang.String, java.lang.String)public byte[] getByteArray(java.lang.String qualifier,
java.lang.String key,
byte[] defaultValue,
IScopeContext[] scopes)
IPreferencesService
The semantics of this method are to calculate the appropriate
Preferences nodes in the preference hierarchy to use
and then call the IPreferencesService.get(String, String, Preferences[])
method. The order of the nodes is calculated by consulting the default
scope lookup order as set by IPreferencesService.setDefaultLookupOrder(String, String, String[]).
The specified key may either refer to a simple key or be the concatenation of the path of a child node and key. If the key contains a slash ("/") character, then a double-slash must be used to denote the end of they child path and the beginning of the key. Otherwise it is assumed that the key is the last segment of the path. The following are some examples of keys and their meanings:
The scope look-up order is determined by the preference service default lookup order, not by the order of the scope contexts that are being passed in. The context objects are only consulted to help determine which nodes to look in, not the order of the nodes.
Callers may specify an array of scope context objects to aid in the determination of the correct nodes. For each entry in the lookup order, the array of contexts is consulted and if one matching the scope exists, then it is used to calculate the node. Otherwise a default calculation algorithm is used.
An example of a qualifier for an Eclipse 2.1 preference is the plug-in identifier. (e.g. "org.eclipse.core.resources" for "description.autobuild")
getByteArray in interface IPreferencesServicequalifier - a namespace qualifier for the preferencekey - the name of the preference (optionally including its path)defaultValue - the value to use if the preference is not definedscopes - optional context objects to help scopes determine which nodes to search, or nullIScopeContext,
IPreferencesService.get(java.lang.String, java.lang.String, org.osgi.service.prefs.Preferences[]),
IPreferencesService.getLookupOrder(java.lang.String, java.lang.String),
IPreferencesService.getDefaultLookupOrder(java.lang.String, java.lang.String)public java.lang.String[] getDefaultLookupOrder(java.lang.String qualifier,
java.lang.String key)
IPreferencesServicenull if no default has been set.
The lookup order returned is based on an exact match to the specified qualifier
and simple name. For instance, if the given key is non-null and
no default lookup order is found, the default lookup order for the qualifier (and a
null key) is NOT returned. Clients should call
IPreferencesService.getLookupOrder(String, String) if they desire this behavior.
getDefaultLookupOrder in interface IPreferencesServicequalifier - the namespace qualifier for the preferencekey - the preference name or nullnullIPreferencesService.setDefaultLookupOrder(String, String, String[]),
IPreferencesService.getLookupOrder(String, String)public double getDouble(java.lang.String qualifier,
java.lang.String key,
double defaultValue,
IScopeContext[] scopes)
IPreferencesService
The semantics of this method are to calculate the appropriate
Preferences nodes in the preference hierarchy to use
and then call the IPreferencesService.get(String, String, Preferences[])
method. The order of the nodes is calculated by consulting the default
scope lookup order as set by IPreferencesService.setDefaultLookupOrder(String, String, String[]).
The specified key may either refer to a simple key or be the concatenation of the path of a child node and key. If the key contains a slash ("/") character, then a double-slash must be used to denote the end of they child path and the beginning of the key. Otherwise it is assumed that the key is the last segment of the path. The following are some examples of keys and their meanings:
The scope look-up order is determined by the preference service default lookup order, not by the order of the scope contexts that are being passed in. The context objects are only consulted to help determine which nodes to look in, not the order of the nodes.
Callers may specify an array of scope context objects to aid in the determination of the correct nodes. For each entry in the lookup order, the array of contexts is consulted and if one matching the scope exists, then it is used to calculate the node. Otherwise a default calculation algorithm is used.
An example of a qualifier for an Eclipse 2.1 preference is the plug-in identifier. (e.g. "org.eclipse.core.resources" for "description.autobuild")
getDouble in interface IPreferencesServicequalifier - a namespace qualifier for the preferencekey - the name of the preference (optionally including its path)defaultValue - the value to use if the preference is not definedscopes - optional context objects to help scopes determine which nodes to search, or nullIScopeContext,
IPreferencesService.get(java.lang.String, java.lang.String, org.osgi.service.prefs.Preferences[]),
IPreferencesService.getLookupOrder(java.lang.String, java.lang.String),
IPreferencesService.getDefaultLookupOrder(java.lang.String, java.lang.String)public float getFloat(java.lang.String qualifier,
java.lang.String key,
float defaultValue,
IScopeContext[] scopes)
IPreferencesService
The semantics of this method are to calculate the appropriate
Preferences nodes in the preference hierarchy to use
and then call the IPreferencesService.get(String, String, Preferences[])
method. The order of the nodes is calculated by consulting the default
scope lookup order as set by IPreferencesService.setDefaultLookupOrder(String, String, String[]).
The specified key may either refer to a simple key or be the concatenation of the path of a child node and key. If the key contains a slash ("/") character, then a double-slash must be used to denote the end of they child path and the beginning of the key. Otherwise it is assumed that the key is the last segment of the path. The following are some examples of keys and their meanings:
The scope look-up order is determined by the preference service default lookup order, not by the order of the scope contexts that are being passed in. The context objects are only consulted to help determine which nodes to look in, not the order of the nodes.
Callers may specify an array of scope context objects to aid in the determination of the correct nodes. For each entry in the lookup order, the array of contexts is consulted and if one matching the scope exists, then it is used to calculate the node. Otherwise a default calculation algorithm is used.
An example of a qualifier for an Eclipse 2.1 preference is the plug-in identifier. (e.g. "org.eclipse.core.resources" for "description.autobuild")
getFloat in interface IPreferencesServicequalifier - a namespace qualifier for the preferencekey - the name of the preference (optionally including its path)defaultValue - the value to use if the preference is not definedscopes - optional context objects to help scopes determine which nodes to search, or nullIScopeContext,
IPreferencesService.get(java.lang.String, java.lang.String, org.osgi.service.prefs.Preferences[]),
IPreferencesService.getLookupOrder(java.lang.String, java.lang.String),
IPreferencesService.getDefaultLookupOrder(java.lang.String, java.lang.String)public int getInt(java.lang.String qualifier,
java.lang.String key,
int defaultValue,
IScopeContext[] scopes)
IPreferencesService
The semantics of this method are to calculate the appropriate
Preferences nodes in the preference hierarchy to use
and then call the IPreferencesService.get(String, String, Preferences[])
method. The order of the nodes is calculated by consulting the default
scope lookup order as set by IPreferencesService.setDefaultLookupOrder(String, String, String[]).
The specified key may either refer to a simple key or be the concatenation of the path of a child node and key. If the key contains a slash ("/") character, then a double-slash must be used to denote the end of they child path and the beginning of the key. Otherwise it is assumed that the key is the last segment of the path. The following are some examples of keys and their meanings:
The scope look-up order is determined by the preference service default lookup order, not by the order of the scope contexts that are being passed in. The context objects are only consulted to help determine which nodes to look in, not the order of the nodes.
Callers may specify an array of scope context objects to aid in the determination of the correct nodes. For each entry in the lookup order, the array of contexts is consulted and if one matching the scope exists, then it is used to calculate the node. Otherwise a default calculation algorithm is used.
An example of a qualifier for an Eclipse 2.1 preference is the plug-in identifier. (e.g. "org.eclipse.core.resources" for "description.autobuild")
getInt in interface IPreferencesServicequalifier - a namespace qualifier for the preferencekey - the name of the preference (optionally including its path)defaultValue - the value to use if the preference is not definedscopes - optional context objects to help scopes determine which nodes to search, or nullIScopeContext,
IPreferencesService.get(java.lang.String, java.lang.String, org.osgi.service.prefs.Preferences[]),
IPreferencesService.getLookupOrder(java.lang.String, java.lang.String),
IPreferencesService.getDefaultLookupOrder(java.lang.String, java.lang.String)public long getLong(java.lang.String qualifier,
java.lang.String key,
long defaultValue,
IScopeContext[] scopes)
IPreferencesService
The semantics of this method are to calculate the appropriate
Preferences nodes in the preference hierarchy to use
and then call the IPreferencesService.get(String, String, Preferences[])
method. The order of the nodes is calculated by consulting the default
scope lookup order as set by IPreferencesService.setDefaultLookupOrder(String, String, String[]).
The specified key may either refer to a simple key or be the concatenation of the path of a child node and key. If the key contains a slash ("/") character, then a double-slash must be used to denote the end of they child path and the beginning of the key. Otherwise it is assumed that the key is the last segment of the path. The following are some examples of keys and their meanings:
The scope look-up order is determined by the preference service default lookup order, not by the order of the scope contexts that are being passed in. The context objects are only consulted to help determine which nodes to look in, not the order of the nodes.
Callers may specify an array of scope context objects to aid in the determination of the correct nodes. For each entry in the lookup order, the array of contexts is consulted and if one matching the scope exists, then it is used to calculate the node. Otherwise a default calculation algorithm is used.
An example of a qualifier for an Eclipse 2.1 preference is the plug-in identifier. (e.g. "org.eclipse.core.resources" for "description.autobuild")
getLong in interface IPreferencesServicequalifier - a namespace qualifier for the preferencekey - the name of the preference (optionally including its path)defaultValue - the value to use if the preference is not definedscopes - optional context objects to help scopes determine which nodes to search, or nullIScopeContext,
IPreferencesService.get(java.lang.String, java.lang.String, org.osgi.service.prefs.Preferences[]),
IPreferencesService.getLookupOrder(java.lang.String, java.lang.String),
IPreferencesService.getDefaultLookupOrder(java.lang.String, java.lang.String)public java.lang.String[] getLookupOrder(java.lang.String qualifier,
java.lang.String key)
IPreferencesService
First do an exact match lookup with the given qualifier and simple name. If a match
is found then return it. Otherwise if the key is non-null then
do a lookup based on only the qualifier and return the set value.
Return the default-default order as defined by the platform if no order has been set.
getLookupOrder in interface IPreferencesServicequalifier - the namespace qualifier for the preferencekey - the preference name or nullIPreferencesService.getDefaultLookupOrder(String, String),
IPreferencesService.setDefaultLookupOrder(String, String, String[])public IEclipsePreferences getRootNode()
IPreferencesServicegetRootNode in interface IPreferencesServicepublic java.lang.String getString(java.lang.String qualifier,
java.lang.String key,
java.lang.String defaultValue,
IScopeContext[] scopes)
IPreferencesService
The semantics of this method are to calculate the appropriate
Preferences nodes in the preference hierarchy to use
and then call the IPreferencesService.get(String, String, Preferences[])
method. The order of the nodes is calculated by consulting the default
scope lookup order as set by IPreferencesService.setDefaultLookupOrder(String, String, String[]).
The specified key may either refer to a simple key or be the concatenation of the path of a child node and key. If the key contains a slash ("/") character, then a double-slash must be used to denote the end of they child path and the beginning of the key. Otherwise it is assumed that the key is the last segment of the path. The following are some examples of keys and their meanings:
The scope look-up order is determined by the preference service default lookup order, not by the order of the scope contexts that are being passed in. The context objects are only consulted to help determine which nodes to look in, not the order of the nodes.
Callers may specify an array of scope context objects to aid in the determination of the correct nodes. For each entry in the lookup order, the array of contexts is consulted and if one matching the scope exists, then it is used to calculate the node. Otherwise a default calculation algorithm is used.
An example of a qualifier for an Eclipse 2.1 preference is the plug-in identifier. (e.g. "org.eclipse.core.resources" for "description.autobuild")
getString in interface IPreferencesServicequalifier - a namespace qualifier for the preferencekey - the name of the preference (optionally including its path)defaultValue - the value to use if the preference is not definedscopes - optional context objects to help scopes determine which nodes to search, or nullIScopeContext,
IPreferencesService.get(java.lang.String, java.lang.String, org.osgi.service.prefs.Preferences[]),
IPreferencesService.getLookupOrder(java.lang.String, java.lang.String),
IPreferencesService.getDefaultLookupOrder(java.lang.String, java.lang.String)public IStatus importPreferences(java.io.InputStream input)
throws CoreException
IPreferencesServicenull and is closed upon return from this method.
This file must have been written by the
IPreferencesService.exportPreferences(IEclipsePreferences, OutputStream, String[])
method.
This method is equivalent to calling applyPreferences(readPreferences(input));.
importPreferences in interface IPreferencesServiceinput - the stream to load the preferences fromCoreException - if there are problems importing the preferencesIPreferencesService.exportPreferences(IEclipsePreferences, OutputStream, String[])public IPreferenceFilter[] matches(IEclipsePreferences tree, IPreferenceFilter[] filters) throws CoreException
IPreferencesServicenull, empty, or there
are no matches, then return an empty list.matches in interface IPreferencesServicetree - the tree to match againstfilters - the list of filters to match againstCoreExceptionIPreferenceFilterpublic IExportedPreferences readPreferences(java.io.InputStream input) throws CoreException
IPreferencesServicenull. The result of this function is suitable
for passing as an argument to IPreferencesService.applyPreferences(IExportedPreferences).
It is assumed the contents of the input stream have been written by
IPreferencesService.exportPreferences(IEclipsePreferences, OutputStream, String[]).
readPreferences in interface IPreferencesServiceinput - the input stream to read fromCoreException - if there are problems reading the preferencesIPreferencesService.exportPreferences(IEclipsePreferences, OutputStream, String[]),
IPreferencesService.applyPreferences(IExportedPreferences)public void setDefaultLookupOrder(java.lang.String qualifier,
java.lang.String key,
java.lang.String[] order)
IPreferencesServicenull then the set
ordering (if it exists) is removed.
If the given simple name is null then set the given lookup
order to be used for all keys with the given qualifier.
Note that the default lookup order is not persisted across platform invocations.
setDefaultLookupOrder in interface IPreferencesServicequalifier - the namespace qualifier for the preferencekey - the preference name or nullorder - the lookup order or nullIPreferencesService.getDefaultLookupOrder(String, String)public void setRegistryHelper(java.lang.Object registryHelper)
public IStatus validateVersions(IPath path)
public java.lang.String[] getDefaultDefaultLookupOrder()
public void setDefaultDefaultLookupOrder(java.lang.String[] order)