jdk/src/share/classes/java/util/spi/CurrencyNameProvider.java
changeset 7255 88d0a8413bb8
parent 5506 202f599c92aa
child 7668 d4a77089c587
--- a/jdk/src/share/classes/java/util/spi/CurrencyNameProvider.java	Wed Nov 24 14:13:37 2010 +0900
+++ b/jdk/src/share/classes/java/util/spi/CurrencyNameProvider.java	Wed Nov 24 15:26:41 2010 -0800
@@ -25,7 +25,9 @@
 
 package java.util.spi;
 
+import java.util.Arrays;
 import java.util.Currency;
+import java.util.List;
 import java.util.Locale;
 
 /**
@@ -95,6 +97,23 @@
             throw new NullPointerException();
         }
 
+        // Check whether the currencyCode is valid
+        char[] charray = currencyCode.toCharArray();
+        if (charray.length != 3) {
+            throw new IllegalArgumentException("The currencyCode is not in the form of three upper-case letters.");
+        }
+        for (char c : charray) {
+            if (c < 'A' || c > 'Z') {
+                throw new IllegalArgumentException("The currencyCode is not in the form of three upper-case letters.");
+            }
+        }
+
+        // Check whether the locale is valid
+        List<Locale> avail = Arrays.asList(getAvailableLocales());
+        if (!avail.contains(locale)) {
+            throw new IllegalArgumentException("The locale is not available");
+        }
+
         return null;
     }
 }