コード例 #1
0
 /**
  * Writes a loadNamesMapNative method for the current locale, based on its the supplied names map
  * and its superclass (if any).
  *
  * <p>If no new names are added for this locale over its superclass, the method is omitted
  * entirely.
  *
  * @param writer SourceWriter instance to use for writing the class
  * @param currencies array of valid currency names in the order they should be listed
  * @param allCurrencyData map of currency codes to currency data for the current locale, including
  *     all inherited currencies data
  */
 private void writeNamesMethodNative(
     SourceWriter writer, String[] currencies, Map<String, CurrencyInfo> allCurrencyData) {
   boolean needHeader = true;
   for (String currencyCode : currencies) {
     // TODO(jat): only emit new data where it differs from superclass!
     CurrencyInfo currencyInfo = allCurrencyData.get(currencyCode);
     String displayName = currencyInfo.getDisplayName();
     if (displayName != null && !currencyCode.equals(displayName)) {
       if (needHeader) {
         needHeader = false;
         writer.println();
         writer.println("@Override");
         writer.println("protected JavaScriptObject loadNamesMapNative() {");
         writer.indent();
         writer.println(
             "return overrideMap(super.loadNamesMapNative(), loadMyNamesMapOverridesNative());");
         writer.outdent();
         writer.println("}");
         writer.println();
         writer.println("private native JavaScriptObject loadMyNamesMapOverridesNative() /*-{");
         writer.indent();
         writer.println("return {");
         writer.indent();
       }
       writer.println("\"" + quote(currencyCode) + "\": \"" + quote(displayName) + "\",");
     }
   }
   if (!needHeader) {
     writer.outdent();
     writer.println("};");
     writer.outdent();
     writer.println("}-*/;");
   }
 }
コード例 #2
0
 /**
  * Writes a loadNamesMapJava method for the current locale, based on its the supplied names map
  * and its superclass (if any).
  *
  * <p>If no new names are added for this locale over its superclass, the method is omitted
  * entirely.
  *
  * @param writer SourceWriter instance to use for writing the class
  * @param currencies array of valid currency names in the order they should be listed
  * @param allCurrencyData map of currency codes to currency data for the current locale, including
  *     all inherited currencies data
  */
 private void writeNamesMethodJava(
     SourceWriter writer, String[] currencies, Map<String, CurrencyInfo> allCurrencyData) {
   boolean needHeader = true;
   for (String currencyCode : currencies) {
     // TODO(jat): only emit new data where it differs from superclass!
     CurrencyInfo currencyInfo = allCurrencyData.get(currencyCode);
     String displayName = currencyInfo.getDisplayName();
     if (displayName != null && !currencyCode.equals(displayName)) {
       if (needHeader) {
         needHeader = false;
         writer.println();
         writer.println("@Override");
         writer.println("protected HashMap<String, String> loadNamesMapJava() {");
         writer.indent();
         writer.println("HashMap<String, String> result = super.loadNamesMapJava();");
       }
       writer.println(
           "result.put(\"" + quote(currencyCode) + "\", \"" + quote(displayName) + "\");");
     }
   }
   if (!needHeader) {
     writer.println("return result;");
     writer.outdent();
     writer.println("}");
   }
 }