Author: ndbeyer
Date: Thu Jan 1 18:52:34 2009
New Revision: 730659
URL: http://svn.apache.org/viewvc?rev=730659&view=rev
Log:
format code, replace tabs with spaces - no functional changes
Modified:
harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/BackingStoreException.java
harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/FilePreferencesImpl.java
harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/InvalidPreferencesFormatException.java
harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/NodeChangeEvent.java
harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/NodeChangeListener.java
harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/PreferenceChangeEvent.java
harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/PreferenceChangeListener.java
harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/Preferences.java
harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/PreferencesFactory.java
harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/RegistryPreferencesFactoryImpl.java
harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/RegistryPreferencesImpl.java
harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/XMLParser.java
harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/AllTests.java
harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/AbstractPreferencesTest.java
harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/AllTests.java
harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/FilePreferencesImplTest.java
harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/InvalidPreferencesFormatExceptionTest.java
harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/MockAbstractPreferences.java
harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/MockPreferencesFactory.java
harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/MockSecurityManager.java
harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/NodeChangeListenerTest.java
harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferenceChangeEventTest.java
harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferenceChangeListenerTest.java
harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferencesFactoryTest.java
harmony/enhanced/classlib/trunk/modules/prefs/src/test/java/org/apache/harmony/prefs/tests/java/util/prefs/PreferencesTest.java
Modified: harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/BackingStoreException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/BackingStoreException.java?rev=730659&r1=730658&r2=730659&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/BackingStoreException.java (original)
+++ harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/BackingStoreException.java Thu Jan 1 18:52:34 2009
@@ -17,7 +17,6 @@
package java.util.prefs;
-
/**
* An exception to indicate that some error was encountered while accessing
* the backing store.
@@ -25,29 +24,26 @@
* @since 1.4
*/
public class BackingStoreException extends Exception {
-
+
private static final long serialVersionUID = 859796500401108469L;
-
- /**
- * Constructs a new
- * This XML document has the following DOCTYPE declaration:
- * BackingStoreException instance using an
- * exception message.
- *
- * @param s the exception message.
- */
- public BackingStoreException (String s) {
- super(s);
- }
- /**
- * Constructs a new BackingStoreException instance using a
- * nested Throwable instance.
- *
- * @param t the nested Throwable instance.
- */
- public BackingStoreException (Throwable t) {
- super(t);
- }
+ /**
+ * Constructs a new BackingStoreException instance using an
+ * exception message.
+ *
+ * @param s the exception message.
+ */
+ public BackingStoreException (String s) {
+ super(s);
+ }
+
+ /**
+ * Constructs a new BackingStoreException instance using a
+ * nested Throwable instance.
+ *
+ * @param t the nested Throwable instance.
+ */
+ public BackingStoreException (Throwable t) {
+ super(t);
+ }
}
-
-
-
Modified: harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/FilePreferencesImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/FilePreferencesImpl.java?rev=730659&r1=730658&r2=730659&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/FilePreferencesImpl.java (original)
+++ harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/FilePreferencesImpl.java Thu Jan 1 18:52:34 2009
@@ -97,7 +97,7 @@
* Constructors
* --------------------------------------------------------------
*/
-
+
/**
* Construct root FilePreferencesImpl instance, construct
* user root if userNode is true, system root otherwise
@@ -108,7 +108,7 @@
path = userNode ? USER_HOME : SYSTEM_HOME;
initPrefs();
}
-
+
/**
* Construct a prefs using given parent and given name
*/
@@ -132,16 +132,16 @@
@Override
protected String[] childrenNamesSpi() throws BackingStoreException {
String[] names = AccessController
- .doPrivileged(new PrivilegedActionInvalidPreferencesFormatException instance using an
- * exception message.
- *
- * @param s the exception message.
- */
- public InvalidPreferencesFormatException (String s) {
- super(s);
- }
-
- /**
- * Constructs a new InvalidPreferencesFormatException instance using a
- * exception message and a nested Throwable instance.
- *
- * @param s the exception message.
- * @param t the nested Throwable instance.
- */
- public InvalidPreferencesFormatException (String s, Throwable t) {
- super(s,t);
- }
- /**
- * Constructs a new InvalidPreferencesFormatException instance using a
- * nested Throwable instance.
- *
- * @param t the nested Throwable instance.
- */
- public InvalidPreferencesFormatException (Throwable t) {
- super(t);
- }
-}
+ private static final long serialVersionUID = -791715184232119669L;
+ /**
+ * Constructs a new InvalidPreferencesFormatException instance using an
+ * exception message.
+ *
+ * @param s the exception message.
+ */
+ public InvalidPreferencesFormatException (String s) {
+ super(s);
+ }
+ /**
+ * Constructs a new InvalidPreferencesFormatException instance using a
+ * exception message and a nested Throwable instance.
+ *
+ * @param s the exception message.
+ * @param t the nested Throwable instance.
+ */
+ public InvalidPreferencesFormatException (String s, Throwable t) {
+ super(s,t);
+ }
+ /**
+ * Constructs a new InvalidPreferencesFormatException instance using a
+ * nested Throwable instance.
+ *
+ * @param t the nested Throwable instance.
+ */
+ public InvalidPreferencesFormatException (Throwable t) {
+ super(t);
+ }
+}
Modified: harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/NodeChangeEvent.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/NodeChangeEvent.java?rev=730659&r1=730658&r2=730659&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/NodeChangeEvent.java (original)
+++ harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/NodeChangeEvent.java Thu Jan 1 18:52:34 2009
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-
package java.util.prefs;
import java.io.Serializable;
@@ -37,61 +36,56 @@
* @since 1.4
*/
public class NodeChangeEvent extends EventObject implements Serializable {
-
+
private static final long serialVersionUID = 8068949086596572957L;
-
+
private final Preferences parent;
private final Preferences child;
-
+
/**
* Construct a new NodeChangeEvent instance.
*
- * @param p the Preferences instance that this event happened,
- * this object is considered as event's source.
- * @param c the child Preferences instance that was added
- * or deleted.
+ * @param p the Preferences instance that this event happened, this object is
+ * considered as event's source.
+ * @param c the child Preferences instance that was added or deleted.
+ */
+ public NodeChangeEvent (Preferences p, Preferences c) {
+ super(p);
+ parent = p;
+ child = c;
+ }
+
+ /**
+ * Get the Preferences instance that this event happened.
+ *
+ * @return the Preferences instance that this event happened.
*/
- public NodeChangeEvent (Preferences p, Preferences c) {
- super(p);
- parent = p;
- child = c;
- }
-
- /**
- * Get the Preferences instance that this event happened.
- *
- * @return the Preferences instance that this event happened.
- */
- public Preferences getParent() {
- return parent;
- }
-
- /**
- * Get the child Preferences node that was added or removed.
- *
- * @return the child Preferences node that was added or removed.
- */
- public Preferences getChild() {
- return child;
- }
-
- /*
+ public Preferences getParent() {
+ return parent;
+ }
+
+ /**
+ * Get the child Preferences node that was added or removed.
+ *
+ * @return the child Preferences node that was added or removed.
+ */
+ public Preferences getChild() {
+ return child;
+ }
+
+ /**
* This method always throws a NotSerializableException, because
* this object cannot be serialized,
*/
- private void writeObject (ObjectOutputStream out) throws IOException {
- throw new NotSerializableException();
- }
-
- /*
+ private void writeObject (ObjectOutputStream out) throws IOException {
+ throw new NotSerializableException();
+ }
+
+ /**
* This method always throws a NotSerializableException, because
* this object cannot be serialized,
*/
- private void readObject (ObjectInputStream in) throws IOException, ClassNotFoundException {
- throw new NotSerializableException();
- }
+ private void readObject (ObjectInputStream in) throws IOException, ClassNotFoundException {
+ throw new NotSerializableException();
+ }
}
-
-
-
-
Modified: harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/NodeChangeListener.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/NodeChangeListener.java?rev=730659&r1=730658&r2=730659&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/NodeChangeListener.java (original)
+++ harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/NodeChangeListener.java Thu Jan 1 18:52:34 2009
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-
package java.util.prefs;
import java.util.EventListener;
@@ -30,20 +29,17 @@
* @since 1.4
*/
public interface NodeChangeListener extends EventListener {
- /**
- * This method gets called whenever a child is added to a node.
- *
- * @param e Node change event.
- */
- public void childAdded (NodeChangeEvent e);
-
- /**
- * This method gets called whenever a child is removed from a node.
- *
- * @param e Node change event.
- */
- public void childRemoved (NodeChangeEvent e);
+ /**
+ * This method gets called whenever a child is added to a node.
+ *
+ * @param e Node change event.
+ */
+ public void childAdded (NodeChangeEvent e);
+
+ /**
+ * This method gets called whenever a child is removed from a node.
+ *
+ * @param e Node change event.
+ */
+ public void childRemoved (NodeChangeEvent e);
}
-
-
-
Modified: harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/PreferenceChangeEvent.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/PreferenceChangeEvent.java?rev=730659&r1=730658&r2=730659&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/PreferenceChangeEvent.java (original)
+++ harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/PreferenceChangeEvent.java Thu Jan 1 18:52:34 2009
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-
package java.util.prefs;
import java.io.IOException;
@@ -40,7 +39,7 @@
public class PreferenceChangeEvent extends EventObject implements Serializable {
private static final long serialVersionUID = 793724513368024975L;
-
+
private final Preferences node;
private final String key;
@@ -50,11 +49,11 @@
/**
* Construct a new PreferenceChangeEvent instance.
*
- * @param p the Preferences instance that this event happened,
- * this object is considered as event's source.
- * @param k the changed preference's key
- * @param v the new value of the changed preference, this value can be null,
- * which means the preference is removed.
+ * @param p the Preferences instance that this event happened, this object is
+ * considered as event's source.
+ * @param k the changed preference's key
+ * @param v the new value of the changed preference, this value can be null, which means the
+ * preference is removed.
*/
public PreferenceChangeEvent(Preferences p, String k, String v) {
super(p);
@@ -92,7 +91,7 @@
return node;
}
- /*
+ /**
* This method always throws a NotSerializableException, because
* this object cannot be serialized,
*/
@@ -100,7 +99,7 @@
throw new NotSerializableException();
}
- /*
+ /**
* This method always throws a NotSerializableException, because
* this object cannot be serialized,
*/
@@ -108,5 +107,3 @@
throw new NotSerializableException();
}
}
-
-
Modified: harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/PreferenceChangeListener.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/PreferenceChangeListener.java?rev=730659&r1=730658&r2=730659&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/PreferenceChangeListener.java (original)
+++ harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/PreferenceChangeListener.java Thu Jan 1 18:52:34 2009
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-
package java.util.prefs;
import java.util.EventListener;
@@ -30,16 +29,12 @@
* @since 1.4
*/
public interface PreferenceChangeListener extends EventListener {
-
+
/**
- * This method gets invoked whenever some preference is added, deleted or
- * updated.
+ * This method gets invoked whenever some preference is added, deleted or updated.
*
- * @param pce the event instance which describes the changed Preferences
- * instance and preferences value.
+ * @param pce the event instance which describes the changed Preferences instance and
+ * preferences value.
*/
- void preferenceChange (PreferenceChangeEvent pce);
+ void preferenceChange (PreferenceChangeEvent pce);
}
-
-
-
Modified: harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/Preferences.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/Preferences.java?rev=730659&r1=730658&r2=730659&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/Preferences.java (original)
+++ harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/Preferences.java Thu Jan 1 18:52:34 2009
@@ -89,33 +89,26 @@
* @since 1.4
*/
public abstract class Preferences {
-
- /*
- * ---------------------------------------------------------
- * Class fields
- * ---------------------------------------------------------
- */
-
- /**
- * Maximum size in characters of preferences key
- */
- public static final int MAX_KEY_LENGTH = 80;
-
- /**
- * Maximum size in characters of preferences name
- */
- public static final int MAX_NAME_LENGTH = 80;
-
- /**
- * Maximum size in characters of preferences value
- */
- public static final int MAX_VALUE_LENGTH = 8192;
-
- //permission
- private static final RuntimePermission PREFS_PERM = new RuntimePermission("preferences"); //$NON-NLS-1$
-
+ /**
+ * Maximum size in characters of preferences key
+ */
+ public static final int MAX_KEY_LENGTH = 80;
+
+ /**
+ * Maximum size in characters of preferences name
+ */
+ public static final int MAX_NAME_LENGTH = 80;
+
+ /**
+ * Maximum size in characters of preferences value
+ */
+ public static final int MAX_VALUE_LENGTH = 8192;
+
+ //permission
+ private static final RuntimePermission PREFS_PERM = new RuntimePermission("preferences"); //$NON-NLS-1$
+
//factory used to get user/system prefs root
- private static final PreferencesFactory factory;
+ private static final PreferencesFactory factory;
// default provider factory name for Windows
private static final String DEFAULT_FACTORY_NAME_WIN = "java.util.prefs.RegistryPreferencesFactoryImpl"; //$NON-NLS-1$
@@ -123,11 +116,6 @@
// default provider factory name for Unix
private static final String DEFAULT_FACTORY_NAME_UNIX = "java.util.prefs.FilePreferencesFactoryImpl"; //$NON-NLS-1$
- /**
- * ---------------------------------------------------------
- * Class initializer
- * ---------------------------------------------------------
- */
static {
String factoryClassName = AccessController.doPrivileged(new PrivilegedAction
- * <!DOCTYPE preferences SYSTEM "http://java.sun.com/dtd/preferences.dtd">
- * And the UTF-8 encoding will be used. Please note that this node is not
- * thread-safe, which is an exception of this class.
- *
IOException
- * @throws BackingStoreException
- * if backing store is unavailable or causes operation failure
- * @throws IllegalStateException
- * if this node has been removed
- */
- public abstract void exportNode (OutputStream ostream) throws IOException, BackingStoreException;
-
- /**
- * Export all preferences of this node and its all descendants to the given
- * output stream in XML document.
- * - * This XML document has the following DOCTYPE declaration: - *
- * <!DOCTYPE preferences SYSTEM "http://java.sun.com/dtd/preferences.dtd">* - * And the UTF-8 encoding will be used. Please note that this node is not - * thread-safe, which is an exception of this class. - * - * @param ostream - * the output stream to export the XML - * @throws IOException - * if export operation caused an
IOException
- * @throws BackingStoreException
- * if backing store is unavailable or causes operation failure
- * @throws IllegalStateException
- * if this node has been removed
- */
- public abstract void exportSubtree (OutputStream ostream) throws IOException, BackingStoreException;
-
- /**
- * Force the updates to this node and its descendants to the backing store.
- * - * If this node has been removed, then the invocation of this method only - * flush this node without descendants. - *
- * @throws BackingStoreException - * if backing store is unavailable or causes operation failure - */ - public abstract void flush() throws BackingStoreException; - - /** - * Return the string value mapped to the given key, or default value if no - * value is mapped or backing store is unavailable. - *- * Some implementations may store default values in backing stores. In this case, - * if there is no value mapped to the given key, the stored default value is - * returned. - *
- * - * @param key the preference key - * @param deflt the default value, which will be returned if no value is - * mapped to the given key or backing store unavailable - * @return the preference value mapped to the given key, or default value if - * no value is mapped or backing store unavailable - * @throws IllegalStateException - * if this node has been removed - * @throws NullPointerException - * if parameter key is null - */ - public abstract String get (String key, String deflt); - - /** - * Return the boolean value mapped to the given key, or default value if no - * value is mapped, backing store is unavailable, or the value is invalid. - *- * The valid value is string equals "true", which represents true, or "false", - * which represents false, case is ignored. - *
- *- * Some implementations may store default values in backing stores. In this case, - * if there is no value mapped to the given key, the stored default value is - * returned. - *
- * - * @param key the preference key - * @param deflt the default value, which will be returned if no value is - * mapped to the given key, backing store unavailable or value - * is invalid - * @return the boolean value mapped to the given key, or default value if - * no value is mapped, backing store unavailable or value is invalid - * @throws IllegalStateException - * if this node has been removed - * @throws NullPointerException - * if parameter key is null - */ - public abstract boolean getBoolean (String key, boolean deflt); - - /** - * Return the byte array value mapped to the given key, or default value if no - * value is mapped, backing store is unavailable, or the value is invalid string. - *- * The valid value string is Base64 encoded binary data. The Base64 encoding - * is as defined in RFC 2045, - * section 6.8. - *
- *- * Some implementations may store default values in backing stores. In this case, - * if there is no value mapped to the given key, the stored default value is - * returned. - *
- * - * @param key the preference key - * @param deflt the default value, which will be returned if no value is - * mapped to the given key, backing store unavailable or value - * is invalid - * @return the byte array value mapped to the given key, or default value if - * no value is mapped, backing store unavailable or value is invalid - * @throws IllegalStateException - * if this node has been removed - * @throws NullPointerException - * if parameter key is null - */ - public abstract byte[] getByteArray (String key, byte[] deflt); - - /** - * Return the double value mapped to the given key, or default value if no - * value is mapped, backing store is unavailable, or the value is invalid string. - *- * The valid value string can be converted to double number by - * {@link Double#parseDouble(String) Double.parseDouble(String)}. - *
- *- * Some implementations may store default values in backing stores. In this case, - * if there is no value mapped to the given key, the stored default value is - * returned. - *
- * - * @param key the preference key - * @param deflt the default value, which will be returned if no value is - * mapped to the given key, backing store unavailable or value - * is invalid - * @return the double value mapped to the given key, or default value if - * no value is mapped, backing store unavailable or value is invalid - * @throws IllegalStateException - * if this node has been removed - * @throws NullPointerException - * if parameter key is null - */ - public abstract double getDouble (String key, double deflt); - - /** - * Return the float value mapped to the given key, or default value if no - * value is mapped, backing store is unavailable, or the value is invalid string. - *- * The valid value string can be converted to float number by - * {@link Float#parseFloat(String) Float.parseFloat(String)}. - *
- *- * Some implementations may store default values in backing stores. In this case, - * if there is no value mapped to the given key, the stored default value is - * returned. - *
- * - * @param key the preference key - * @param deflt the default value, which will be returned if no value is - * mapped to the given key, backing store unavailable or value - * is invalid - * @return the float value mapped to the given key, or default value if - * no value is mapped, backing store unavailable or value is invalid - * @throws IllegalStateException - * if this node has been removed - * @throws NullPointerException - * if parameter key is null - */ - public abstract float getFloat (String key, float deflt); - - /** - * Return the float value mapped to the given key, or default value if no - * value is mapped, backing store is unavailable, or the value is invalid string. - *- * The valid value string can be converted to integer by - * {@link Integer#parseInt(String) Integer.parseInt(String)}. - *
- *- * Some implementations may store default values in backing stores. In this case, - * if there is no value mapped to the given key, the stored default value is - * returned. - *
- * - * @param key the preference key - * @param deflt the default value, which will be returned if no value is - * mapped to the given key, backing store unavailable or value - * is invalid - * @return the integer value mapped to the given key, or default value if - * no value is mapped, backing store unavailable or value is invalid - * @throws IllegalStateException - * if this node has been removed - * @throws NullPointerException - * if parameter key is null - */ - public abstract int getInt (String key, int deflt); - - /** - * Return the long value mapped to the given key, or default value if no - * value is mapped, backing store is unavailable, or the value is invalid string. - *- * The valid value string can be converted to long integer by - * {@link Long#parseLong(String) Long.parseLong(String)}. - *
- *- * Some implementations may store default values in backing stores. In this case, - * if there is no value mapped to the given key, the stored default value is - * returned. - *
- * - * @param key the preference key - * @param deflt the default value, which will be returned if no value is - * mapped to the given key, backing store unavailable or value - * is invalid - * @return the long value mapped to the given key, or default value if - * no value is mapped, backing store unavailable or value is invalid - * @throws IllegalStateException - * if this node has been removed - * @throws NullPointerException - * if parameter key is null - */ - public abstract long getLong (String key, long deflt); - - /** - * Import all preferences from the given input stream in XML document. - *- * This XML document has the following DOCTYPE declaration: - *
- * <!DOCTYPE preferences SYSTEM "http://java.sun.com/dtd/preferences.dtd">* - * Please note that this node is not thread-safe, which is an exception of - * this class. - * - * - * @param istream - * the given input stream to read data - * @throws InvalidPreferencesFormatException - * if the data read from given input stream is not valid XML - * document - * @throws IOException - * if import operation caused an
IOException
- * @throws SecurityException
- * if RuntimePermission("preferences") is denied
- * by a SecurityManager
- */
- public static void importPreferences (InputStream istream) throws InvalidPreferencesFormatException, IOException {
- checkSecurity();
- if(null == istream){
+ }
+
+ /**
+ * Get this preference node's absolute path string.
+ *
+ * @return this preference node's absolute path string.
+ */
+ public abstract String absolutePath();
+
+ /**
+ * Return names of all children of this node, or empty string if this node has no children.
+ *
+ * @return names of all children of this node
+ * @throws BackingStoreException if backing store is unavailable or causes operation failure
+ * @throws IllegalStateException if this node has been removed
+ */
+ public abstract String[] childrenNames() throws BackingStoreException;
+
+ /**
+ * Remove all preferences of this node.
+ *
+ * @throws BackingStoreException if backing store is unavailable or causes operation failure
+ * @throws IllegalStateException if this node has been removed
+ */
+ public abstract void clear() throws BackingStoreException;
+
+ /**
+ * Export all preferences of this node to the given output stream in XML document.
+ * + * This XML document has the following DOCTYPE declaration: + * + *
+ * <!DOCTYPE preferences SYSTEM "http://java.sun.com/dtd/preferences.dtd"> + *+ * + * And the UTF-8 encoding will be used. Please note that this node is not thread-safe, which is + * an exception of this class. + * + * + * @param ostream the output stream to export the XML + * @throws IOException if export operation caused an
IOException
+ * @throws BackingStoreException if backing store is unavailable or causes operation failure
+ * @throws IllegalStateException if this node has been removed
+ */
+ public abstract void exportNode(OutputStream ostream) throws IOException, BackingStoreException;
+
+ /**
+ * Export all preferences of this node and its all descendants to the given output stream in XML
+ * document.
+ * + * This XML document has the following DOCTYPE declaration: + * + *
+ * <!DOCTYPE preferences SYSTEM "http://java.sun.com/dtd/preferences.dtd"> + *+ * + * And the UTF-8 encoding will be used. Please note that this node is not thread-safe, which is + * an exception of this class. + * + * + * @param ostream the output stream to export the XML + * @throws IOException if export operation caused an
IOException
+ * @throws BackingStoreException if backing store is unavailable or causes operation failure
+ * @throws IllegalStateException if this node has been removed
+ */
+ public abstract void exportSubtree(OutputStream ostream) throws IOException,
+ BackingStoreException;
+
+ /**
+ * Force the updates to this node and its descendants to the backing store.
+ * + * If this node has been removed, then the invocation of this method only flush this node + * without descendants. + *
+ * + * @throws BackingStoreException if backing store is unavailable or causes operation failure + */ + public abstract void flush() throws BackingStoreException; + + /** + * Return the string value mapped to the given key, or default value if no value is mapped or + * backing store is unavailable. + *+ * Some implementations may store default values in backing stores. In this case, if there is no + * value mapped to the given key, the stored default value is returned. + *
+ * + * @param key the preference key + * @param deflt the default value, which will be returned if no value is mapped to the given key + * or backing store unavailable + * @return the preference value mapped to the given key, or default value if no value is mapped + * or backing store unavailable + * @throws IllegalStateException if this node has been removed + * @throws NullPointerException if parameter key is null + */ + public abstract String get(String key, String deflt); + + /** + * Return the boolean value mapped to the given key, or default value if no value is mapped, + * backing store is unavailable, or the value is invalid. + *+ * The valid value is string equals "true", which represents true, or "false", which represents + * false, case is ignored. + *
+ *+ * Some implementations may store default values in backing stores. In this case, if there is no + * value mapped to the given key, the stored default value is returned. + *
+ * + * @param key the preference key + * @param deflt the default value, which will be returned if no value is mapped to the given + * key, backing store unavailable or value is invalid + * @return the boolean value mapped to the given key, or default value if no value is mapped, + * backing store unavailable or value is invalid + * @throws IllegalStateException if this node has been removed + * @throws NullPointerException if parameter key is null + */ + public abstract boolean getBoolean(String key, boolean deflt); + + /** + * Return the byte array value mapped to the given key, or default value if no value is mapped, + * backing store is unavailable, or the value is invalid string. + *+ * The valid value string is Base64 encoded binary data. The Base64 encoding is as defined in RFC 2045, section 6.8. + *
+ *+ * Some implementations may store default values in backing stores. In this case, if there is no + * value mapped to the given key, the stored default value is returned. + *
+ * + * @param key the preference key + * @param deflt the default value, which will be returned if no value is mapped to the given + * key, backing store unavailable or value is invalid + * @return the byte array value mapped to the given key, or default value if no value is mapped, + * backing store unavailable or value is invalid + * @throws IllegalStateException if this node has been removed + * @throws NullPointerException if parameter key is null + */ + public abstract byte[] getByteArray(String key, byte[] deflt); + + /** + * Return the double value mapped to the given key, or default value if no value is mapped, + * backing store is unavailable, or the value is invalid string. + *+ * The valid value string can be converted to double number by + * {@link Double#parseDouble(String) Double.parseDouble(String)}. + *
+ *+ * Some implementations may store default values in backing stores. In this case, if there is no + * value mapped to the given key, the stored default value is returned. + *
+ * + * @param key the preference key + * @param deflt the default value, which will be returned if no value is mapped to the given + * key, backing store unavailable or value is invalid + * @return the double value mapped to the given key, or default value if no value is mapped, + * backing store unavailable or value is invalid + * @throws IllegalStateException if this node has been removed + * @throws NullPointerException if parameter key is null + */ + public abstract double getDouble(String key, double deflt); + + /** + * Return the float value mapped to the given key, or default value if no value is mapped, + * backing store is unavailable, or the value is invalid string. + *+ * The valid value string can be converted to float number by {@link Float#parseFloat(String) + * Float.parseFloat(String)}. + *
+ *+ * Some implementations may store default values in backing stores. In this case, if there is no + * value mapped to the given key, the stored default value is returned. + *
+ * + * @param key the preference key + * @param deflt the default value, which will be returned if no value is mapped to the given + * key, backing store unavailable or value is invalid + * @return the float value mapped to the given key, or default value if no value is mapped, + * backing store unavailable or value is invalid + * @throws IllegalStateException if this node has been removed + * @throws NullPointerException if parameter key is null + */ + public abstract float getFloat(String key, float deflt); + + /** + * Return the float value mapped to the given key, or default value if no value is mapped, + * backing store is unavailable, or the value is invalid string. + *+ * The valid value string can be converted to integer by {@link Integer#parseInt(String) + * Integer.parseInt(String)}. + *
+ *+ * Some implementations may store default values in backing stores. In this case, if there is no + * value mapped to the given key, the stored default value is returned. + *
+ * + * @param key the preference key + * @param deflt the default value, which will be returned if no value is mapped to the given + * key, backing store unavailable or value is invalid + * @return the integer value mapped to the given key, or default value if no value is mapped, + * backing store unavailable or value is invalid + * @throws IllegalStateException if this node has been removed + * @throws NullPointerException if parameter key is null + */ + public abstract int getInt(String key, int deflt); + + /** + * Return the long value mapped to the given key, or default value if no value is mapped, + * backing store is unavailable, or the value is invalid string. + *+ * The valid value string can be converted to long integer by {@link Long#parseLong(String) + * Long.parseLong(String)}. + *
+ *+ * Some implementations may store default values in backing stores. In this case, if there is no + * value mapped to the given key, the stored default value is returned. + *
+ * + * @param key the preference key + * @param deflt the default value, which will be returned if no value is mapped to the given + * key, backing store unavailable or value is invalid + * @return the long value mapped to the given key, or default value if no value is mapped, + * backing store unavailable or value is invalid + * @throws IllegalStateException if this node has been removed + * @throws NullPointerException if parameter key is null + */ + public abstract long getLong(String key, long deflt); + + /** + * Import all preferences from the given input stream in XML document. + *+ * This XML document has the following DOCTYPE declaration: + * + *
+ * <!DOCTYPE preferences SYSTEM "http://java.sun.com/dtd/preferences.dtd"> + *+ * + * Please note that this node is not thread-safe, which is an exception of this class. + * + * + * @param istream the given input stream to read data + * @throws InvalidPreferencesFormatException if the data read from given input stream is not + * valid XML document + * @throws IOException if import operation caused an
IOException
+ * @throws SecurityException if RuntimePermission("preferences") is denied by a
+ * SecurityManager
+ */
+ public static void importPreferences (InputStream istream) throws InvalidPreferencesFormatException, IOException {
+ checkSecurity();
+ if(null == istream){
// prefs.0=Inputstream cannot be null\!
- throw new MalformedURLException(Messages.getString("prefs.0")); //$NON-NLS-1$
- }
- XMLParser.importPrefs(istream);
- }
-
- /**
- * Return true if this is a user preferences, false if this is a system
- * preferences
- *
- * @return true if this is a user preferences, false if this is a
- * system preferences
- */
- public abstract boolean isUserNode();
-
- /**
- * Return all preferences keys stored in this node, or empty array if no
- * key is found.
- *
- * @return all preferences keys in this node
- * @throws BackingStoreException
- * if backing store is unavailable or causes operation failure
- * @throws IllegalStateException
- * if this node has been removed
- */
- public abstract String[] keys() throws BackingStoreException;
-
- /**
- * Return name of this node.
- *
- * @return the name of this node
- */
- public abstract String name();
-
- /**
- * Return the preferences node with the given path name. The path name can
- * be relative or absolute. The dictated preferences and its ancestors will
- * be created if they do not exist.
- * - * The path is treated as relative to this node if it doesn't start with - * slash, or as absolute otherwise.
- * - * @param path the path name of dictated preferences - * @return the dictated preferences node - * @throws IllegalStateException - * if this node has been removed. - * @throws IllegalArgumentException - * if the path name is invalid. - * @throws NullPointerException - * if given path is null. - */ - public abstract Preferences node (String path); - - /** - * Return the preferences node with the given path name. The path is treated - * as relative to this node if it doesn't start with slash, or as absolute - * otherwise. - *
- * Please note that if this node has been removed, invocation of this node
- * will throw IllegalStateException except the given path is
- * empty string, which will return false.
- *
MAX_KEY_LENGTH, or the value's length is bigger
- * than MAX_VALUE_LENGTH
- * @throws IllegalStateException
- * if this node has been removed
- */
- public abstract void put (String key, String value);
-
- /**
- * Add new preferences to this node using given key and string form of given
- * value, or update value if preferences with given key has already existed.
- *
- * @param key the preferences key to be added or be updated
- * @param value the preferences value for the given key
- * @throws NullPointerException
- * if the given key is null
- * @throws IllegalArgumentException
- * if the given key's length is bigger than
- * MAX_KEY_LENGTH
- * @throws IllegalStateException
- * if this node has been removed
- */
- public abstract void putBoolean (String key, boolean value);
-
- /**
- * Add new preferences to this node using given key and string form of given
- * value, or update value if preferences with given key has already existed.
- * - * The string form of value is the Base64 encoded binary data of the given - * byte array. The Base64 encoding is as defined in - * RFC 2045, section 6.8.
- * - * @param key the preferences key to be added or be updated - * @param value the preferences value for the given key - * @throws NullPointerException - * if the given key or value is null - * @throws IllegalArgumentException - * if the given key's length is bigger than - *MAX_KEY_LENGTH or value's length is bigger than
- * three quarters of MAX_KEY_LENGTH
- * @throws IllegalStateException
- * if this node has been removed
- */
- public abstract void putByteArray (String key, byte[] value);
-
- /**
- * Add new preferences to this node using given key and string form of given
- * value, or update value if preferences with given key has already existed.
- * - * The string form of given value is the result of invoking - * {@link Double#toString(double) Double.toString(double)}
- * - * @param key the preferences key to be added or be updated - * @param value the preferences value for the given key - * @throws NullPointerException - * if the given key is null - * @throws IllegalArgumentException - * if the given key's length is bigger than - *MAX_KEY_LENGTH
- * @throws IllegalStateException
- * if this node has been removed
- */
- public abstract void putDouble (String key, double value);
-
- /**
- * Add new preferences to this node using given key and string form of given
- * value, or update value if preferences with given key has already existed.
- * - * The string form of given value is the result of invoking - * {@link Float#toString(float) Float.toString(float)}
- * - * @param key the preferences key to be added or be updated - * @param value the preferences value for the given key - * @throws NullPointerException - * if the given key is null - * @throws IllegalArgumentException - * if the given key's length is bigger than - *MAX_KEY_LENGTH
- * @throws IllegalStateException
- * if this node has been removed
- */
- public abstract void putFloat (String key, float value);
-
- /**
- * Add new preferences to this node using given key and string form of given
- * value, or update value if preferences with given key has already existed.
- * - * The string form of given value is the result of invoking - * {@link Integer#toString(int) Integer.toString(int)}
- * - * @param key the preferences key to be added or be updated - * @param value the preferences value for the given key - * @throws NullPointerException - * if the given key is null - * @throws IllegalArgumentException - * if the given key's length is bigger than - *MAX_KEY_LENGTH
- * @throws IllegalStateException
- * if this node has been removed
- */
- public abstract void putInt (String key, int value);
-
- /**
- * Add new preferences to this node using given key and string form of given
- * value, or update value if preferences with given key has already existed.
- * - * The string form of given value is the result of invoking - * {@link Long#toString(long) Long.toString(long)}
- * - * @param key the preferences key to be added or be updated - * @param value the preferences value for the given key - * @throws NullPointerException - * if the given key is null - * @throws IllegalArgumentException - * if the given key's length is bigger than - *MAX_KEY_LENGTH
- * @throws IllegalStateException
- * if this node has been removed
- */
- public abstract void putLong (String key, long value);
-
- /**
- * Remove the preferences mapped to the given key from this node.
- *
- * @param key the given preferences key to removed
- * @throws NullPointerException
- * if the given key is null
- * @throws IllegalStateException
- * if this node has been removed
- */
- public abstract void remove (String key);
-
- /**
- * Remove this preferences node and its all descendants. The removal maybe
- * won't be persisted until the flush() method is invoked.
- *
- * @throws BackingStoreException
- * if backing store is unavailable or causes operation failure
- * @throws IllegalStateException
- * if this node has been removed
- * @throws UnsupportedOperationException
- * if this is a root node
- */
- public abstract void removeNode() throws BackingStoreException;
-
- /**
- * Register an NodeChangeListener instance for this node, which
- * will receive NodeChangeEvent. NodeChangeEvent will
- * be produced when direct child node is added to or removed from this node.
- *
- * @param ncl the given listener to be registered
- * @throws NullPointerException
- * if the given listener is null
- * @throws IllegalStateException
- * if this node has been removed
- */
- public abstract void addNodeChangeListener (NodeChangeListener ncl);
-
- /**
- * Register an PreferenceChangeListener instance for this node, which
- * will receive PreferenceChangeEvent. PreferenceChangeEvent will
- * be produced when preference is added to, removed from or updated for this node.
- *
- * @param pcl the given listener to be registered
- * @throws NullPointerException
- * if the given listener is null
- * @throws IllegalStateException
- * if this node has been removed
- */
- public abstract void addPreferenceChangeListener (PreferenceChangeListener pcl);
-
- /**
- * Remove the given NodeChangeListener instance from this node.
- *
- * @param ncl the given listener to be removed
- * @throws IllegalArgumentException
- * if the given listener
- * @throws IllegalStateException
- * if this node has been removed
- */
- public abstract void removeNodeChangeListener (NodeChangeListener ncl);
-
- /**
- * Remove the given PreferenceChangeListener instance from this node.
- *
- * @param pcl the given listener to be removed
- * @throws IllegalArgumentException
- * if the given listener
- * @throws IllegalStateException
- * if this node has been removed
- */
- public abstract void removePreferenceChangeListener (PreferenceChangeListener pcl);
-
- /**
- * Synchronize this preferences node and its descendants' data with the back
- * end preferences store. The changes of back end should be reflect by this
- * node and its descendants, meanwhile, the changes of this node and descendants
- * should be persisted.
- *
- * @throws BackingStoreException
- * if backing store is unavailable or causes operation failure
- * @throws IllegalStateException
- * if this node has been removed
- */
- public abstract void sync() throws BackingStoreException;
-
- /**
- * Return the system preference node for the package of given class. The
- * absolute path of the returned node is one slash followed by the given
- * class's full package name with replacing each period ('.') with slash.
- * For example, the preference's associated with class Object
+ throw new MalformedURLException(Messages.getString("prefs.0")); //$NON-NLS-1$
+ }
+ XMLParser.importPrefs(istream);
+ }
+
+ /**
+ * Return true if this is a user preferences, false if this is a system preferences
+ *
+ * @return true if this is a user preferences, false if this is a system preferences
+ */
+ public abstract boolean isUserNode();
+
+ /**
+ * Return all preferences keys stored in this node, or empty array if no key is found.
+ *
+ * @return all preferences keys in this node
+ * @throws BackingStoreException if backing store is unavailable or causes operation failure
+ * @throws IllegalStateException if this node has been removed
+ */
+ public abstract String[] keys() throws BackingStoreException;
+
+ /**
+ * Return name of this node.
+ *
+ * @return the name of this node
+ */
+ public abstract String name();
+
+ /**
+ * Return the preferences node with the given path name. The path name can be relative or
+ * absolute. The dictated preferences and its ancestors will be created if they do not exist.
+ *
+ * The path is treated as relative to this node if it doesn't start with slash, or as absolute
+ * otherwise.
+ *
+ *
+ * @param path the path name of dictated preferences
+ * @return the dictated preferences node
+ * @throws IllegalStateException if this node has been removed.
+ * @throws IllegalArgumentException if the path name is invalid.
+ * @throws NullPointerException if given path is null.
+ */
+ public abstract Preferences node(String path);
+
+ /**
+ * Return the preferences node with the given path name. The path is treated as relative to this
+ * node if it doesn't start with slash, or as absolute otherwise.
+ *
+ * Please note that if this node has been removed, invocation of this node will throw
+ * IllegalStateException except the given path is empty string, which will return
+ * false.
+ *
+ *
+ * @param path the path name of dictated preferences
+ * @return true if the dictated preferences node exists
+ * @throws IllegalStateException if this node has been removed and the path is not empty string.
+ * @throws IllegalArgumentException if the path name is invalid.
+ * @throws NullPointerException if given path is null.
+ * @throws BackingStoreException if backing store is unavailable or causes operation failure
+ */
+ public abstract boolean nodeExists(String path) throws BackingStoreException;
+
+ /**
+ * Return the parent preferences node of this node, or null if this node is root.
+ *
+ * @return the parent preferences node of this node.
+ * @throws IllegalStateException if this node has been removed
+ */
+ public abstract Preferences parent();
+
+ /**
+ * Add new preferences to this node using given key and value, or update value if preferences
+ * with given key has already existed.
+ *
+ * @param key the preferences key to be added or be updated
+ * @param value the preferences value for the given key
+ * @throws NullPointerException if the given key or value is null
+ * @throws IllegalArgumentException if the given key's length is bigger than
+ * MAX_KEY_LENGTH, or the value's length is bigger than
+ * MAX_VALUE_LENGTH
+ * @throws IllegalStateException if this node has been removed
+ */
+ public abstract void put(String key, String value);
+
+ /**
+ * Add new preferences to this node using given key and string form of given value, or update
+ * value if preferences with given key has already existed.
+ *
+ * @param key the preferences key to be added or be updated
+ * @param value the preferences value for the given key
+ * @throws NullPointerException if the given key is null
+ * @throws IllegalArgumentException if the given key's length is bigger than
+ * MAX_KEY_LENGTH
+ * @throws IllegalStateException if this node has been removed
+ */
+ public abstract void putBoolean(String key, boolean value);
+
+ /**
+ * Add new preferences to this node using given key and string form of given value, or update
+ * value if preferences with given key has already existed.
+ *
+ * The string form of value is the Base64 encoded binary data of the given byte array. The
+ * Base64 encoding is as defined in RFC 2045,
+ * section 6.8.
+ *
+ *
+ * @param key the preferences key to be added or be updated
+ * @param value the preferences value for the given key
+ * @throws NullPointerException if the given key or value is null
+ * @throws IllegalArgumentException if the given key's length is bigger than
+ * MAX_KEY_LENGTH or value's length is bigger than three quarters of
+ * MAX_KEY_LENGTH
+ * @throws IllegalStateException if this node has been removed
+ */
+ public abstract void putByteArray(String key, byte[] value);
+
+ /**
+ * Add new preferences to this node using given key and string form of given value, or update
+ * value if preferences with given key has already existed.
+ *
+ * The string form of given value is the result of invoking {@link Double#toString(double)
+ * Double.toString(double)}
+ *
+ *
+ * @param key the preferences key to be added or be updated
+ * @param value the preferences value for the given key
+ * @throws NullPointerException if the given key is null
+ * @throws IllegalArgumentException if the given key's length is bigger than
+ * MAX_KEY_LENGTH
+ * @throws IllegalStateException if this node has been removed
+ */
+ public abstract void putDouble(String key, double value);
+
+ /**
+ * Add new preferences to this node using given key and string form of given value, or update
+ * value if preferences with given key has already existed.
+ *
+ * The string form of given value is the result of invoking {@link Float#toString(float)
+ * Float.toString(float)}
+ *
+ *
+ * @param key the preferences key to be added or be updated
+ * @param value the preferences value for the given key
+ * @throws NullPointerException if the given key is null
+ * @throws IllegalArgumentException if the given key's length is bigger than
+ * MAX_KEY_LENGTH
+ * @throws IllegalStateException if this node has been removed
+ */
+ public abstract void putFloat(String key, float value);
+
+ /**
+ * Add new preferences to this node using given key and string form of given value, or update
+ * value if preferences with given key has already existed.
+ *
+ * The string form of given value is the result of invoking {@link Integer#toString(int)
+ * Integer.toString(int)}
+ *
+ *
+ * @param key the preferences key to be added or be updated
+ * @param value the preferences value for the given key
+ * @throws NullPointerException if the given key is null
+ * @throws IllegalArgumentException if the given key's length is bigger than
+ * MAX_KEY_LENGTH
+ * @throws IllegalStateException if this node has been removed
+ */
+ public abstract void putInt(String key, int value);
+
+ /**
+ * Add new preferences to this node using given key and string form of given value, or update
+ * value if preferences with given key has already existed.
+ *
+ * The string form of given value is the result of invoking {@link Long#toString(long)
+ * Long.toString(long)}
+ *
+ *
+ * @param key the preferences key to be added or be updated
+ * @param value the preferences value for the given key
+ * @throws NullPointerException if the given key is null
+ * @throws IllegalArgumentException if the given key's length is bigger than
+ * MAX_KEY_LENGTH
+ * @throws IllegalStateException if this node has been removed
+ */
+ public abstract void putLong(String key, long value);
+
+ /**
+ * Remove the preferences mapped to the given key from this node.
+ *
+ * @param key the given preferences key to removed
+ * @throws NullPointerException if the given key is null
+ * @throws IllegalStateException if this node has been removed
+ */
+ public abstract void remove(String key);
+
+ /**
+ * Remove this preferences node and its all descendants. The removal maybe won't be persisted
+ * until the flush() method is invoked.
+ *
+ * @throws BackingStoreException if backing store is unavailable or causes operation failure
+ * @throws IllegalStateException if this node has been removed
+ * @throws UnsupportedOperationException if this is a root node
+ */
+ public abstract void removeNode() throws BackingStoreException;
+
+ /**
+ * Register an NodeChangeListener instance for this node, which will receive
+ * NodeChangeEvent. NodeChangeEvent will be produced when direct child
+ * node is added to or removed from this node.
+ *
+ * @param ncl the given listener to be registered
+ * @throws NullPointerException if the given listener is null
+ * @throws IllegalStateException if this node has been removed
+ */
+ public abstract void addNodeChangeListener(NodeChangeListener ncl);
+
+ /**
+ * Register an PreferenceChangeListener instance for this node, which will receive
+ * PreferenceChangeEvent. PreferenceChangeEvent will be produced when
+ * preference is added to, removed from or updated for this node.
+ *
+ * @param pcl the given listener to be registered
+ * @throws NullPointerException if the given listener is null
+ * @throws IllegalStateException if this node has been removed
+ */
+ public abstract void addPreferenceChangeListener (PreferenceChangeListener pcl);
+
+ /**
+ * Remove the given NodeChangeListener instance from this node.
+ *
+ * @param ncl the given listener to be removed
+ * @throws IllegalArgumentException if the given listener
+ * @throws IllegalStateException if this node has been removed
+ */
+ public abstract void removeNodeChangeListener (NodeChangeListener ncl);
+
+ /**
+ * Remove the given PreferenceChangeListener instance from this node.
+ *
+ * @param pcl the given listener to be removed
+ * @throws IllegalArgumentException if the given listener
+ * @throws IllegalStateException if this node has been removed
+ */
+ public abstract void removePreferenceChangeListener (PreferenceChangeListener pcl);
+
+ /**
+ * Synchronize this preferences node and its descendants' data with the back end preferences
+ * store. The changes of back end should be reflect by this node and its descendants, meanwhile,
+ * the changes of this node and descendants should be persisted.
+ *
+ * @throws BackingStoreException if backing store is unavailable or causes operation failure
+ * @throws IllegalStateException if this node has been removed
+ */
+ public abstract void sync() throws BackingStoreException;
+
+ /**
+ * Return the system preference node for the package of given class. The absolute path of the
+ * returned node is one slash followed by the given class's full package name with replacing
+ * each period ('.') with slash. For example, the preference's associated with class
+ * Object
* has absolute path like "/java/lang". As a special case, the unnamed
- * package is associated with preference node "/".
+ * package is associated with preference node "/".
*
- * This method will create node and its ancestors if needed, and the new
- * created nodes maybe won't be persisted until the flush()
- * is invoked.
- *
- * @param c the given class
- * @return the system preference node for the package of given class.
- * @throws NullPointerException
- * if the given class is null
- * @throws SecurityException
- * if RuntimePermission("preferences") is denied
- * by a SecurityManager
- */
- public static Preferences systemNodeForPackage (Class> c) {
- checkSecurity();
- return factory.systemRoot().node(getNodeName(c));
- }
-
- /**
- * Return the root node for system preference hierarchy.
- *
- * @return the root node for system preference hierarchy
- * @throws SecurityException
- * if RuntimePermission("preferences") is denied
- * by a SecurityManager
- */
- public static Preferences systemRoot() {
- checkSecurity();
- return factory.systemRoot();
- }
-
- //check the RuntimePermission("preferences")
+ * This method will create node and its ancestors if needed, and the new
+ * created nodes maybe won't be persisted until the flush() is invoked.
+ *
+ * @param c the given class
+ * @return the system preference node for the package of given class.
+ * @throws NullPointerException if the given class is null
+ * @throws SecurityException if RuntimePermission("preferences") is denied by a
+ * SecurityManager
+ */
+ public static Preferences systemNodeForPackage (Class> c) {
+ checkSecurity();
+ return factory.systemRoot().node(getNodeName(c));
+ }
+
+ /**
+ * Return the root node for system preference hierarchy.
+ *
+ * @return the root node for system preference hierarchy
+ * @throws SecurityException if RuntimePermission("preferences") is denied by a
+ * SecurityManager
+ */
+ public static Preferences systemRoot() {
+ checkSecurity();
+ return factory.systemRoot();
+ }
+
+ //check the RuntimePermission("preferences")
private static void checkSecurity() {
SecurityManager manager = System.getSecurityManager();
if(null != manager){
manager.checkPermission(PREFS_PERM);
}
-
+
}
/**
- * Return the user preference node for the package of given class. The
- * absolute path of the returned node is one slash followed by the given
- * class's full package name with replacing each period ('.') with slash.
- * For example, the preference's associated with class Object
+ * Return the user preference node for the package of given class. The absolute path of the
+ * returned node is one slash followed by the given class's full package name with replacing
+ * each period ('.') with slash. For example, the preference's associated with class
+ * Object
* has absolute path like "/java/lang". As a special case, the unnamed
- * package is associated with preference node "/".
+ * package is associated with preference node "/".
*
- * This method will create node and its ancestors if needed, and the new
- * created nodes maybe won't be persisted until the flush()
- * is invoked.
- *
- * @param c the given class
- * @return the user preference node for the package of given class.
- * @throws NullPointerException
- * if the given class is null
- * @throws SecurityException
- * if RuntimePermission("preferences") is denied
- * by a SecurityManager
- */
- public static Preferences userNodeForPackage (Class> c) {
- checkSecurity();
- return factory.userRoot().node(getNodeName(c));
- }
-
- //parse node's absolute path from class instance
- private static String getNodeName(Class> c){
- Package p = c.getPackage();
- if(null == p){
- return "/"; //$NON-NLS-1$
- }
- return "/"+p.getName().replace('.', '/'); //$NON-NLS-1$
- }
-
- /**
- * Return the root node for user preference hierarchy.
- *
- * @return the root node for user preference hierarchy
- * @throws SecurityException
- * if RuntimePermission("preferences") is denied
- * by a SecurityManager
- */
- public static Preferences userRoot() {
- checkSecurity();
- return factory.userRoot();
- }
-
- /**
- * Return a string description of this node. The format is "User/System
- * Preference Node: " followed by this node's absolute path.
- *
- * @return a string description of this node
- *
- */
- @Override
+ * This method will create node and its ancestors if needed, and the new
+ * created nodes maybe won't be persisted until the flush() is invoked.
+ *
+ * @param c the given class
+ * @return the user preference node for the package of given class.
+ * @throws NullPointerException if the given class is null
+ * @throws SecurityException if RuntimePermission("preferences") is denied by a
+ * SecurityManager
+ */
+ public static Preferences userNodeForPackage (Class> c) {
+ checkSecurity();
+ return factory.userRoot().node(getNodeName(c));
+ }
+
+ //parse node's absolute path from class instance
+ private static String getNodeName(Class> c){
+ Package p = c.getPackage();
+ if(null == p){
+ return "/"; //$NON-NLS-1$
+ }
+ return "/"+p.getName().replace('.', '/'); //$NON-NLS-1$
+ }
+
+ /**
+ * Return the root node for user preference hierarchy.
+ *
+ * @return the root node for user preference hierarchy
+ * @throws SecurityException if RuntimePermission("preferences") is denied by a
+ * SecurityManager
+ */
+ public static Preferences userRoot() {
+ checkSecurity();
+ return factory.userRoot();
+ }
+
+ /**
+ * Return a string description of this node. The format is "User/System
+ * Preference Node: " followed by this node's absolute path.
+ *
+ * @return a string description of this node
+ */
+ @Override
public abstract String toString();
}
Modified: harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/PreferencesFactory.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/PreferencesFactory.java?rev=730659&r1=730658&r2=730659&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/PreferencesFactory.java (original)
+++ harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/PreferencesFactory.java Thu Jan 1 18:52:34 2009
@@ -14,35 +14,29 @@
* limitations under the License.
*/
-
package java.util.prefs;
/**
- * This interface is used by {@link Preferences} class
- * as factory class to create Preferences instance. This interface can be implemented
- * and installed to replace the default preferences implementation.
+ * This interface is used by {@link Preferences} class as factory class to create Preferences
+ * instance. This interface can be implemented and installed to replace the default preferences
+ * implementation.
*
* @see java.util.prefs.Preferences
*
* @since 1.4
*/
public interface PreferencesFactory {
- /**
- * Returns the root of the preferences hierarchy for the calling user
- * context.
- *
- * @return The user root preferences node.
- */
- Preferences userRoot();
-
- /**
- * Returns the root of the system preferences hierarchy.
- *
- * @return The root of the system preferences hierarchy.
- */
- Preferences systemRoot();
+ /**
+ * Returns the root of the preferences hierarchy for the calling user context.
+ *
+ * @return The user root preferences node.
+ */
+ Preferences userRoot();
+
+ /**
+ * Returns the root of the system preferences hierarchy.
+ *
+ * @return The root of the system preferences hierarchy.
+ */
+ Preferences systemRoot();
}
-
-
-
-
Modified: harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/RegistryPreferencesFactoryImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/RegistryPreferencesFactoryImpl.java?rev=730659&r1=730658&r2=730659&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/RegistryPreferencesFactoryImpl.java (original)
+++ harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/RegistryPreferencesFactoryImpl.java Thu Jan 1 18:52:34 2009
@@ -20,20 +20,20 @@
import java.util.prefs.PreferencesFactory;
/**
- * Default implementation of PreferencesFactory for windows
- * platform, using windows Registry as back end.
+ * Default implementation of PreferencesFactory for windows platform, using windows
+ * Registry as back end.
*
* @since 1.4
*/
class RegistryPreferencesFactoryImpl implements PreferencesFactory {
- //user root preferences
+ // user root preferences
private static final Preferences USER_ROOT = new RegistryPreferencesImpl(true);
- //system root preferences
+ // system root preferences
private static final Preferences SYSTEM_ROOT = new RegistryPreferencesImpl(false);
-
+
public RegistryPreferencesFactoryImpl() {
- super();
+ super();
}
public Preferences userRoot() {
@@ -44,7 +44,3 @@
return SYSTEM_ROOT;
}
}
-
-
-
-