Package com.globalmentor.util.prefs
Class PreferencesUtilities
- java.lang.Object
-
- com.globalmentor.util.prefs.PreferencesUtilities
-
public class PreferencesUtilities extends java.lang.Object
Utilities methods for working with preferences.- Author:
- Garret Wilson
-
-
Field Summary
Fields Modifier and Type Field Description protected static char
PATH_SEPARATOR
The character used to separate elements in preference paths.
-
Constructor Summary
Constructors Constructor Description PreferencesUtilities()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static java.lang.String
getNodeName(java.lang.Class<?> c)
Deterines the absolute path name of the node corresponding to the specified class.static java.lang.String
getPreferenceName(java.lang.Class<?> c, java.lang.String name)
Constructs a name for a preference based upon a given class and preference name, in the form "classname.name".static java.util.prefs.Preferences
getUserNodeForClass(java.lang.Class<?> c)
Returns the preference node from the calling user's preference tree that is associated with this class relative to the package node (i.e.
-
-
-
Field Detail
-
PATH_SEPARATOR
protected static final char PATH_SEPARATOR
The character used to separate elements in preference paths.- See Also:
- Constant Field Values
-
-
Method Detail
-
getPreferenceName
public static final java.lang.String getPreferenceName(java.lang.Class<?> c, java.lang.String name)
Constructs a name for a preference based upon a given class and preference name, in the form "classname.name".- Parameters:
c
- The class the lowercase local name of which will be used in constructing the name.name
- The locall name of the preference.- Returns:
- A name suitable for storing the preference for the class.
-
getUserNodeForClass
public static java.util.prefs.Preferences getUserNodeForClass(java.lang.Class<?> c)
Returns the preference node from the calling user's preference tree that is associated with this class relative to the package node (i.e. packageNode/classNode).- Parameters:
c
- The class for which a user preference node is desired.- Returns:
- The user preference node associated with the class.
- Throws:
java.lang.NullPointerException
- if c isnull
.java.lang.SecurityException
- if a security manager is present and it deniesRuntimePermission("preferences")
.- See Also:
RuntimePermission
-
getNodeName
protected static java.lang.String getNodeName(java.lang.Class<?> c)
Deterines the absolute path name of the node corresponding to the specified class. This is implemented to use the entire class name with every occurence of '.' replaced with '/'. Implemented by consulting java.util.prefs.Preferences.java 1.25 04/06/21 by Josh Bloch.- Parameters:
c
- The class for which a node name should be returned.- Returns:
- The absolute path name of the node corresponding to the specified class.
- Throws:
java.lang.IllegalArgumentException
- if the package has no node preferences node associated with it.
-
-