/[Apache-SVN]/incubator/jdo/trunk/api20/src/java/javax/jdo/spi/JDOImplHelper.java
ViewVC logotype

Diff of /incubator/jdo/trunk/api20/src/java/javax/jdo/spi/JDOImplHelper.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- incubator/jdo/trunk/api20/src/java/javax/jdo/spi/JDOImplHelper.java	2005/07/22 04:34:39	220236
+++ incubator/jdo/trunk/api20/src/java/javax/jdo/spi/JDOImplHelper.java	2005/07/22 04:48:28	220237
@@ -555,19 +555,21 @@ public class JDOImplHelper extends java.
      */
     static {
         JDOImplHelper helper = getInstance();
-        helper.registerStringConstructor(Currency.class, new StringConstructor() {
-            public Object construct(String s) {
-                try {
-                    return Currency.getInstance(s);
-                } catch (IllegalArgumentException ex) {
-                    throw new javax.jdo.JDOUserException(
-                        msg.msg("EXC_CurrencyStringConstructorIllegalArgument", s), ex); //NOI18N
-                } catch (Exception ex) {
-                    throw new JDOUserException(
-                        msg.msg("EXC_CurrencyStringConstructorException"), ex); //NOI18N
+        if (isClassLoadable("java.util.Currency")) {
+            helper.registerStringConstructor(Currency.class, new StringConstructor() {
+                public Object construct(String s) {
+                    try {
+                        return Currency.getInstance(s);
+                    } catch (IllegalArgumentException ex) {
+                        throw new javax.jdo.JDOUserException(
+                            msg.msg("EXC_CurrencyStringConstructorIllegalArgument", s), ex); //NOI18N
+                    } catch (Exception ex) {
+                        throw new JDOUserException(
+                            msg.msg("EXC_CurrencyStringConstructorException"), ex); //NOI18N
+                    }
                 }
-            }
-        });
+            });
+        }
         helper.registerStringConstructor(Locale.class, new StringConstructor() {
             public Object construct(String s) {
                 try {
@@ -593,6 +595,18 @@ public class JDOImplHelper extends java.
     }
     
     /**
+     * Determine if a class is loadable in the current environment.
+     */
+    public static boolean isClassLoadable(String className) {
+        try {
+            Class.forName(className);
+            return true;
+        } catch (ClassNotFoundException ex) {
+            return false;
+        }
+    }
+    
+    /**
      * Construct an instance of the parameter class, using the keyString
      * as an argument to the constructor. If the class has a StringConstructor
      * instance registered, use it. If not, try to find a constructor for

 

infrastructure at apache.org
ViewVC Help
Powered by ViewVC 1.1.26