PTP
Release 5.0

org.eclipse.ptp.remote.core
Class Preferences

java.lang.Object
  extended by org.eclipse.ptp.remote.core.Preferences

public final class Preferences
extends java.lang.Object

Convenience class to facilitate using the new IEclipsePreferences story. Adapted from org.eclipse.debug.internal.core.Preferences.

Since:
5.0

Method Summary
static void addPreferenceChangeListener(java.lang.String qualifier, org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener listener)
          Adds the given preference listener to the DefaultScope and the InstanceScope
static boolean contains(java.lang.String qualifier, java.lang.String name)
          Returns whether the named preference is know in the preference store.
static boolean getBoolean(java.lang.String qualifier, java.lang.String key)
          Returns the value in the preference store for the given key.
static byte[] getByteArray(java.lang.String qualifier, java.lang.String key)
          Returns the value in the preference store for the given key.
static boolean getDefaultBoolean(java.lang.String qualifier, java.lang.String key, boolean defaultvalue)
          Returns the default boolean value stored in the DefaultScope for the given key or the specified default value if the key does not appear in the DefaultScope
static byte[] getDefaultByteArray(java.lang.String qualifier, java.lang.String key, byte[] defaultvalue)
          Returns the default byte array value stored in the DefaultScope for the given key or the specified default value if the key does not appear in the DefaultScope
static double getDefaultDouble(java.lang.String qualifier, java.lang.String key, double defaultvalue)
          Returns the default double value stored in the DefaultScope for the given key or the specified default value if the key does not appear in the DefaultScope
static float getDefaultFloat(java.lang.String qualifier, java.lang.String key, float defaultvalue)
          Returns the default float value stored in the DefaultScope for the given key or the specified default value if the key does not appear in the DefaultScope
static int getDefaultInt(java.lang.String qualifier, java.lang.String key, int defaultvalue)
          Returns the default integer value stored in the DefaultScope for the given key or the specified default value if the key does not appear in the DefaultScope
static long getDefaultLong(java.lang.String qualifier, java.lang.String key, long defaultvalue)
          Returns the default long value stored in the DefaultScope for the given key or the specified default value if the key does not appear in the DefaultScope
static java.lang.String getDefaultString(java.lang.String qualifier, java.lang.String key, java.lang.String defaultvalue)
          Returns the default string value stored in the DefaultScope for the given key or the specified default value if the key does not appear in the DefaultScope
static double getDouble(java.lang.String qualifier, java.lang.String key)
          Returns the value in the preference store for the given key.
static float getFloat(java.lang.String qualifier, java.lang.String key)
          Returns the value in the preference store for the given key.
static int getInt(java.lang.String qualifier, java.lang.String key)
          Returns the value in the preference store for the given key.
static long getLong(java.lang.String qualifier, java.lang.String key)
          Returns the value in the preference store for the given key.
static java.lang.String getString(java.lang.String qualifier, java.lang.String key)
          Returns the value in the preference store for the given key.
static boolean isDefault(java.lang.String qualifier, java.lang.String name)
          Returns true if the named preference has the default value.
static void removePreferenceChangeListener(java.lang.String qualifier, org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener listener)
          Removes the given preference listener from the DefaultScope and the InstanceScope
static void savePreferences(java.lang.String qualifier)
          Save the preferences for the given plugin identifier.
static void setBoolean(java.lang.String qualifier, java.lang.String key, boolean value)
          Sets a boolean preference in the InstanceScope.
static void setByteArray(java.lang.String qualifier, java.lang.String key, byte[] value)
          Sets a byte array preference in the InstanceScope.
static void setDefaultBoolean(java.lang.String qualifier, java.lang.String key, boolean value)
          Sets a boolean in the DefaultScope
static void setDefaultByteArray(java.lang.String qualifier, java.lang.String key, byte[] value)
          Sets a byte array in the DefaultScope
static void setDefaultDouble(java.lang.String qualifier, java.lang.String key, double value)
          Sets a double in the DefaultScope
static void setDefaultFloat(java.lang.String qualifier, java.lang.String key, float value)
          Sets a float in the DefaultScope
static void setDefaultInt(java.lang.String qualifier, java.lang.String key, int value)
          Sets a integer in the DefaultScope
static void setDefaultLong(java.lang.String qualifier, java.lang.String key, long value)
          Sets a long in the DefaultScope
static void setDefaultString(java.lang.String qualifier, java.lang.String key, java.lang.String value)
          Sets a string in the DefaultScope
static void setDouble(java.lang.String qualifier, java.lang.String key, double value)
          Sets a double preference in the InstanceScope.
static void setFloat(java.lang.String qualifier, java.lang.String key, float value)
          Sets a float preference in the InstanceScope.
static void setInt(java.lang.String qualifier, java.lang.String key, int value)
          Sets a integer preference in the InstanceScope.
