harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r447854 - in /incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/main/java: java/util/prefs/ org/apache/harmony/prefs/internal/nls/
Date Tue, 19 Sep 2006 14:22:43 GMT
Author: pyang
Date: Tue Sep 19 07:22:42 2006
New Revision: 447854

URL: http://svn.apache.org/viewvc?view=rev&rev=447854
Log:
Patch applied for HARMONY-1315 ([classlib][internationalization]Internationalization of the
prefs module)

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/AbstractPreferences.java
    incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/FilePreferencesImpl.java
    incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/Preferences.java
    incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/RegistryPreferencesImpl.java
    incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/XMLParser.java
    incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/org/apache/harmony/prefs/internal/nls/messages.properties

Modified: incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/AbstractPreferences.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/AbstractPreferences.java?view=diff&rev=447854&r1=447853&r2=447854
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/AbstractPreferences.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/AbstractPreferences.java
Tue Sep 19 07:22:42 2006
@@ -29,6 +29,7 @@
 import java.util.TreeSet;
 
 import org.apache.harmony.luni.util.Base64;
+import org.apache.harmony.prefs.internal.nls.Messages;
 
 /**
  * This class is partly implementation of <code>Preferences</code>, which can
be 
@@ -58,7 +59,7 @@
     //the unhandled events collection
     static final List<EventObject> events = new LinkedList<EventObject>();
     //the event dispatcher thread
-    private final static EventDispatcher dispatcher = new EventDispatcher("Preference Event
Dispatcher");
+    private final static EventDispatcher dispatcher = new EventDispatcher("Preference Event
Dispatcher"); //$NON-NLS-1$
 
     /*
      * -----------------------------------------------------------
@@ -368,7 +369,8 @@
     public void exportNode(OutputStream ostream) throws IOException,
             BackingStoreException {
         if(ostream == null) {
-            throw new AssertionError("Stream is null"); //$NON-NLS-1$
+            // prefs.5=Stream is null
+            throw new AssertionError(Messages.getString("prefs.5"));  //$NON-NLS-1$
         }
         checkState();
         XMLParser.exportPrefs(this, ostream, false);
@@ -382,7 +384,8 @@
     public void exportSubtree(OutputStream ostream) throws IOException,
             BackingStoreException {
         if(ostream == null) {
-            throw new AssertionError("Stream is null"); //$NON-NLS-1$
+            // prefs.5=Stream is null
+            throw new AssertionError(Messages.getString("prefs.5"));  //$NON-NLS-1$
         }
 
         checkState();
@@ -597,11 +600,13 @@
 
     private void validateName(String name) {
         if (name.endsWith("/") && name.length() > 1) { //$NON-NLS-1$
-            throw new IllegalArgumentException("Name cannot end with '/'!"); //$NON-NLS-1$
+            // prefs.6=Name cannot end with '/'\!
+            throw new IllegalArgumentException(Messages.getString("prefs.6"));  //$NON-NLS-1$
         }
         if (name.indexOf("//") >= 0) { //$NON-NLS-1$
+            // prefs.7=Name cannot contains consecutive '/'\!
             throw new IllegalArgumentException(
-                    "Name cannot contains consecutive '/'!"); //$NON-NLS-1$
+                    Messages.getString("prefs.7"));  //$NON-NLS-1$
         }
     }
 
@@ -629,8 +634,9 @@
             throws BackingStoreException {
         AbstractPreferences temp;
         if (name.length() > MAX_NAME_LENGTH) {
-            throw new IllegalArgumentException("Name length is too long: " //$NON-NLS-1$
-                    + name);
+            // prefs.8=Name length is too long: {0}
+            throw new IllegalArgumentException(Messages.getString("prefs.8",  //$NON-NLS-1$
+                    name));
         }
         if (createNew) {
             temp = currentNode.childSpi(name);
@@ -655,7 +661,8 @@
                 if ("".equals(name)) { //$NON-NLS-1$
                     return false;
                 }
-                throw new IllegalStateException("This node has been removed!"); //$NON-NLS-1$
+                // prefs.9=This node has been removed\!
+                throw new IllegalStateException(Messages.getString("prefs.9"));  //$NON-NLS-1$
             }
             validateName(name);
             if ("".equals(name) || "/".equals(name)) { //$NON-NLS-1$ //$NON-NLS-2$
@@ -687,7 +694,8 @@
 
     private void checkState() {
         if (isRemoved()) {
-            throw new IllegalStateException("This node has been removed!"); //$NON-NLS-1$
+            // prefs.9=This node has been removed\!
+            throw new IllegalStateException(Messages.getString("prefs.9"));  //$NON-NLS-1$
         }
     }
 
@@ -784,7 +792,8 @@
      */
     public void removeNode() throws BackingStoreException {
         if (root == this) {
-            throw new UnsupportedOperationException("Cannot remove root node!"); //$NON-NLS-1$
+            // prefs.A=Cannot remove root node\!
+            throw new UnsupportedOperationException(Messages.getString("prefs.A"));  //$NON-NLS-1$
         }
         synchronized (parentPref.lock) {
             removeNodeImpl();

Modified: incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/FilePreferencesImpl.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/FilePreferencesImpl.java?view=diff&rev=447854&r1=447853&r2=447854
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/FilePreferencesImpl.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/FilePreferencesImpl.java
Tue Sep 19 07:22:42 2006
@@ -25,6 +25,8 @@
 import java.util.Properties;
 import java.util.Set;
 
+import org.apache.harmony.prefs.internal.nls.Messages;
+
 /**
  * TODO some sync mechanism wich backend, Performance - check file edit date
  */
@@ -157,8 +159,9 @@
                     }
                 });
         if (null == names) {// file is not a directory, exception case
+            // prefs.3=Cannot get children names for {0}!
             throw new BackingStoreException(
-                    "Cannot get children names for " + toString() + "!"); //$NON-NLS-1$ //$NON-NLS-2$
+                    Messages.getString("prefs.3", toString()));  //$NON-NLS-1$
         }
         return names;
     }
