Java Doc for AbstractPreferences.java in  » 6.0-JDK-Core » Collections-Jar-Zip-Logging-regex » java » util » prefs » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » Collections Jar Zip Logging regex » java.util.prefs 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.util.prefs.Preferences
      java.util.prefs.AbstractPreferences

AbstractPreferences
abstract public class AbstractPreferences extends Preferences (Code)
This class provides a skeletal implementation of the Preferences class, greatly easing the task of implementing it.

This class is for Preferences implementers only. Normal users of the Preferences facility should have no need to consult this documentation. The Preferences documentation should suffice.

Implementors must override the nine abstract service-provider interface (SPI) methods: AbstractPreferences.getSpi(String) , AbstractPreferences.putSpi(String,String) , AbstractPreferences.removeSpi(String) , AbstractPreferences.childSpi(String) , AbstractPreferences.removeNodeSpi() , AbstractPreferences.keysSpi() , AbstractPreferences.childrenNamesSpi() , AbstractPreferences.syncSpi() and AbstractPreferences.flushSpi() . All of the concrete methods specify precisely how they are implemented atop these SPI methods. The implementor may, at his discretion, override one or more of the concrete methods if the default implementation is unsatisfactory for any reason, such as performance.

The SPI methods fall into three groups concerning exception behavior. The getSpi method should never throw exceptions, but it doesn't really matter, as any exception thrown by this method will be intercepted by AbstractPreferences.get(String,String) , which will return the specified default value to the caller. The removeNodeSpi, keysSpi, childrenNamesSpi, syncSpi and flushSpi methods are specified to throw BackingStoreException , and the implementation is required to throw this checked exception if it is unable to perform the operation. The exception propagates outward, causing the corresponding API method to fail.

The remaining SPI methods AbstractPreferences.putSpi(String,String) , AbstractPreferences.removeSpi(String) and AbstractPreferences.childSpi(String) have more complicated exception behavior. They are not specified to throw BackingStoreException, as they can generally obey their contracts even if the backing store is unavailable. This is true because they return no information and their effects are not required to become permanent until a subsequent call to Preferences.flush or Preferences.sync . Generally speaking, these SPI methods should not throw exceptions. In some implementations, there may be circumstances under which these calls cannot even enqueue the requested operation for later processing. Even under these circumstances it is generally better to simply ignore the invocation and return, rather than throwing an exception. Under these circumstances, however, all subsequent invocations of flush() and sync should return false, as returning true would imply that all previous operations had successfully been made permanent.

There is one circumstance under which putSpi, removeSpi and childSpi should throw an exception: if the caller lacks sufficient privileges on the underlying operating system to perform the requested operation. This will, for instance, occur on most systems if a non-privileged user attempts to modify system preferences. (The required privileges will vary from implementation to implementation. On some implementations, they are the right to modify the contents of some directory in the file system; on others they are the right to modify contents of some key in a registry.) Under any of these circumstances, it would generally be undesirable to let the program continue executing as if these operations would become permanent at a later time. While implementations are not required to throw an exception under these circumstances, they are encouraged to do so. A SecurityException would be appropriate.

Most of the SPI methods require the implementation to read or write information at a preferences node. The implementor should beware of the fact that another VM may have concurrently deleted this node from the backing store. It is the implementation's responsibility to recreate the node if it has been deleted.

Implementation note: In Sun's default Preferences implementations, the user's identity is inherited from the underlying operating system and does not change for the lifetime of the virtual machine. It is recognized that server-side Preferences implementations may have the user identity change from request to request, implicitly passed to Preferences methods via the use of a static ThreadLocal instance. Authors of such implementations are strongly encouraged to determine the user at the time preferences are accessed (for example by the AbstractPreferences.get(String,String) or AbstractPreferences.put(String,String) method) rather than permanently associating a user with each Preferences instance. The latter behavior conflicts with normal Preferences usage and would lead to great confusion.
author:
   Josh Bloch
version:
   1.32, 05/05/07
See Also:   Preferences
since:
   1.4



Field Summary
final protected  Objectlock
     An object whose monitor is used to lock this node.
protected  booleannewNode
     This field should be true if this node did not exist in the backing store prior to the creation of this object.
final  AbstractPreferencesparent
     Our parent node.

Constructor Summary
protected  AbstractPreferences(AbstractPreferences parent, String name)
     Creates a preference node with the specified parent and the specified name relative to its parent.
Parameters:
  parent - the parent of this preference node, or null if thisis the root.
Parameters:
  name - the name of this preference node, relative to its parent,or "" if this is the root.
throws:
  IllegalArgumentException - if name contains a slash('/'), or parent is null andname isn't "".

Method Summary
public  StringabsolutePath()
     Implements the absolutePath method as per the specification in Preferences.absolutePath .
public  voidaddNodeChangeListener(NodeChangeListener ncl)
    
public  voidaddPreferenceChangeListener(PreferenceChangeListener pcl)
    
final protected  AbstractPreferences[]cachedChildren()
     Returns all known unremoved children of this node.
abstract protected  AbstractPreferenceschildSpi(String name)
     Returns the named child of this preference node, creating it if it does not already exist.
public  String[]childrenNames()
     Implements the children method as per the specification in Preferences.childrenNames .

This implementation obtains this preference node's lock, checks that the node has not been removed, constructs a TreeSet initialized to the names of children already cached (the children in this node's "child-cache"), invokes AbstractPreferences.childrenNamesSpi() , and adds all of the returned child-names into the set.

