API Overview API Index Package Overview Direct link to this page
JDK 1.6
  java.util.prefs. Preferences View Source
Author(s)
Josh Bloch
Since
1.4
Version
1.30, 06/26/06
Serial
Hierarchy
 Object
      Preferences
Implements
Subclasses
Description
publicabstract abstract class Preferences
  A node in a hierarchical collection of preference data.
See also:   
Constructors
protected Preferences ()
  Sole constructor.
Methods
Hide/Show inherited methods
publicabstract String absolutePath ()
  Returns this preference node's absolute path name.
publicabstract void addNodeChangeListener (NodeChangeListener ncl)
  Registers the specified listener to receive node change events for this node.
publicabstract void addPreferenceChangeListener (PreferenceChangeListener pcl)
  Registers the specified listener to receive preference change events for this preference node.
publicabstract String childrenNames () throws BackingStoreException
  Returns the names of the children of this preference node, relative to this node.
publicabstract void clear () throws BackingStoreException
  Removes all of the preferences (key-value associations) in this preference node.
publicabstract void exportNode (OutputStream os) throws IOException BackingStoreException
  Emits on the specified output stream an XML document representing all of the preferences contained in this node (but not its descendants).
publicabstract void exportSubtree (OutputStream os) throws IOException BackingStoreException
  Emits an XML document representing all of the preferences contained in this node and all of its descendants.
publicabstract void flush () throws BackingStoreException
  Forces any changes in the contents of this preference node and its descendants to the persistent store.
publicabstract String get (String key, String def)
  Returns the value associated with the specified key in this preference node.
publicabstract boolean getBoolean (String key, boolean def)
  Returns the boolean value represented by the string associated with the specified key in this preference node.
publicabstract byte getByteArray (String key, byte[] def)
  Returns the byte array value represented by the string associated with the specified key in this preference node.
publicabstract double getDouble (String key, double def)
  Returns the double value represented by the string associated with the specified key in this preference node.
publicabstract float getFloat (String key, float def)
  Returns the float value represented by the string associated with the specified key in this preference node.
publicabstract int getInt (String key, int def)
  Returns the int value represented by the string associated with the specified key in this preference node.
publicabstract long getLong (String key, long def)
  Returns the long value represented by the string associated with the specified key in this preference node.
publicstatic void importPreferences (InputStream is) throws IOException InvalidPreferencesFormatException
  Imports all of the preferences represented by the XML document on the specified input stream.
publicabstract boolean isUserNode ()
  Returns true if this preference node is in the user preference tree, false if it's in the system preference tree.
publicabstract String keys () throws BackingStoreException
  Returns all of the keys that have an associated value in this preference node.
publicabstract String name ()
  Returns this preference node's name, relative to its parent.
publicabstract Preferences node (String pathName)
  Returns the named preference node in the same tree as this node, creating it and any of its ancestors if they do not already exist.
publicabstract boolean nodeExists (String pathName) throws BackingStoreException
  Returns true if the named preference node exists in the same tree as this node.
publicabstract Preferences parent ()
  Returns the parent of this preference node, or null if this is the root.
publicabstract void put (String key, String value)
  Associates the specified value with the specified key in this preference node.
publicabstract void putBoolean (String key, boolean value)
  Associates a string representing the specified boolean value with the specified key in this preference node.
publicabstract void putByteArray (String key, byte[] value)
  Associates a string representing the specified byte array with the specified key in this preference node.
publicabstract void putDouble (String key, double value)
  Associates a string representing the specified double value with the specified key in this preference node.
publicabstract void putFloat (String key, float value)
  Associates a string representing the specified float value with the specified key in this preference node.
publicabstract void putInt (String key, int value)
  Associates a string representing the specified int value with the specified key in this preference node.
publicabstract void putLong (String key, long value)
  Associates a string representing the specified long value with the specified key in this preference node.
publicabstract void remove (String key)
  Removes the value associated with the specified key in this preference node, if any.
publicabstract void removeNode () throws BackingStoreException
  Removes this preference node and all of its descendants, invalidating any preferences contained in the removed nodes.
publicabstract void removeNodeChangeListener (NodeChangeListener ncl)
  Removes the specified NodeChangeListener, so it no longer receives change events.
publicabstract void removePreferenceChangeListener (PreferenceChangeListener pcl)
  Removes the specified preference change listener, so it no longer receives preference change events.
publicabstract void sync () throws BackingStoreException
  Ensures that future reads from this preference node and its descendants reflect any changes that were committed to the persistent store (from any VM) prior to the sync invocation.
publicstatic Preferences systemNodeForPackage (Class<Object> c)
  Returns the preference node from the system preference tree that is associated (by convention) with the specified class's package.
publicstatic Preferences systemRoot ()
  Returns the root preference node for the system.
publicabstract String toString ()
Returns a string representation of this preferences node, as if computed by the expression:(this.isUserNode() ? "User" : "System") + " Preference Node: " + this.absolutePath().
publicstatic Preferences userNodeForPackage (Class<Object> c)
  Returns the preference node from the calling user's preference tree that is associated (by convention) with the specified class's package.
publicstatic Preferences userRoot ()
  Returns the root preference node for the calling user.
Fields
Hide/Show inherited fields
publicfinalstatic int MAX_KEY_LENGTH = "80"
Maximum length of string allowed as a key (80 characters).
publicfinalstatic int MAX_NAME_LENGTH = "80"
Maximum length of a node name (80 characters).
publicfinalstatic int MAX_VALUE_LENGTH = "8192"
Maximum length of string allowed as a value (8192 characters).
Nested Classes
Generated By: JavaOnTracks Doclet 0.1.4     ©Thibaut Colar