< prev index next >

make/src/classes/build/tools/generatecurrencydata/GenerateCurrencyData.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -119,11 +119,11 @@
     private static int[] specialCaseOldCurrenciesNumericCode = new int[maxSpecialCases];
     private static int[] specialCaseNewCurrenciesNumericCode = new int[maxSpecialCases];
 
     private static final int maxOtherCurrencies = 128;
     private static int otherCurrenciesCount = 0;
-    private static StringBuffer otherCurrencies = new StringBuffer();
+    private static String[] otherCurrencies = new String[maxOtherCurrencies];
     private static int[] otherCurrenciesDefaultFractionDigits = new int[maxOtherCurrencies];
     private static int[] otherCurrenciesNumericCode= new int[maxOtherCurrencies];
 
     // date format for parsing cut-over times
     private static SimpleDateFormat format;

@@ -316,14 +316,11 @@
                     (tableEntry & SPECIAL_CASE_COUNTRY_MASK) != 0 ||
                     (tableEntry & SIMPLE_CASE_COUNTRY_FINAL_CHAR_MASK) != (currencyCode.charAt(2) - 'A')) {
                 if (otherCurrenciesCount == maxOtherCurrencies) {
                     throw new RuntimeException("too many other currencies");
                 }
-                if (otherCurrencies.length() > 0) {
-                    otherCurrencies.append('-');
-                }
-                otherCurrencies.append(currencyCode);
+                otherCurrencies[otherCurrenciesCount] = currencyCode;
                 otherCurrenciesDefaultFractionDigits[otherCurrenciesCount] = getDefaultFractionDigits(currencyCode);
                 otherCurrenciesNumericCode[otherCurrenciesCount] = getNumericCode(currencyCode);
                 otherCurrenciesCount++;
             }
         }

@@ -348,37 +345,43 @@
         out.writeInt(MAGIC_NUMBER);
         out.writeInt(Integer.parseInt(formatVersion));
         out.writeInt(Integer.parseInt(dataVersion));
         writeIntArray(mainTable, mainTable.length);
         out.writeInt(specialCaseCount);
-        writeLongArray(specialCaseCutOverTimes, specialCaseCount);
-        writeStringArray(specialCaseOldCurrencies, specialCaseCount);
-        writeStringArray(specialCaseNewCurrencies, specialCaseCount);
-        writeIntArray(specialCaseOldCurrenciesDefaultFractionDigits, specialCaseCount);
-        writeIntArray(specialCaseNewCurrenciesDefaultFractionDigits, specialCaseCount);
-        writeIntArray(specialCaseOldCurrenciesNumericCode, specialCaseCount);
-        writeIntArray(specialCaseNewCurrenciesNumericCode, specialCaseCount);
+        writeSpecialCaseEntries();
         out.writeInt(otherCurrenciesCount);
-        out.writeUTF(otherCurrencies.toString());
-        writeIntArray(otherCurrenciesDefaultFractionDigits, otherCurrenciesCount);
-        writeIntArray(otherCurrenciesNumericCode, otherCurrenciesCount);
+        writeOtherCurrencies();
     }
 
     private static void writeIntArray(int[] ia, int count) throws IOException {
-        for (int i = 0; i < count; i ++) {
+        for (int i = 0; i < count; i++) {
             out.writeInt(ia[i]);
         }
     }
 
-    private static void writeLongArray(long[] la, int count) throws IOException  {
-        for (int i = 0; i < count; i ++) {
-            out.writeLong(la[i]);
+    private static void writeSpecialCaseEntries() throws IOException {
+        for (int index = 0; index < specialCaseCount; index++) {
+            out.writeLong(specialCaseCutOverTimes[index]);
+            String str = (specialCaseOldCurrencies[index] != null)
+                    ? specialCaseOldCurrencies[index] : "";
+            out.writeUTF(str);
+            str = (specialCaseNewCurrencies[index] != null)
+                    ? specialCaseNewCurrencies[index] : "";
+            out.writeUTF(str);
+            out.writeInt(specialCaseOldCurrenciesDefaultFractionDigits[index]);
+            out.writeInt(specialCaseNewCurrenciesDefaultFractionDigits[index]);
+            out.writeInt(specialCaseOldCurrenciesNumericCode[index]);
+            out.writeInt(specialCaseNewCurrenciesNumericCode[index]);
         }
     }
 
-    private static void writeStringArray(String[] sa, int count) throws IOException  {
-        for (int i = 0; i < count; i ++) {
-            String str = (sa[i] != null) ? sa[i] : "";
+    private static void writeOtherCurrencies() throws IOException {
+        for (int index = 0; index < otherCurrenciesCount; index++) {
+            String str = (otherCurrencies[index] != null)
+                    ? otherCurrencies[index] : "";
             out.writeUTF(str);
+            out.writeInt(otherCurrenciesDefaultFractionDigits[index]);
+            out.writeInt(otherCurrenciesNumericCode[index]);
         }
     }
+
 }
< prev index next >