abstract protected  String[]childrenNamesSpi()
     Returns the names of the children of this preference node.
public  voidclear()
     Implements the clear method as per the specification in Preferences.clear .
public  voidexportNode(OutputStream os)
     Implements the exportNode method as per the specification in Preferences.exportNode(OutputStream) .
public  voidexportSubtree(OutputStream os)
     Implements the exportSubtree method as per the specification in Preferences.exportSubtree(OutputStream) .
public  voidflush()
     Implements the flush method as per the specification in Preferences.flush .

This implementation calls a recursive helper method that locks this node, invokes flushSpi() on it, unlocks this node, and recursively invokes this method on each "cached child." A cached child is a child of this node that has been created in this VM and not subsequently removed.

abstract protected  voidflushSpi()
     This method is invoked with this node locked.
public  Stringget(String key, String def)
     Implements the get method as per the specification in Preferences.get(StringString) .

This implementation first checks to see if key is null throwing a NullPointerException if this is the case.

public  booleangetBoolean(String key, boolean def)
     Implements the getBoolean method as per the specification in Preferences.getBoolean(Stringboolean) .

This implementation invokes AbstractPreferences.get(String,String) get(key,null) .

public  byte[]getByteArray(String key, byte[] def)
     Implements the getByteArray method as per the specification in Preferences.getByteArray(Stringbyte[]) .
Parameters:
  key - key whose associated value is to be returned as a byte array.
Parameters:
  def - the value to be returned in the event that thispreference node has no value associated with keyor the associated value cannot be interpreted as a byte array.
protected  AbstractPreferencesgetChild(String nodeName)
     Returns the named child if it exists, or null if it does not. It is guaranteed that nodeName is non-null, non-empty, does not contain the slash character ('/'), and is no longer than AbstractPreferences.MAX_NAME_LENGTH characters.
public  doublegetDouble(String key, double def)
     Implements the getDouble method as per the specification in Preferences.getDouble(Stringdouble) .

This implementation invokes AbstractPreferences.get(String,String) get(key,null) .

public  floatgetFloat(String key, float def)
     Implements the getFloat method as per the specification in Preferences.getFloat(Stringfloat) .

This implementation invokes AbstractPreferences.get(String,String) get(key,null) .

public  intgetInt(String key, int def)
     Implements the getInt method as per the specification in Preferences.getInt(Stringint) .

This implementation invokes AbstractPreferences.get(String,String) get(key,null) .

public  longgetLong(String key, long def)
     Implements the getLong method as per the specification in Preferences.getLong(Stringlong) .

This implementation invokes AbstractPreferences.get(String,String) get(key,null) .

abstract protected  StringgetSpi(String key)
     Return the value associated with the specified key at this preference node, or null if there is no association for this key, or the association cannot be determined at this time.
protected  booleanisRemoved()
     Returns true iff this node (or an ancestor) has been removed with the AbstractPreferences.removeNode() method.
public  booleanisUserNode()
     Implements the isUserNode method as per the specification in Preferences.isUserNode .

This implementation compares this node's root node (which is stored in a private field) with the value returned by Preferences.userRoot .

public  String[]keys()
     Implements the keys method as per the specification in Preferences.keys .
abstract protected  String[]keysSpi()
     Returns all of the keys that have an associated value in this preference node.
public  Stringname()
     Implements the name method as per the specification in Preferences.name .
public  Preferencesnode(String path)
     Implements the node method as per the specification in Preferences.node(String) .

This implementation obtains this preference node's lock and checks that the node has not been removed.

public  booleannodeExists(String path)
     Implements the nodeExists method as per the specification in Preferences.nodeExists(String) .

This implementation is very similar to AbstractPreferences.node(String) , except that AbstractPreferences.getChild(String) is used instead of AbstractPreferences.childSpi(String) .
Parameters:
  path - the path name of the node whose existence is to be checked.

 NodeChangeListener[]nodeListeners()
    
public  Preferencesparent()
     Implements the parent method as per the specification in Preferences.parent .
 PreferenceChangeListener[]prefListeners()
     Return this node's preference/node change listeners.
public  voidput(String key, String value)
     Implements the put method as per the specification in Preferences.put(StringString) .
public  voidputBoolean(String key, boolean value)
     Implements the putBoolean method as per the specification in Preferences.putBoolean(Stringboolean) .
public  voidputByteArray(String key, byte[] value)
     Implements the putByteArray method as per the specification in Preferences.putByteArray(Stringbyte[]) .
public  voidputDouble(String key, double value)
     Implements the putDouble method as per the specification in Preferences.putDouble(Stringdouble) .
public  voidputFloat(String key, float value)
     Implements the putFloat method as per the specification in Preferences.putFloat(Stringfloat) .
public  voidputInt(String key, int value)
     Implements the putInt method as per the specification in Preferences.putInt(Stringint) .
public  voidputLong(String key, long value)
     Implements the putLong method as per the specification in Preferences.putLong(Stringlong) .
abstract protected  voidputSpi(String key, String value)
     Put the given key-value association into this preference node.
public  voidremove(String key)
     Implements the remove(String) method as per the specification in Preferences.remove(String) .
public  voidremoveNode()
     Implements the removeNode() method as per the specification in Preferences.removeNode .

This implementation checks to see that this node is the root; if so, it throws an appropriate exception.

public  voidremoveNodeChangeListener(NodeChangeListener ncl)
    
abstract protected  voidremoveNodeSpi()
     Removes this preference node, invalidating it and any preferences that it contains.
public  voidremovePreferenceChangeListener(PreferenceChangeListener pcl)
    
