harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r420487 - in /incubator/harmony/enhanced/classlib/trunk/modules/sql: ./ META-INF/ make/ src/main/java/java/sql/ src/main/java/org/apache/harmony/sql/internal/nls/
Date Mon, 10 Jul 2006 11:01:01 GMT
Author: tellison
Date: Mon Jul 10 04:01:00 2006
New Revision: 420487

URL: http://svn.apache.org/viewvc?rev=420487&view=rev
Log:
Externalize the SQL messages into their own catalog.

Added:
    incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/org/apache/harmony/sql/internal/nls/
    incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/org/apache/harmony/sql/internal/nls/Messages.java
  (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/org/apache/harmony/sql/internal/nls/messages.properties
  (with props)
Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/sql/.classpath
    incubator/harmony/enhanced/classlib/trunk/modules/sql/META-INF/MANIFEST.MF
    incubator/harmony/enhanced/classlib/trunk/modules/sql/build.xml
    incubator/harmony/enhanced/classlib/trunk/modules/sql/make/patternset.txt
    incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/DriverManager.java
    incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Time.java
    incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Timestamp.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/sql/.classpath
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sql/.classpath?rev=420487&r1=420486&r2=420487&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/.classpath (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/.classpath Mon Jul 10 04:01:00 2006
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
-	<classpathentry output="bin/main" kind="src" path="src/main/java"/>
-	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
-	<classpathentry output="bin/test" kind="src" path="src/test/java"/>
-	<classpathentry sourcepath="JUNIT_SRC_HOME/junitsrc.zip" kind="var" path="JUNIT_HOME/junit.jar"/>
-	<classpathentry kind="output" path="bin/main"/>
+	<classpathentry path="src/main/java" kind="src" output="bin/main"/>
+	<classpathentry path="src/test/java" kind="src" output="bin/test"/>
+	<classpathentry path="org.eclipse.pde.core.requiredPlugins" kind="con"/>
+	<classpathentry path="JUNIT_HOME/junit.jar" kind="var" sourcepath="JUNIT_SRC_HOME/junitsrc.zip"/>
+	<classpathentry path="bin/main" kind="output"/>
 </classpath>

Modified: incubator/harmony/enhanced/classlib/trunk/modules/sql/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sql/META-INF/MANIFEST.MF?rev=420487&r1=420486&r2=420487&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/META-INF/MANIFEST.MF (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/META-INF/MANIFEST.MF Mon Jul 10
04:01:00 2006
@@ -16,7 +16,8 @@
  java.util,
  java.util.jar;resolution:=optional,
  java.util.zip;resolution:=optional,
- org.apache.harmony.kernel.vm
+ org.apache.harmony.kernel.vm,
+ org.apache.harmony.luni.util
 Export-Package: java.sql,
  javax.sql,
  javax.transaction,

Modified: incubator/harmony/enhanced/classlib/trunk/modules/sql/build.xml
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sql/build.xml?rev=420487&r1=420486&r2=420487&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/build.xml (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/build.xml Mon Jul 10 04:01:00 2006
@@ -46,11 +46,9 @@
         </delete>
     </target>
 
-    <target name="compile.java">
+    <target name="compile.java" depends="copy.resources">
         <echo message="Compiling SQL classes" />
 
-        <mkdir dir="${hy.build}" />
-
         <javac sourcepath=""
                srcdir="${hy.sql.src.main.java}"
                destdir="${hy.build}"
@@ -65,6 +63,15 @@
             </bootclasspath>
         </javac>
     </target>
+
+	<target name="copy.resources">
+    	<mkdir dir="${hy.build}" />
+        <copy todir="${hy.build}" includeemptydirs="false">
+            <fileset dir="${hy.sql.src.main.java}">
+                <exclude name="**/*.java" />
+            </fileset>
+        </copy>
+	</target>
 
     <target name="build.jar">
         <jar destfile="${hy.jdk}/jre/lib/boot/sql.jar"

Modified: incubator/harmony/enhanced/classlib/trunk/modules/sql/make/patternset.txt
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sql/make/patternset.txt?rev=420487&r1=420486&r2=420487&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/make/patternset.txt (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/make/patternset.txt Mon Jul 10 04:01:00
2006
@@ -20,4 +20,4 @@
 javax/transaction/*
 javax/transaction/xa/*
 
-org/apache/harmony/sql/internal/common/*
\ No newline at end of file
+org/apache/harmony/sql/**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/DriverManager.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/DriverManager.java?rev=420487&r1=420486&r2=420487&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/DriverManager.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/DriverManager.java
Mon Jul 10 04:01:00 2006
@@ -24,6 +24,7 @@
 import java.util.HashSet;
 import java.util.Vector;
 import org.apache.harmony.sql.internal.common.ClassUtils;
+import org.apache.harmony.sql.internal.nls.Messages;
 import org.apache.harmony.kernel.vm.VM;
 
 /**
@@ -116,8 +117,8 @@
         ClassLoader callerClassLoader = VM.callerClassLoader();
 
         if (!ClassUtils.isClassFromClassLoader(driver, callerClassLoader)) {
-            throw new SecurityException(
-                    "DriverManager: calling class not authorized to deregister JDBC driver");
+            // sql.1=DriverManager: calling class not authorized to deregister JDBC driver
+            throw new SecurityException(Messages.getString("sql.1")); //$NON-NLS-1$
         } // end if
         synchronized (theDriverSet) {
             theDriverSet.remove(driver);
@@ -160,7 +161,8 @@
     public static Connection getConnection(String url, Properties info)
             throws SQLException {
         if (url == null) {
-            throw new SQLException("The url cannot be null");
+            // sql.5=The url cannot be null
+            throw new SQLException(Messages.getString("sql.5")); //$NON-NLS-1$
         }
         synchronized (theDriverSet) {
             /*
@@ -178,7 +180,8 @@
             }
         }
         // If we get here, none of the drivers are able to resolve the URL
-        throw new SQLException("No suitable driver");
+        // sql.6=No suitable driver
+        throw new SQLException(Messages.getString("sql.6")); //$NON-NLS-1$
     }
 
     /**
@@ -199,7 +202,8 @@
     public static Connection getConnection(String url, String user,
             String password) throws SQLException {
         if (user == null || password == null) {
-            throw new SQLException("Userid and/or password not supplied");
+            // sql.7=Userid and/or password not supplied
+            throw new SQLException(Messages.getString("sql.7")); //$NON-NLS-1$
         }
         Properties theProperties = new Properties();
         theProperties.setProperty("user", user); //$NON-NLS-1$
@@ -237,7 +241,8 @@
             }
         }
         // If no drivers understand the URL, throw an SQLException
-        throw new SQLException("No suitable driver");
+        // sql.6=No suitable driver
+        throw new SQLException(Messages.getString("sql.6")); //$NON-NLS-1$
     }
 
     /**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Time.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Time.java?rev=420487&r1=420486&r2=420487&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Time.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Time.java
Mon Jul 10 04:01:00 2006
@@ -154,7 +154,7 @@
      *         HH:mm:ss
      */
     public String toString() {
-        SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
+        SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); //$NON-NLS-1$
         return dateFormat.format(this);
     }
 
@@ -179,7 +179,7 @@
             throw new IllegalArgumentException();
         }
 
-        SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
+        SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); //$NON-NLS-1$
         try {
             aDate = dateFormat.parse(theTime);
         } catch (ParseException pe) {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Timestamp.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Timestamp.java?rev=420487&r1=420486&r2=420487&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Timestamp.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Timestamp.java
Mon Jul 10 04:01:00 2006
@@ -20,6 +20,8 @@
 import java.text.SimpleDateFormat;
 import java.util.Date;
 
+import org.apache.harmony.sql.internal.nls.Messages;
+
 /**
  * A Java representation of the SQL TIMESTAMP type. It provides the capability
  * to represent the SQL TIMESTAMP nanosecond value, in addition to the regular
@@ -251,7 +253,8 @@
      */
     public void setNanos(int n) throws IllegalArgumentException {
         if ((n < 0) || (n > 999999999)) {
-            throw new IllegalArgumentException("Nanos value out of range.");
+            // sql.0=Value out of range
+            throw new IllegalArgumentException(Messages.getString("sql.0")); //$NON-NLS-1$
         }
         nanoseconds = n;
     }
@@ -293,13 +296,13 @@
         // A SimpleDateFormat will lay out everything except the nanosecond
         // value
         SimpleDateFormat dateFormat = new SimpleDateFormat(
-                "yyyy-MM-dd HH:mm:ss");
+                "yyyy-MM-dd HH:mm:ss"); //$NON-NLS-1$
 
         /*
          * Use a DecimalFormat to lay out the nanosecond value as a simple
          * string of 9 integers, with leading Zeros
          */
-        DecimalFormat decimalFormat = new DecimalFormat("0");
+        DecimalFormat decimalFormat = new DecimalFormat("0"); //$NON-NLS-1$
         decimalFormat.setMinimumIntegerDigits(9);
         decimalFormat.setMaximumIntegerDigits(9);
         String theNanos = decimalFormat.format(nanoseconds);
@@ -326,7 +329,7 @@
              * with a single '0'
              */
             if (i == 1) {
-                return "0";
+                return "0"; //$NON-NLS-1$
             }
         }
 
@@ -334,7 +337,8 @@
         return finalString;
     }
 