@@ -255,7 +258,8 @@
             }
         })).booleanValue();
         if (!removeSucceed) {
-            throw new BackingStoreException("Cannot remove " + toString() + "!"); //$NON-NLS-1$
//$NON-NLS-2$
+            // prefs.4=Cannot remove {0}!
+            throw new BackingStoreException(Messages.getString("prefs.4", toString())); 
//$NON-NLS-1$
         }
     }
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/Preferences.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/Preferences.java?view=diff&rev=447854&r1=447853&r2=447854
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/Preferences.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/Preferences.java
Tue Sep 19 07:22:42 2006
@@ -23,6 +23,8 @@
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 
+import org.apache.harmony.prefs.internal.nls.Messages;
+
 
 
 /**
@@ -133,7 +135,8 @@
 	        Class<?> factoryClass = loader.loadClass(factoryClassName);
 	        factory = (PreferencesFactory) factoryClass.newInstance();
         } catch (Exception e) {
-            throw new InternalError("Cannot initiate PreferencesFactory: "+factoryClassName+".
Caused by "+ e);  //$NON-NLS-1$//$NON-NLS-2$
+            // prefs.10=Cannot initiate PreferencesFactory: {0}. Caused by {1}
+            throw new InternalError(Messages.getString("prefs.10", factoryClassName, e));
  //$NON-NLS-1$
         }
 	    
 	}
@@ -438,7 +441,8 @@
 	public static void importPreferences (InputStream istream) throws InvalidPreferencesFormatException,
IOException {
 	    checkSecurity();
 	    if(null == istream){
-	        throw new MalformedURLException("Inputstream cannot be null!");
+            // prefs.0=Inputstream cannot be null\!
+	        throw new MalformedURLException(Messages.getString("prefs.0")); //$NON-NLS-1$
 	    }
 	    XMLParser.importPrefs(istream);
 	}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/RegistryPreferencesImpl.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/RegistryPreferencesImpl.java?view=diff&rev=447854&r1=447853&r2=447854
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/RegistryPreferencesImpl.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/RegistryPreferencesImpl.java
Tue Sep 19 07:22:42 2006
@@ -16,6 +16,8 @@
 
 package java.util.prefs;
 
+import org.apache.harmony.prefs.internal.nls.Messages;
+
 /*
  * Default implementation of <code>AbstractPreferences</code> for windows platform,
  * using windows registry as back end. 
@@ -25,7 +27,7 @@
 class RegistryPreferencesImpl extends AbstractPreferences {
     
     static {
-		System.loadLibrary("hyprefs");
+		System.loadLibrary("hyprefs"); //$NON-NLS-1$
 	}
 
     /*
@@ -94,7 +96,8 @@
         int[] error = new int[1];
         byte[][] names = getChildNames(path, userNode, error);
         if (error[ERROR_CODE] != RETURN_SUCCESS) {
-            throw new BackingStoreException("Enumerate child nodes error!"); //$NON-NLS-1$
+            // prefs.B=Enumerate child nodes error\!
+            throw new BackingStoreException(Messages.getString("prefs.B"));  //$NON-NLS-1$
         }
         String[] result = new String[names.length];
         for (int i = 0; i < result.length; i++) {
@@ -118,7 +121,8 @@
         int[] error = new int[1];
         flushPrefs(path, userNode, error);
         if (error[ERROR_CODE] != RETURN_SUCCESS) {
-            throw new BackingStoreException("Flush error!"); //$NON-NLS-1$
+            // prefs.C=Flush error\!
+            throw new BackingStoreException(Messages.getString("prefs.C"));  //$NON-NLS-1$
         }
     }
 
@@ -135,7 +139,8 @@
         int[] errorCode = new int[1];
         byte[][] keys = keys(path, userNode, errorCode);
         if (errorCode[ERROR_CODE] != RETURN_SUCCESS) {
-            throw new BackingStoreException("Enumerate keys error!"); //$NON-NLS-1$
+            // prefs.D=Enumerate keys error\!
+            throw new BackingStoreException(Messages.getString("prefs.D"));  //$NON-NLS-1$
         }
         String[] result = new String[keys.length];
         for (int i = 0; i < result.length; i++) {
@@ -148,7 +153,8 @@
         int[] errorCode = new int[1];
         putValue(path, encodeWindowsStr(name).getBytes(), value.getBytes(), userNode, errorCode);
         if (errorCode[ERROR_CODE] == RETURN_ACCESS_DENIED) {
-            throw new SecurityException("Access denied!"); //$NON-NLS-1$
+            // prefs.E=Access denied\!
+            throw new SecurityException(Messages.getString("prefs.E"));  //$NON-NLS-1$
         }
     }
 
@@ -157,7 +163,8 @@
         removeNode(((RegistryPreferencesImpl) parent()).path,
                 encodeWindowsStr(name()).getBytes(), userNode, error);
         if (error[ERROR_CODE] != RETURN_SUCCESS) {
-            throw new BackingStoreException("Remove node error!"); //$NON-NLS-1$
+            // prefs.F=Remove node error\!
+            throw new BackingStoreException(Messages.getString("prefs.F"));  //$NON-NLS-1$
         }
     }
 
@@ -165,7 +172,8 @@
         int[] errorCode = new int[1];
         removeKey(path, encodeWindowsStr(key).getBytes(), userNode, errorCode);
         if (errorCode[ERROR_CODE] == RETURN_ACCESS_DENIED) {
-            throw new SecurityException("Access denied!"); //$NON-NLS-1$
+            // prefs.E=Access denied\!
+            throw new SecurityException(Messages.getString("prefs.E"));  //$NON-NLS-1$
         }
     }
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/XMLParser.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/XMLParser.java?view=diff&rev=447854&r1=447853&r2=447854
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/XMLParser.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/java/util/prefs/XMLParser.java
Tue Sep 19 07:22:42 2006
@@ -41,6 +41,7 @@
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.transform.TransformerException;
 
+import org.apache.harmony.prefs.internal.nls.Messages;
 import org.apache.xpath.XPathAPI;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -131,8 +132,9 @@
                     result.setSystemId(PREFS_DTD_NAME);
                     return result;
                 }
+                // prefs.1=Invalid DOCTYPE declaration: {0}
                 throw new SAXException(
-                        "Invalid DOCTYPE declaration: " + systemId); //$NON-NLS-1$
+                        Messages.getString("prefs.1", systemId));  //$NON-NLS-1$
             }
         });
         builder.setErrorHandler(new ErrorHandler() {
@@ -357,8 +359,9 @@
             preferences = doc.getDocumentElement();
             String version = preferences.getAttribute("EXTERNAL_XML_VERSION"); //$NON-NLS-1$
             if (version != null && Float.parseFloat(version) > XML_VERSION) {
+                // prefs.2=This preferences exported version is not supported:{0}
                 throw new InvalidPreferencesFormatException(
-                        "This preferences exported version is not supported:" + version);
//$NON-NLS-1$
+                        Messages.getString("prefs.2", version));  //$NON-NLS-1$
             }
 
             // check preferences root's type

Modified: incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/org/apache/harmony/prefs/internal/nls/messages.properties
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/org/apache/harmony/prefs/internal/nls/messages.properties?view=diff&rev=447854&r1=447853&r2=447854
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/org/apache/harmony/prefs/internal/nls/messages.properties
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/prefs/src/main/java/org/apache/harmony/prefs/internal/nls/messages.properties
Tue Sep 19 07:22:42 2006
@@ -14,3 +14,20 @@
 # 
 
 # messages for EN locale
+prefs.0=Inputstream cannot be null\!
+prefs.1=Invalid DOCTYPE declaration: {0}
+prefs.10=Cannot initiate PreferencesFactory: {0}. Caused by {1}
+prefs.2=This preferences exported version is not supported:{0}
+prefs.3=Cannot get children names for {0}!
+prefs.4=Cannot remove {0}!
+prefs.5=Stream is null
+prefs.6=Name cannot end with '/'\!
+prefs.7=Name cannot contains consecutive '/'\!
+prefs.8=Name length is too long: {0}
+prefs.9=This node has been removed\!
+prefs.A=Cannot remove root node\!
+prefs.B=Enumerate child nodes error\!
+prefs.C=Flush error\!
+prefs.D=Enumerate keys error\!
+prefs.E=Access denied\!
+prefs.F=Remove node error\!



Mime
View raw message