abstract protected  voidremoveSpi(String key)
     Remove the association (if any) for the specified key at this preference node.
public  voidsync()
     Implements the sync method as per the specification in Preferences.sync .

This implementation calls a recursive helper method that locks this node, invokes syncSpi() on it, unlocks this node, and recursively invokes this method on each "cached child." A cached child is a child of this node that has been created in this VM and not subsequently removed.

abstract protected  voidsyncSpi()
     This method is invoked with this node locked.
public  StringtoString()
     Returns the absolute path name of this preferences node.

Field Detail
lock
final protected Object lock(Code)
An object whose monitor is used to lock this node. This object is used in preference to the node itself to reduce the likelihood of intentional or unintentional denial of service due to a locked node. To avoid deadlock, a node is never locked by a thread that holds a lock on a descendant of that node.



newNode
protected boolean newNode(Code)
This field should be true if this node did not exist in the backing store prior to the creation of this object. The field is initialized to false, but may be set to true by a subclass constructor (and should not be modified thereafter). This field indicates whether a node change event should be fired when creation is complete.



parent
final AbstractPreferences parent(Code)
Our parent node.




Constructor Detail
AbstractPreferences
protected AbstractPreferences(AbstractPreferences parent, String name)(Code)
Creates a preference node with the specified parent and the specified name relative to its parent.
Parameters:
  parent - the parent of this preference node, or null if thisis the root.
Parameters:
  name - the name of this preference node, relative to its parent,or "" if this is the root.
throws:
  IllegalArgumentException - if name contains a slash('/'), or parent is null andname isn't "".




Method Detail
absolutePath
public String absolutePath()(Code)
Implements the absolutePath method as per the specification in Preferences.absolutePath .