-    private static String valueOfExceptionMessage = "Timestamp format must be yyyy-mm-dd
hh:mm:ss.fffffffff";
+    // sql.2=Timestamp format must be yyyy-mm-dd hh:mm:ss.fffffffff
+    private static String valueOfExceptionMessage = Messages.getString("sql.2"); //$NON-NLS-1$
 
     /**
      * Creates a Timestamp object with a time value equal to the time specified
@@ -348,10 +352,11 @@
      */
     public static Timestamp valueOf(String s) throws IllegalArgumentException {
         if (s == null) {
-            throw new IllegalArgumentException("null string");
+            // sql.3=Argument cannot be null
+            throw new IllegalArgumentException(Messages.getString("sql.3")); //$NON-NLS-1$
         }
 
-        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //$NON-NLS-1$
         ParsePosition pp = new ParsePosition(0);
 
         /*
@@ -392,7 +397,7 @@
              * Case where fraction of a second is specified: Require 1 character
              * plus the "." in the remaining part of the string...
              */
-            if ((s.length() - position) < ".n".length()) {
+            if ((s.length() - position) < ".n".length()) { //$NON-NLS-1$
                 throw new IllegalArgumentException(valueOfExceptionMessage);
             }
 
@@ -400,14 +405,14 @@
              * If we're strict, we should not allow any EXTRA characters after
              * the 9 digits
              */
-            if ((s.length() - position) > ".nnnnnnnnn".length()) {
+            if ((s.length() - position) > ".nnnnnnnnn".length()) { //$NON-NLS-1$
                 throw new IllegalArgumentException(valueOfExceptionMessage);
             }
 
             // Require the next character to be a "."
             if (s.charAt(position) != '.') {
-                throw new NumberFormatException("Bad input string format - '"
-                        + s.charAt(position) + "' instead of '.'");
+                // sql.4=Bad input string format: expected '.' not {0}
+                throw new NumberFormatException(Messages.getString("sql.4", s.charAt(position)));
//$NON-NLS-1$
             }
             // Get the length of the number string - need to account for the '.'
             int nanoLength = s.length() - position - 1;
@@ -419,7 +424,7 @@
              * We must adjust for the cases where the nanos String was not 9
              * characters long by padding out with zeros
              */
-            theNanoString = theNanoString + "000000000";
+            theNanoString = theNanoString + "000000000"; //$NON-NLS-1$
             theNanoString = theNanoString.substring(0, 9);
 
             try {

Added: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/org/apache/harmony/sql/internal/nls/Messages.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/org/apache/harmony/sql/internal/nls/Messages.java?rev=420487&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/org/apache/harmony/sql/internal/nls/Messages.java
(added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/org/apache/harmony/sql/internal/nls/Messages.java
Mon Jul 10 04:01:00 2006
@@ -0,0 +1,132 @@
+/* Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.sql.internal.nls;
+
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.apache.harmony.luni.util.MsgHelp;
+
+public class Messages {
+
+    // ResourceBundle holding the system messages.
+    static private ResourceBundle bundle = null;
+
+    static {
+        // Attempt to load the messages.
+        try {
+            bundle = MsgHelp.setLocale(
+                    Locale.getDefault(),
+                    "org.apache.harmony.sql.internal.nls.messages"); //$NON-NLS-1$
+        } catch (Throwable e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * Retrieves a message which has no arguments.
+     * 
+     * @param msg
+     *            String the key to look up.
+     * @return String the message for that key in the system message bundle.
+     */
+    static public String getString(String msg) {
+        if (bundle == null)
+            return msg;
+        try {
+            return bundle.getString(msg);
+        } catch (MissingResourceException e) {
+            return "Missing message: " + msg; //$NON-NLS-1$
+        }
+    }
+
+    /**
+     * Retrieves a message which takes 1 argument.
+     * 
+     * @param msg
+     *            String the key to look up.
+     * @param arg
+     *            Object the object to insert in the formatted output.
+     * @return String the message for that key in the system message bundle.
+     */
+    static public String getString(String msg, Object arg) {
+        return getString(msg, new Object[] { arg });
+    }
+
+    /**
+     * Retrieves a message which takes 1 integer argument.
+     * 
+     * @param msg
+     *            String the key to look up.
+     * @param arg
+     *            int the integer to insert in the formatted output.
+     * @return String the message for that key in the system message bundle.
+     */
+    static public String getString(String msg, int arg) {
+        return getString(msg, new Object[] { Integer.toString(arg) });
+    }
+
+    /**
+     * Retrieves a message which takes 1 character argument.
+     * 
+     * @param msg
+     *            String the key to look up.
+     * @param arg
+     *            char the character to insert in the formatted output.
+     * @return String the message for that key in the system message bundle.
+     */
+    static public String getString(String msg, char arg) {
+        return getString(msg, new Object[] { String.valueOf(arg) });
+    }
+
+    /**
+     * Retrieves a message which takes 2 arguments.
+     * 
+     * @param msg
+     *            String the key to look up.
+     * @param arg1
+     *            Object an object to insert in the formatted output.
+     * @param arg2
+     *            Object another object to insert in the formatted output.
+     * @return String the message for that key in the system message bundle.
+     */
+    static public String getString(String msg, Object arg1, Object arg2) {
+        return getString(msg, new Object[] { arg1, arg2 });
+    }
+
+    /**
+     * Retrieves a message which takes several arguments.
+     * 
+     * @param msg
+     *            String the key to look up.
+     * @param args
+     *            Object[] the objects to insert in the formatted output.
+     * @return String the message for that key in the system message bundle.
+     */
+    static public String getString(String msg, Object[] args) {
+        String format = msg;
+
+        if (bundle != null) {
+            try {
+                format = bundle.getString(msg);
+            } catch (MissingResourceException e) {
+            }
+        }
+
+        return MsgHelp.format(format, args);
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/org/apache/harmony/sql/internal/nls/Messages.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/org/apache/harmony/sql/internal/nls/messages.properties
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/org/apache/harmony/sql/internal/nls/messages.properties?rev=420487&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/org/apache/harmony/sql/internal/nls/messages.properties
(added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/org/apache/harmony/sql/internal/nls/messages.properties
Mon Jul 10 04:01:00 2006
@@ -0,0 +1,24 @@
+# Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+#  
+#  Licensed under the Apache License, Version 2.0 (the "License");
+#  you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#  
+#      http://www.apache.org/licenses/LICENSE-2.0
+#  
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+# 
+
+# messages for EN locale
+sql.0=Value out of range
+sql.1=DriverManager: calling class not authorized to deregister JDBC driver
+sql.2=Timestamp format must be yyyy-mm-dd hh:mm:ss.fffffffff
+sql.3=Argument cannot be null
+sql.4=Bad input string format: expected '.' not {0}
+sql.5=The url cannot be null
+sql.6=No suitable driver
+sql.7=Userid and/or password not supplied

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/org/apache/harmony/sql/internal/nls/messages.properties
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message