static void setLong(java.lang.String qualifier, java.lang.String key, long value)
          Sets a long preference in the InstanceScope.
static void setString(java.lang.String qualifier, java.lang.String key, java.lang.String value)
          Sets a string preference in the InstanceScope.
static void setToDefault(java.lang.String qualifier, java.lang.String key)
          Sets the given preference to its default value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

addPreferenceChangeListener

public static void addPreferenceChangeListener(java.lang.String qualifier,
                                               org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener listener)
Adds the given preference listener to the DefaultScope and the InstanceScope

Parameters:
qualifier -
listener -

contains

public static boolean contains(java.lang.String qualifier,
                               java.lang.String name)
Returns whether the named preference is know in the preference store.

Parameters:
qualifier -
name -
Returns:

getBoolean

public static boolean getBoolean(java.lang.String qualifier,
                                 java.lang.String key)
Returns the value in the preference store for the given key. If the key is not defined then return the default value. Use the canonical scope lookup order for finding the preference value.

Parameters:
qualifier -
key -
defaultvalue -
Returns:
the value of the preference or the given default value

getByteArray

public static byte[] getByteArray(java.lang.String qualifier,
                                  java.lang.String key)
Returns the value in the preference store for the given key. If the key is not defined then return the default value. Use the canonical scope lookup order for finding the preference value.

Parameters:
qualifier -
key -
defaultvalue -
Returns:
the value of the preference or the given default value

getDefaultBoolean

public static boolean getDefaultBoolean(java.lang.String qualifier,
                                        java.lang.String key,
                                        boolean defaultvalue)
Returns the default boolean value stored in the DefaultScope for the given key or the specified default value if the key does not appear in the DefaultScope

Parameters:
qualifier -
key -
defaultvalue -
Returns:
the boolean value set in the DefaultScope for the given key, or the specified default value.

getDefaultByteArray

public static byte[] getDefaultByteArray(java.lang.String qualifier,
                                         java.lang.String key,
                                         byte[] defaultvalue)
Returns the default byte array value stored in the DefaultScope for the given key or the specified default value if the key does not appear in the DefaultScope

Parameters:
qualifier -
key -
defaultvalue -
Returns:
the byte array value set in the DefaultScope for the given key, or the specified default value.

getDefaultDouble

public static double getDefaultDouble(java.lang.String qualifier,
                                      java.lang.String key,
                                      double defaultvalue)
Returns the default double value stored in the DefaultScope for the given key or the specified default value if the key does not appear in the DefaultScope

Parameters:
qualifier -
key -
defaultvalue -
Returns:
the double value set in the DefaultScope for the given key, or the specified default value.

getDefaultFloat

public static float getDefaultFloat(java.lang.String qualifier,
                                    java.lang.String key,
                                    float defaultvalue)
Returns the default float value stored in the DefaultScope for the given key or the specified default value if the key does not appear in the DefaultScope

Parameters:
qualifier -
key -
defaultvalue -
Returns:
the float value set in the DefaultScope for the given key, or the specified default value.

getDefaultInt

public static int getDefaultInt(java.lang.String qualifier,
                                java.lang.String key,
                                int defaultvalue)
Returns the default integer value stored in the DefaultScope for the given key or the specified default value if the key does not appear in the DefaultScope

Parameters:
qualifier -
key -
defaultvalue -
Returns:
the integer value set in the DefaultScope for the given key, or the specified default value.

getDefaultLong

public static long getDefaultLong(java.lang.String qualifier,
                                  java.lang.String key,
                                  long defaultvalue)
Returns the default long value stored in the DefaultScope for the given key or the specified default value if the key does not appear in the DefaultScope

Parameters:
qualifier -
key -
defaultvalue -
Returns:
the long value set in the DefaultScope for the given key, or the specified default value.

getDefaultString

public static java.lang.String getDefaultString(java.lang.String qualifier,
                                                java.lang.String key,
                                                java.lang.String defaultvalue)
Returns the default string value stored in the DefaultScope for the given key or the specified default value if the key does not appear in the DefaultScope

Parameters:
qualifier -
key -
defaultvalue -
Returns:
the string value set in the DefaultScope for the given key, or the specified default value.

getDouble

public static double getDouble(java.lang.String qualifier,
                               java.lang.String key)
Returns the value in the preference store for the given key. If the key is not defined then return the default value. Use the canonical scope lookup order for finding the preference value.

Parameters:
qualifier -
key -
defaultvalue -
Returns:
the value of the preference or the given default value

getFloat

public static float getFloat(java.lang.String qualifier,
                             java.lang.String key)
Returns the value in the preference store for the given key. If the key is not defined then return the default value. Use the canonical scope lookup order for finding the preference value.

Parameters:
qualifier -
key -
defaultvalue -
Returns:
the value of the preference or the given default value

getInt

public static int getInt(java.lang.String qualifier,
                         java.lang.String key)
