1 /* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package libcore.icu; 18 19 import android.icu.util.TimeZone; 20 import com.android.tools.layoutlib.annotations.LayoutlibDelegate; 21 22 import android.icu.text.DateTimePatternGenerator; 23 import android.icu.util.Currency; 24 import android.icu.util.ULocale; 25 import android.icu.util.VersionInfo; 26 27 import java.util.Locale; 28 29 /** 30 * Delegate implementing the native methods of libcore.icu.ICU 31 * 32 * Through the layoutlib_create tool, the original native methods of ICU have been replaced 33 * by calls to methods of the same name in this delegate class. 34 * 35 */ 36 public class ICU_Delegate { 37 38 // --- Java delegates 39 40 @LayoutlibDelegate toLowerCase(String s, String localeName)41 /*package*/ static String toLowerCase(String s, String localeName) { 42 return s.toLowerCase(); 43 } 44 45 @LayoutlibDelegate toUpperCase(String s, String localeName)46 /*package*/ static String toUpperCase(String s, String localeName) { 47 return s.toUpperCase(); 48 } 49 50 // --- Native methods accessing ICU's database. 51 52 @LayoutlibDelegate getBestDateTimePatternNative(String skeleton, String localeName)53 /*package*/ static String getBestDateTimePatternNative(String skeleton, String localeName) { 54 return DateTimePatternGenerator.getInstance(new ULocale(localeName)) 55 .getBestPattern(skeleton); 56 } 57 58 @LayoutlibDelegate 59 @SuppressWarnings("deprecation") getCldrVersion()60 /*package*/ static String getCldrVersion() { 61 return VersionInfo.ICU_DATA_VERSION.toString(); 62 } 63 64 @LayoutlibDelegate getIcuVersion()65 /*package*/ static String getIcuVersion() { 66 return VersionInfo.ICU_VERSION.toString(); 67 } 68 69 @LayoutlibDelegate getUnicodeVersion()70 /*package*/ static String getUnicodeVersion() { 71 return VersionInfo.UNICODE_7_0.toString(); 72 } 73 74 @LayoutlibDelegate getAvailableBreakIteratorLocalesNative()75 /*package*/ static String[] getAvailableBreakIteratorLocalesNative() { 76 return new String[0]; 77 } 78 79 @LayoutlibDelegate getAvailableCalendarLocalesNative()80 /*package*/ static String[] getAvailableCalendarLocalesNative() { 81 return new String[0]; 82 } 83 84 @LayoutlibDelegate getAvailableCollatorLocalesNative()85 /*package*/ static String[] getAvailableCollatorLocalesNative() { 86 return new String[0]; 87 } 88 89 @LayoutlibDelegate getAvailableDateFormatLocalesNative()90 /*package*/ static String[] getAvailableDateFormatLocalesNative() { 91 return new String[0]; 92 } 93 94 @LayoutlibDelegate getAvailableLocalesNative()95 /*package*/ static String[] getAvailableLocalesNative() { 96 return new String[0]; 97 } 98 99 @LayoutlibDelegate getAvailableNumberFormatLocalesNative()100 /*package*/ static String[] getAvailableNumberFormatLocalesNative() { 101 return new String[0]; 102 } 103 104 @LayoutlibDelegate getAvailableCurrencyCodes()105 /*package*/ static String[] getAvailableCurrencyCodes() { 106 return new String[0]; 107 } 108 109 @LayoutlibDelegate getCurrencyCode(String locale)110 /*package*/ static String getCurrencyCode(String locale) { 111 return ""; 112 } 113 114 @LayoutlibDelegate getCurrencyDisplayName(String locale, String currencyCode)115 /*package*/ static String getCurrencyDisplayName(String locale, String currencyCode) { 116 return ""; 117 } 118 119 @LayoutlibDelegate getCurrencyFractionDigits(String currencyCode)120 /*package*/ static int getCurrencyFractionDigits(String currencyCode) { 121 return 0; 122 } 123 124 @LayoutlibDelegate getCurrencyNumericCode(String currencyCode)125 /*package*/ static int getCurrencyNumericCode(String currencyCode) { 126 return Currency.getInstance(currencyCode).getNumericCode(); 127 } 128 129 @LayoutlibDelegate getCurrencySymbol(String locale, String currencyCode)130 /*package*/ static String getCurrencySymbol(String locale, String currencyCode) { 131 return ""; 132 } 133 134 @LayoutlibDelegate getDisplayCountryNative(String countryCode, String locale)135 /*package*/ static String getDisplayCountryNative(String countryCode, String locale) { 136 return ""; 137 } 138 139 @LayoutlibDelegate getDisplayLanguageNative(String languageCode, String locale)140 /*package*/ static String getDisplayLanguageNative(String languageCode, String locale) { 141 return ""; 142 } 143 144 @LayoutlibDelegate getDisplayVariantNative(String variantCode, String locale)145 /*package*/ static String getDisplayVariantNative(String variantCode, String locale) { 146 return ""; 147 } 148 149 @LayoutlibDelegate getDisplayScriptNative(String variantCode, String locale)150 /*package*/ static String getDisplayScriptNative(String variantCode, String locale) { 151 return ""; 152 } 153 154 @LayoutlibDelegate getISO3Country(String locale)155 /*package*/ static String getISO3Country(String locale) { 156 return ""; 157 } 158 159 @LayoutlibDelegate getISO3Language(String locale)160 /*package*/ static String getISO3Language(String locale) { 161 return ""; 162 } 163 164 @LayoutlibDelegate addLikelySubtags(String locale)165 /*package*/ static String addLikelySubtags(String locale) { 166 return ""; 167 } 168 169 @LayoutlibDelegate getScript(String locale)170 /*package*/ static String getScript(String locale) { 171 return ""; 172 } 173 174 @LayoutlibDelegate getISOLanguagesNative()175 /*package*/ static String[] getISOLanguagesNative() { 176 return Locale.getISOLanguages(); 177 } 178 179 @LayoutlibDelegate getISOCountriesNative()180 /*package*/ static String[] getISOCountriesNative() { 181 return Locale.getISOCountries(); 182 } 183 184 @LayoutlibDelegate setDefaultLocale(String locale)185 /*package*/ static void setDefaultLocale(String locale) { 186 ICU.setDefaultLocale(locale); 187 } 188 189 @LayoutlibDelegate getDefaultLocale()190 /*package*/ static String getDefaultLocale() { 191 return ICU.getDefaultLocale(); 192 } 193 194 @LayoutlibDelegate getTZDataVersion()195 /*package*/ static String getTZDataVersion() { 196 return TimeZone.getTZDataVersion(); 197 } 198 } 199