This implementation merely returns the absolute path name that was computed at the time that this node was constructed (based on the name that was passed to this node's constructor, and the names that were passed to this node's ancestors' constructors). this preference node's absolute path name.




addNodeChangeListener
public void addNodeChangeListener(NodeChangeListener ncl)(Code)



addPreferenceChangeListener
public void addPreferenceChangeListener(PreferenceChangeListener pcl)(Code)



cachedChildren
final protected AbstractPreferences[] cachedChildren()(Code)
Returns all known unremoved children of this node. all known unremoved children of this node.



childSpi
abstract protected AbstractPreferences childSpi(String name)(Code)
Returns the named child of this preference node, creating it if it does not already exist. It is guaranteed that name is non-null, non-empty, does not contain the slash character ('/'), and is no longer than AbstractPreferences.MAX_NAME_LENGTH characters. Also, it is guaranteed that this node has not been removed. (The implementor needn't check for any of these things.)

Finally, it is guaranteed that the named node has not been returned by a previous invocation of this method or AbstractPreferences.getChild(String) after the last time that it was removed. In other words, a cached value will always be used in preference to invoking this method. Subclasses need not maintain their own cache of previously returned children.

The implementer must ensure that the returned node has not been removed. If a like-named child of this node was previously removed, the implementer must return a newly constructed AbstractPreferences node; once removed, an AbstractPreferences node cannot be "resuscitated."

If this method causes a node to be created, this node is not guaranteed to be persistent until the flush method is invoked on this node or one of its ancestors (or descendants).

This method is invoked with the lock on this node held.
Parameters:
  name - The name of the child node to return, relative tothis preference node. The named child node.




childrenNames
public String[] childrenNames() throws BackingStoreException(Code)
Implements the children method as per the specification in Preferences.childrenNames .

This implementation obtains this preference node's lock, checks that the node has not been removed, constructs a TreeSet initialized to the names of children already cached (the children in this node's "child-cache"), invokes AbstractPreferences.childrenNamesSpi() , and adds all of the returned child-names into the set. The elements of the tree set are dumped into a String array using the toArray method, and this array is returned. the names of the children of this preference node.
throws:
  BackingStoreException - if this operation cannot be completeddue to a failure in the backing store, or inability to communicate with it.
throws:
  IllegalStateException - if this node (or an ancestor) has beenremoved with the AbstractPreferences.removeNode() method.
See Also:   AbstractPreferences.cachedChildren()




childrenNamesSpi
abstract protected String[] childrenNamesSpi() throws BackingStoreException(Code)
Returns the names of the children of this preference node. (The returned array will be of size zero if this node has no children.) This method need not return the names of any nodes already cached, but may do so without harm.

This method is invoked with the lock on this node held.

If this node throws a BackingStoreException, the exception will propagate out beyond the enclosing AbstractPreferences.childrenNames() invocation. an array containing the names of the children of thispreference node.
throws:
  BackingStoreException - if this operation cannot be completeddue to a failure in the backing store, or inability to communicate with it.




clear
public void clear() throws BackingStoreException(Code)
Implements the clear method as per the specification in Preferences.clear .

This implementation obtains this preference node's lock, invokes AbstractPreferences.keys() to obtain an array of keys, and iterates over the array invoking AbstractPreferences.remove(String) on each key.
throws:
  BackingStoreException - if this operation cannot be completeddue to a failure in the backing store, or inability to communicate with it.
throws:
  IllegalStateException - if this node (or an ancestor) has beenremoved with the AbstractPreferences.removeNode() method.




exportNode
public void exportNode(OutputStream os) throws IOException, BackingStoreException(Code)
Implements the exportNode method as per the specification in Preferences.exportNode(OutputStream) .
Parameters:
  os - the output stream on which to emit the XML document.
throws:
  IOException - if writing to the specified output streamresults in an IOException.
throws:
  BackingStoreException - if preference data cannot be read frombacking store.



exportSubtree
public void exportSubtree(OutputStream os) throws IOException, BackingStoreException(Code)
Implements the exportSubtree method as per the specification in Preferences.exportSubtree(OutputStream) .
Parameters:
  os - the output stream on which to emit the XML document.
throws:
  IOException - if writing to the specified output streamresults in an IOException.
throws:
  BackingStoreException - if preference data cannot be read frombacking store.



flush
public void flush() throws BackingStoreException(Code)
Implements the flush method as per the specification in Preferences.flush .

This implementation calls a recursive helper method that locks this node, invokes flushSpi() on it, unlocks this node, and recursively invokes this method on each "cached child." A cached child is a child of this node that has been created in this VM and not subsequently removed. In effect, this method does a depth first traversal of the "cached subtree" rooted at this node, calling flushSpi() on each node in the subTree while only that node is locked. Note that flushSpi() is invoked top-down.

If this method is invoked on a node that has been removed with the AbstractPreferences.removeNode() method, flushSpi() is invoked on this node, but not on others.
throws:
  BackingStoreException - if this operation cannot be completeddue to a failure in the backing store, or inability to communicate with it.
See Also:   AbstractPreferences.flush()




flushSpi
abstract protected void flushSpi() throws BackingStoreException(Code)
This method is invoked with this node locked. The contract of this method is to force any cached changes in the contents of this preference node to the backing store, guaranteeing their persistence. (It is perfectly possible that this node does not exist on the backing store, either because it has been deleted by another VM, or because it has not yet been created.) Note that this method should not flush the preferences in any subnodes of this node. If the backing store naturally flushes an entire subtree at once, the implementer is encouraged to override flush(), rather than merely overriding this method.

If this node throws a BackingStoreException, the exception will propagate out beyond the enclosing AbstractPreferences.flush() invocation.
throws:
  BackingStoreException - if this operation cannot be completeddue to a failure in the backing store, or inability to communicate with it.




get
public String get(String key, String def)(Code)
Implements the get method as per the specification in Preferences.get(StringString) .

This implementation first checks to see if key is null throwing a NullPointerException if this is the case. Then it obtains this preference node's lock, checks that the node has not been removed, invokes AbstractPreferences.getSpi(String) , and returns the result, unless the getSpi invocation returns null or throws an exception, in which case this invocation returns def.
Parameters:
  key - key whose associated value is to be returned.
Parameters:
  def - the value to be returned in the event that thispreference node has no value associated with key. the value associated with key, or defif no value is associated with key.
throws:
  IllegalStateException - if this node (or an ancestor) has beenremoved with the AbstractPreferences.removeNode() method.
throws:
  NullPointerException - if key is null. (A null default is permitted.)




getBoolean
public boolean getBoolean(String key, boolean def)(Code)
Implements the getBoolean method as per the specification in Preferences.getBoolean(Stringboolean) .

This implementation invokes AbstractPreferences.get(String,String) get(key,null) . If the return value is non-null, it is compared with "true" using String.equalsIgnoreCase(String) . If the comparison returns true, this invocation returns true. Otherwise, the original return value is compared with "false", again using String.equalsIgnoreCase(String) . If the comparison returns true, this invocation returns false. Otherwise, this invocation returns def.
Parameters:
  key - key whose associated value is to be returned as a boolean.
Parameters:
  def - the value to be returned in the event that thispreference node has no value associated with keyor the associated value cannot be interpreted as a boolean. the boolean value represented by the string associated withkey in this preference node, or def if theassociated value does not exist or cannot be interpreted asa boolean.
throws:
  IllegalStateException - if this node (or an ancestor) has beenremoved with the AbstractPreferences.removeNode() method.
throws:
  NullPointerException - if key is null.




getByteArray
public byte[] getByteArray(String key, byte[] def)(Code)
Implements the getByteArray method as per the specification in Preferences.getByteArray(Stringbyte[]) .
Parameters:
  key - key whose associated value is to be returned as a byte array.
Parameters:
  def - the value to be returned in the event that thispreference node has no value associated with keyor the associated value cannot be interpreted as a byte array. the byte array value represented by the string associated withkey in this preference node, or def if theassociated value does not exist or cannot be interpreted asa byte array.
throws:
  IllegalStateException - if this node (or an ancestor) has beenremoved with the AbstractPreferences.removeNode() method.
throws:
  NullPointerException - if key is null. (A null value for def is permitted.)



getChild
protected AbstractPreferences getChild(String nodeName) throws BackingStoreException(Code)
Returns the named child if it exists, or null if it does not. It is guaranteed that nodeName is non-null, non-empty, does not contain the slash character ('/'), and is no longer than AbstractPreferences.MAX_NAME_LENGTH characters. Also, it is guaranteed that this node has not been removed. (The implementor needn't check for any of these things if he chooses to override this method.)

Finally, it is guaranteed that the named node has not been returned by a previous invocation of this method or AbstractPreferences.childSpi after the last time that it was removed. In other words, a cached value will always be used in preference to invoking this method. (The implementor needn't maintain his own cache of previously returned children if he chooses to override this method.)

This implementation obtains this preference node's lock, invokes AbstractPreferences.childrenNames() to get an array of the names of this node's children, and iterates over the array comparing the name of each child with the specified node name. If a child node has the correct name, the AbstractPreferences.childSpi(String) method is invoked and the resulting node is returned. If the iteration completes without finding the specified name, null is returned.
Parameters:
  nodeName - name of the child to be searched for. the named child if it exists, or null if it does not.
throws:
  BackingStoreException - if this operation cannot be completeddue to a failure in the backing store, or inability to communicate with it.




getDouble
public double getDouble(String key, double def)(Code)
Implements the getDouble method as per the specification in Preferences.getDouble(Stringdouble) .

This implementation invokes AbstractPreferences.get(String,String) get(key,null) . If the return value is non-null, the implementation attempts to translate it to an double with Double.parseDouble(String) . If the attempt succeeds, the return value is returned by this method. Otherwise, def is returned.
Parameters:
  key - key whose associated value is to be returned as a double.
Parameters:
  def - the value to be returned in the event that thispreference node has no value associated with keyor the associated value cannot be interpreted as a double. the double value represented by the string associated withkey in this preference node, or def if theassociated value does not exist or cannot be interpreted asa double.
throws:
  IllegalStateException - if this node (or an ancestor) has beenremoved with the AbstractPreferences.removeNode() method.
throws:
  NullPointerException - if key is null.




getFloat
public float getFloat(String key, float def)(Code)
Implements the getFloat method as per the specification in Preferences.getFloat(Stringfloat) .

This implementation invokes AbstractPreferences.get(String,String) get(key,null) . If the return value is non-null, the implementation attempts to translate it to an float with Float.parseFloat(String) . If the attempt succeeds, the return value is returned by this method. Otherwise, def is returned.
Parameters:
  key - key whose associated value is to be returned as a float.
Parameters:
  def - the value to be returned in the event that thispreference node has no value associated with keyor the associated value cannot be interpreted as a float. the float value represented by the string associated withkey in this preference node, or def if theassociated value does not exist or cannot be interpreted asa float.
throws:
  IllegalStateException - if this node (or an ancestor) has beenremoved with the AbstractPreferences.removeNode() method.
throws:
  NullPointerException - if key is null.




getInt
public int getInt(String key, int def)(Code)
Implements the getInt method as per the specification in Preferences.getInt(Stringint) .

This implementation invokes AbstractPreferences.get(String,String) get(key,null) . If the return value is non-null, the implementation attempts to translate it to an int with Integer.parseInt(String) . If the attempt succeeds, the return value is returned by this method. Otherwise, def is returned.
Parameters:
  key - key whose associated value is to be returned as an int.
Parameters:
  def - the value to be returned in the event that thispreference node has no value associated with keyor the associated value cannot be interpreted as an int. the int value represented by the string associated withkey in this preference node, or def if theassociated value does not exist or cannot be interpreted asan int.
throws:
  IllegalStateException - if this node (or an ancestor) has beenremoved with the AbstractPreferences.removeNode() method.
throws:
  NullPointerException - if key is null.




getLong
public long getLong(String key, long def)(Code)
Implements the getLong method as per the specification in Preferences.getLong(Stringlong) .

This implementation invokes AbstractPreferences.get(String,String) get(key,null) . If the return value is non-null, the implementation attempts to translate it to a long with Long.parseLong(String) . If the attempt succeeds, the return value is returned by this method. Otherwise, def is returned.
Parameters:
  key - key whose associated value is to be returned as a long.
Parameters:
  def - the value to be returned in the event that thispreference node has no value associated with keyor the associated value cannot be interpreted as a long. the long value represented by the string associated withkey in this preference node, or def if theassociated value does not exist or cannot be interpreted asa long.
throws:
  IllegalStateException - if this node (or an ancestor) has beenremoved with the AbstractPreferences.removeNode() method.
throws:
  NullPointerException - if key is null.




getSpi
abstract protected String getSpi(String key)(Code)
Return the value associated with the specified key at this preference node, or null if there is no association for this key, or the association cannot be determined at this time. It is guaranteed that key is non-null. Also, it is guaranteed that this node has not been removed. (The implementor needn't check for either of these things.)

Generally speaking, this method should not throw an exception under any circumstances. If, however, if it does throw an exception, the exception will be intercepted and treated as a null return value.

This method is invoked with the lock on this node held. the value associated with the specified key at this preferencenode, or null if there is no association for thiskey, or the association cannot be determined at this time.




isRemoved
protected boolean isRemoved()(Code)
Returns true iff this node (or an ancestor) has been removed with the AbstractPreferences.removeNode() method. This method locks this node prior to returning the contents of the private field used to track this state. true iff this node (or an ancestor) has beenremoved with the AbstractPreferences.removeNode() method.



isUserNode
public boolean isUserNode()(Code)
Implements the isUserNode method as per the specification in Preferences.isUserNode .

This implementation compares this node's root node (which is stored in a private field) with the value returned by Preferences.userRoot . If the two object references are identical, this method returns true. true if this preference node is in the userpreference tree, false if it's in the systempreference tree.




keys
public String[] keys() throws BackingStoreException(Code)
Implements the keys method as per the specification in Preferences.keys .

This implementation obtains this preference node's lock, checks that the node has not been removed and invokes AbstractPreferences.keysSpi() . an array of the keys that have an associated value in thispreference node.
throws:
  BackingStoreException - if this operation cannot be completeddue to a failure in the backing store, or inability to communicate with it.
throws:
  IllegalStateException - if this node (or an ancestor) has beenremoved with the AbstractPreferences.removeNode() method.




keysSpi
abstract protected String[] keysSpi() throws BackingStoreException(Code)
Returns all of the keys that have an associated value in this preference node. (The returned array will be of size zero if this node has no preferences.) It is guaranteed that this node has not been removed.

This method is invoked with the lock on this node held.

If this node throws a BackingStoreException, the exception will propagate out beyond the enclosing AbstractPreferences.keys() invocation. an array of the keys that have an associated value in thispreference node.
throws:
  BackingStoreException - if this operation cannot be completeddue to a failure in the backing store, or inability to communicate with it.




name
public String name()(Code)
Implements the name method as per the specification in Preferences.name .

This implementation merely returns the name that was passed to this node's constructor. this preference node's name, relative to its parent.




node
public Preferences node(String path)(Code)
Implements the node method as per the specification in Preferences.node(String) .

This implementation obtains this preference node's lock and checks that the node has not been removed. If path is "", this node is returned; if path is "/", this node's root is returned. If the first character in path is not '/', the implementation breaks path into tokens and recursively traverses the path from this node to the named node, "consuming" a name and a slash from path at each step of the traversal. At each step, the current node is locked and the node's child-cache is checked for the named node. If it is not found, the name is checked to make sure its length does not exceed MAX_NAME_LENGTH. Then the AbstractPreferences.childSpi(String) method is invoked, and the result stored in this node's child-cache. If the newly created Preferences object's AbstractPreferences.newNode field is true and there are any node change listeners, a notification event is enqueued for processing by the event dispatch thread.

When there are no more tokens, the last value found in the child-cache or returned by childSpi is returned by this method. If during the traversal, two "/" tokens occur consecutively, or the final token is "/" (rather than a name), an appropriate IllegalArgumentException is thrown.

If the first character of path is '/' (indicating an absolute path name) this preference node's lock is dropped prior to breaking path into tokens, and this method recursively traverses the path starting from the root (rather than starting from this node). The traversal is otherwise identical to the one described for relative path names. Dropping the lock on this node prior to commencing the traversal at the root node is essential to avoid the possibility of deadlock, as per the AbstractPreferences.lock locking invariant .
Parameters:
  path - the path name of the preference node to return. the specified preference node.
throws:
  IllegalArgumentException - if the path name is invalid (i.e.,it contains multiple consecutive slash characters, or endswith a slash character and is more than one character long).
throws:
  IllegalStateException - if this node (or an ancestor) has beenremoved with the AbstractPreferences.removeNode() method.




nodeExists
public boolean nodeExists(String path) throws BackingStoreException(Code)
Implements the nodeExists method as per the specification in Preferences.nodeExists(String) .

This implementation is very similar to AbstractPreferences.node(String) , except that AbstractPreferences.getChild(String) is used instead of AbstractPreferences.childSpi(String) .
Parameters:
  path - the path name of the node whose existence is to be checked. true if the specified node exists.
throws:
  BackingStoreException - if this operation cannot be completeddue to a failure in the backing store, or inability to communicate with it.
throws:
  IllegalArgumentException - if the path name is invalid (i.e.,it contains multiple consecutive slash characters, or endswith a slash character and is more than one character long).
throws:
  IllegalStateException - if this node (or an ancestor) has beenremoved with the AbstractPreferences.removeNode() method andpathname is not the empty string ("").




nodeListeners
NodeChangeListener[] nodeListeners()(Code)



parent
public Preferences parent()(Code)
Implements the parent method as per the specification in Preferences.parent .

This implementation obtains this preference node's lock, checks that the node has not been removed and returns the parent value that was passed to this node's constructor. the parent of this preference node.
throws:
  IllegalStateException - if this node (or an ancestor) has beenremoved with the AbstractPreferences.removeNode() method.




prefListeners
PreferenceChangeListener[] prefListeners()(Code)
Return this node's preference/node change listeners. Even though we're using a copy-on-write lists, we use synchronized accessors to ensure information transmission from the writing thread to the reading thread.



put
public void put(String key, String value)(Code)
Implements the put method as per the specification in Preferences.put(StringString) .

This implementation checks that the key and value are legal, obtains this preference node's lock, checks that the node has not been removed, invokes AbstractPreferences.putSpi(String,String) , and if there are any preference change listeners, enqueues a notification event for processing by the event dispatch thread.
Parameters:
  key - key with which the specified value is to be associated.
Parameters:
  value - value to be associated with the specified key.
throws:
  NullPointerException - if key or value is null.
throws:
  IllegalArgumentException - if key.length() exceedsMAX_KEY_LENGTH or if value.length exceedsMAX_VALUE_LENGTH.
throws:
  IllegalStateException - if this node (or an ancestor) has beenremoved with the AbstractPreferences.removeNode() method.




putBoolean
public void putBoolean(String key, boolean value)(Code)
Implements the putBoolean method as per the specification in Preferences.putBoolean(Stringboolean) .

This implementation translates value to a string with String.valueOf(boolean) and invokes AbstractPreferences.put(String,String) on the result.
Parameters:
  key - key with which the string form of value is to be associated.
Parameters:
  value - value whose string form is to be associated with key.
throws:
  NullPointerException - if key is null.
throws:
  IllegalArgumentException - if key.length() exceedsMAX_KEY_LENGTH.
throws:
  IllegalStateException - if this node (or an ancestor) has beenremoved with the AbstractPreferences.removeNode() method.




putByteArray
public void putByteArray(String key, byte[] value)(Code)
Implements the putByteArray method as per the specification in Preferences.putByteArray(Stringbyte[]) .
Parameters:
  key - key with which the string form of value is to be associated.
Parameters:
  value - value whose string form is to be associated with key.
throws:
  NullPointerException - if key or value is null.
throws:
  IllegalArgumentException - if key.length() exceeds MAX_KEY_LENGTHor if value.length exceeds MAX_VALUE_LENGTH*3/4.
throws:
  IllegalStateException - if this node (or an ancestor) has beenremoved with the AbstractPreferences.removeNode() method.



putDouble
public void putDouble(String key, double value)(Code)
Implements the putDouble method as per the specification in Preferences.putDouble(Stringdouble) .

This implementation translates value to a string with Double.toString(double) and invokes AbstractPreferences.put(String,String) on the result.
Parameters:
  key - key with which the string form of value is to be associated.
Parameters:
  value - value whose string form is to be associated with key.
throws:
  NullPointerException - if key is null.
throws:
  IllegalArgumentException - if key.length() exceedsMAX_KEY_LENGTH.
throws:
  IllegalStateException - if this node (or an ancestor) has beenremoved with the AbstractPreferences.removeNode() method.




putFloat
public void putFloat(String key, float value)(Code)
Implements the putFloat method as per the specification in Preferences.putFloat(Stringfloat) .

This implementation translates value to a string with Float.toString(float) and invokes AbstractPreferences.put(String,String) on the result.
Parameters:
  key - key with which the string form of value is to be associated.
Parameters:
  value - value whose string form is to be associated with key.
throws:
  NullPointerException - if key is null.
throws:
  IllegalArgumentException - if key.length() exceedsMAX_KEY_LENGTH.
throws:
  IllegalStateException - if this node (or an ancestor) has beenremoved with the AbstractPreferences.removeNode() method.




putInt
public void putInt(String key, int value)(Code)
Implements the putInt method as per the specification in Preferences.putInt(Stringint) .

This implementation translates value to a string with Integer.toString(int) and invokes AbstractPreferences.put(String,String) on the result.
Parameters:
  key - key with which the string form of value is to be associated.
Parameters:
  value - value whose string form is to be associated with key.
throws:
  NullPointerException - if key is null.
throws:
  IllegalArgumentException - if key.length() exceedsMAX_KEY_LENGTH.
throws:
  IllegalStateException - if this node (or an ancestor) has beenremoved with the AbstractPreferences.removeNode() method.




putLong
public void putLong(String key, long value)(Code)
Implements the putLong method as per the specification in Preferences.putLong(Stringlong) .

This implementation translates value to a string with Long.toString(long) and invokes AbstractPreferences.put(String,String) on the result.
Parameters:
  key - key with which the string form of value is to be associated.
Parameters:
  value - value whose string form is to be associated with key.
throws:
  NullPointerException - if key is null.
throws:
  IllegalArgumentException - if key.length() exceedsMAX_KEY_LENGTH.
throws:
  IllegalStateException - if this node (or an ancestor) has beenremoved with the AbstractPreferences.removeNode() method.




putSpi
abstract protected void putSpi(String key, String value)(Code)
Put the given key-value association into this preference node. It is guaranteed that key and value are non-null and of legal length. Also, it is guaranteed that this node has not been removed. (The implementor needn't check for any of these things.)

This method is invoked with the lock on this node held.




remove
public void remove(String key)(Code)
Implements the remove(String) method as per the specification in Preferences.remove(String) .

This implementation obtains this preference node's lock, checks that the node has not been removed, invokes AbstractPreferences.removeSpi(String) and if there are any preference change listeners, enqueues a notification event for processing by the event dispatch thread.
Parameters:
  key - key whose mapping is to be removed from the preference node.
throws:
  IllegalStateException - if this node (or an ancestor) has beenremoved with the AbstractPreferences.removeNode() method.




removeNode
public void removeNode() throws BackingStoreException(Code)
Implements the removeNode() method as per the specification in Preferences.removeNode .

This implementation checks to see that this node is the root; if so, it throws an appropriate exception. Then, it locks this node's parent, and calls a recursive helper method that traverses the subtree rooted at this node. The recursive method locks the node on which it was called, checks that it has not already been removed, and then ensures that all of its children are cached: The AbstractPreferences.childrenNamesSpi() method is invoked and each returned child name is checked for containment in the child-cache. If a child is not already cached, the AbstractPreferences.childSpi(String) method is invoked to create a Preferences instance for it, and this instance is put into the child-cache. Then the helper method calls itself recursively on each node contained in its child-cache. Next, it invokes AbstractPreferences.removeNodeSpi() , marks itself as removed, and removes itself from its parent's child-cache. Finally, if there are any node change listeners, it enqueues a notification event for processing by the event dispatch thread.

Note that the helper method is always invoked with all ancestors up to the "closest non-removed ancestor" locked.
throws:
  IllegalStateException - if this node (or an ancestor) has alreadybeen removed with the AbstractPreferences.removeNode() method.
throws:
  UnsupportedOperationException - if this method is invoked on the root node.
throws:
  BackingStoreException - if this operation cannot be completeddue to a failure in the backing store, or inability to communicate with it.




removeNodeChangeListener
public void removeNodeChangeListener(NodeChangeListener ncl)(Code)



removeNodeSpi
abstract protected void removeNodeSpi() throws BackingStoreException(Code)
Removes this preference node, invalidating it and any preferences that it contains. The named child will have no descendants at the time this invocation is made (i.e., the Preferences.removeNode method invokes this method repeatedly in a bottom-up fashion, removing each of a node's descendants before removing the node itself).

This method is invoked with the lock held on this node and its parent (and all ancestors that are being removed as a result of a single invocation to Preferences.removeNode ).

The removal of a node needn't become persistent until the flush method is invoked on this node (or an ancestor).

If this node throws a BackingStoreException, the exception will propagate out beyond the enclosing AbstractPreferences.removeNode() invocation.
throws:
  BackingStoreException - if this operation cannot be completeddue to a failure in the backing store, or inability to communicate with it.




removePreferenceChangeListener
public void removePreferenceChangeListener(PreferenceChangeListener pcl)(Code)



removeSpi
abstract protected void removeSpi(String key)(Code)
Remove the association (if any) for the specified key at this preference node. It is guaranteed that key is non-null. Also, it is guaranteed that this node has not been removed. (The implementor needn't check for either of these things.)

This method is invoked with the lock on this node held.




sync
public void sync() throws BackingStoreException(Code)
Implements the sync method as per the specification in Preferences.sync .

This implementation calls a recursive helper method that locks this node, invokes syncSpi() on it, unlocks this node, and recursively invokes this method on each "cached child." A cached child is a child of this node that has been created in this VM and not subsequently removed. In effect, this method does a depth first traversal of the "cached subtree" rooted at this node, calling syncSpi() on each node in the subTree while only that node is locked. Note that syncSpi() is invoked top-down.
throws:
  BackingStoreException - if this operation cannot be completeddue to a failure in the backing store, or inability to communicate with it.
throws:
  IllegalStateException - if this node (or an ancestor) has beenremoved with the AbstractPreferences.removeNode() method.
See Also:   AbstractPreferences.flush()




syncSpi
abstract protected void syncSpi() throws BackingStoreException(Code)
This method is invoked with this node locked. The contract of this method is to synchronize any cached preferences stored at this node with any stored in the backing store. (It is perfectly possible that this node does not exist on the backing store, either because it has been deleted by another VM, or because it has not yet been created.) Note that this method should not synchronize the preferences in any subnodes of this node. If the backing store naturally syncs an entire subtree at once, the implementer is encouraged to override sync(), rather than merely overriding this method.

If this node throws a BackingStoreException, the exception will propagate out beyond the enclosing AbstractPreferences.sync() invocation.
throws:
  BackingStoreException - if this operation cannot be completeddue to a failure in the backing store, or inability to communicate with it.




toString
public String toString()(Code)
Returns the absolute path name of this preferences node.



Fields inherited from java.util.prefs.Preferences
final public static int MAX_KEY_LENGTH(Code)(Java Doc)
final public static int MAX_NAME_LENGTH(Code)(Java Doc)
final public static int MAX_VALUE_LENGTH(Code)(Java Doc)

Methods inherited from java.util.prefs.Preferences
abstract public String absolutePath()(Code)(Java Doc)
abstract public void addNodeChangeListener(NodeChangeListener ncl)(Code)(Java Doc)
abstract public void addPreferenceChangeListener(PreferenceChangeListener pcl)(Code)(Java Doc)
abstract public String[] childrenNames() throws BackingStoreException(Code)(Java Doc)
abstract public void clear() throws BackingStoreException(Code)(Java Doc)
abstract public void exportNode(OutputStream os) throws IOException, BackingStoreException(Code)(Java Doc)
abstract public void exportSubtree(OutputStream os) throws IOException, BackingStoreException(Code)(Java Doc)
abstract public void flush() throws BackingStoreException(Code)(Java Doc)
abstract public String get(String key, String def)(Code)(Java Doc)
abstract public boolean getBoolean(String key, boolean def)(Code)(Java Doc)
abstract public byte[] getByteArray(String key, byte[] def)(Code)(Java Doc)
abstract public double getDouble(String key, double def)(Code)(Java Doc)
abstract public float getFloat(String key, float def)(Code)(Java Doc)
abstract public int getInt(String key, int def)(Code)(Java Doc)
abstract public long getLong(String key, long def)(Code)(Java Doc)
public static void importPreferences(InputStream is) throws IOException, InvalidPreferencesFormatException(Code)(Java Doc)
abstract public boolean isUserNode()(Code)(Java Doc)
abstract public String[] keys() throws BackingStoreException(Code)(Java Doc)
abstract public String name()(Code)(Java Doc)
abstract public Preferences node(String pathName)(Code)(Java Doc)
abstract public boolean nodeExists(String pathName) throws BackingStoreException(Code)(Java Doc)
abstract public Preferences parent()(Code)(Java Doc)
abstract public void put(String key, String value)(Code)(Java Doc)
abstract public void putBoolean(String key, boolean value)(Code)(Java Doc)
abstract public void putByteArray(String key, byte[] value)(Code)(Java Doc)
abstract public void putDouble(String key, double value)(Code)(Java Doc)
abstract public void putFloat(String key, float value)(Code)(Java Doc)
abstract public void putInt(String key, int value)(Code)(Java Doc)
abstract public void putLong(String key, long value)(Code)(Java Doc)
abstract public void remove(String key)(Code)(Java Doc)
abstract public void removeNode() throws BackingStoreException(Code)(Java Doc)
abstract public void removeNodeChangeListener(NodeChangeListener ncl)(Code)(Java Doc)
abstract public void removePreferenceChangeListener(PreferenceChangeListener pcl)(Code)(Java Doc)
abstract public void sync() throws BackingStoreException(Code)(Java Doc)
public static Preferences systemNodeForPackage(Class c)(Code)(Java Doc)
public static Preferences systemRoot()(Code)(Java Doc)
abstract public String toString()(Code)(Java Doc)
public static Preferences userNodeForPackage(Class c)(Code)(Java Doc)
public static Preferences userRoot()(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.