![]() |
The Java Developers Almanac 1.4Order this book from Amazon. |
e413. Retrieving a Preference NodeA preference node can be retrieved using aClass object or by a
string. When using a Class object to retrieve a preference node, the
package containing the Class object identifies the node.
It is important to note that these methods also automatically create the node if it doesn't exist. Since nodes take up resources, even when empty, you should avoid creating unnecessary nodes. See e415 Determining If a Preference Node Exists for information on how to avoid creating nodes. The string used to retrieve a preference node is called a path
and resembles a file path. For example, the path for the preference
node associated with the package Paths that begin with ` // System preference nodes // Use a Class Preferences prefs = Preferences.systemNodeForPackage(java.lang.String.class); // Use an absolute path prefs = Preferences.systemRoot().node("/java/lang/String"); // Use a relative path prefs = Preferences.systemRoot().node("/javax/swing"); prefs = prefs.node("text/html"); // User preference nodes // Use a class prefs = Preferences.userNodeForPackage(com.mycompany.MyClass.class); // Use an absolute path prefs = Preferences.userRoot().node("/com/mycompany"); // Use a relative path prefs = Preferences.userRoot().node("/javax/swing"); prefs = prefs.node("text/html");
e412. Creating a Preference Node e414. Removing a Preference Node e415. Determining If a Preference Node Exists e416. Retrieving the Parent and Child Nodes of a Preference Node e417. Finding a Preference in a Preference Tree
© 2002 Addison-Wesley. |