Returns the value in the preference store for the given key. If the key is not defined then return the default value. Use the canonical scope lookup order for finding the preference value.

Parameters:
qualifier -
key -
defaultvalue -
Returns:
the value of the preference or the given default value

getLong

public static long getLong(java.lang.String qualifier,
                           java.lang.String key)
Returns the value in the preference store for the given key. If the key is not defined then return the default value. Use the canonical scope lookup order for finding the preference value.

Parameters:
qualifier -
key -
defaultvalue -
Returns:
the value of the preference or the given default value

getString

public static java.lang.String getString(java.lang.String qualifier,
                                         java.lang.String key)
Returns the value in the preference store for the given key. If the key is not defined then return the default value. Use the canonical scope lookup order for finding the preference value.

Parameters:
qualifier -
key -
defaultvalue -
Returns:
the value of the preference or the given default value

isDefault

public static boolean isDefault(java.lang.String qualifier,
                                java.lang.String name)
Returns true if the named preference has the default value.

Parameters:
qualifier -
name -
Returns:

removePreferenceChangeListener

public static void removePreferenceChangeListener(java.lang.String qualifier,
                                                  org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener listener)
Removes the given preference listener from the DefaultScope and the InstanceScope

Parameters:
qualifier -
listener -

savePreferences

public static void savePreferences(java.lang.String qualifier)
Save the preferences for the given plugin identifier. It should be noted that all pending preference changes will be flushed with this method.

Parameters:
qualifier -

setBoolean

public static void setBoolean(java.lang.String qualifier,
                              java.lang.String key,
                              boolean value)
Sets a boolean preference in the InstanceScope.

Parameters:
qualifier -
key - the key
value - the value

setByteArray

public static void setByteArray(java.lang.String qualifier,
                                java.lang.String key,
                                byte[] value)
Sets a byte array preference in the InstanceScope.

Parameters:
qualifier -
key - the key
value - the value

setDefaultBoolean

public static void setDefaultBoolean(java.lang.String qualifier,
                                     java.lang.String key,
                                     boolean value)
Sets a boolean in the DefaultScope

Parameters:
qualifier -
key - the key
value - the new value

setDefaultByteArray

public static void setDefaultByteArray(java.lang.String qualifier,
                                       java.lang.String key,
                                       byte[] value)
Sets a byte array in the DefaultScope

Parameters:
qualifier -
key - the key
value - the new value

setDefaultDouble

public static void setDefaultDouble(java.lang.String qualifier,
                                    java.lang.String key,
                                    double value)
Sets a double in the DefaultScope

Parameters:
qualifier -
key - the key
value - the new value

setDefaultFloat

public static void setDefaultFloat(java.lang.String qualifier,
                                   java.lang.String key,
                                   float value)
Sets a float in the DefaultScope

Parameters:
qualifier -
key - the key
value - the new value

setDefaultInt

public static void setDefaultInt(java.lang.String qualifier,
                                 java.lang.String key,
                                 int value)
Sets a integer in the DefaultScope

Parameters:
qualifier -
key - the key
value - the new value

setDefaultLong

public static void setDefaultLong(java.lang.String qualifier,
                                  java.lang.String key,
                                  long value)
Sets a long in the DefaultScope

Parameters:
qualifier -
key - the key
value - the new value

setDefaultString

public static void setDefaultString(java.lang.String qualifier,
                                    java.lang.String key,
                                    java.lang.String value)
Sets a string in the DefaultScope

Parameters:
qualifier -
key - the key
value - the new value

setDouble

public static void setDouble(java.lang.String qualifier,
                             java.lang.String key,
                             double value)
Sets a double preference in the InstanceScope.

Parameters:
qualifier -
key - the key
value - the value

setFloat

public static void setFloat(java.lang.String qualifier,
                            java.lang.String key,
                            float value)
Sets a float preference in the InstanceScope.

Parameters:
qualifier -
key - the key
value - the value

setInt

public static void setInt(java.lang.String qualifier,
                          java.lang.String key,
                          int value)
Sets a integer preference in the InstanceScope.

Parameters:
qualifier -
key - the key
value - the value

setLong

public static void setLong(java.lang.String qualifier,
                           java.lang.String key,
                           long value)
Sets a long preference in the InstanceScope.

Parameters:
qualifier -
key - the key
value - the value

setString

public static void setString(java.lang.String qualifier,
                             java.lang.String key,
                             java.lang.String value)
Sets a string preference in the InstanceScope.

Parameters:
qualifier -
key - the key
value - the value

setToDefault

public static void setToDefault(java.lang.String qualifier,
                                java.lang.String key)
Sets the given preference to its default value. This is done by removing any set value from the InstanceScope. Has no effect if the given key is null.

Parameters:
qualifier -
key - the key for the preference

PTP
Release 5.0

Copyright (c) 2011 IBM Corporation and others. All Rights Reserved.