• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 com.android.tools.layoutlib.annotations.LayoutlibDelegate;
20 
21 import java.util.Locale;
22 
23 /**
24  * Delegate implementing the native methods of libcore.icu.ICU
25  *
26  * Through the layoutlib_create tool, the original native methods of ICU have been replaced
27  * by calls to methods of the same name in this delegate class.
28  *
29  */
30 public class ICU_Delegate {
31 
32     // --- Java delegates
33 
34     @LayoutlibDelegate
toLowerCase(String s, String localeName)35     /*package*/ static String toLowerCase(String s, String localeName) {
36         return s.toLowerCase();
37     }
38 
39     @LayoutlibDelegate
toUpperCase(String s, String localeName)40     /*package*/ static String toUpperCase(String s, String localeName) {
41         return s.toUpperCase();
42     }
43 
44     // --- Native methods accessing ICU's database.
45 
46     @LayoutlibDelegate
getBestDateTimePattern(String skeleton, String localeName)47     /*package*/ static String getBestDateTimePattern(String skeleton, String localeName) {
48         return "";            // TODO: check what the right value should be.
49     }
50 
51     @LayoutlibDelegate
getCldrVersion()52     /*package*/ static String getCldrVersion() {
53         return "22.1.1";      // TODO: check what the right value should be.
54     }
55 
56     @LayoutlibDelegate
getIcuVersion()57     /*package*/ static String getIcuVersion() {
58         return "unknown_layoutlib";
59     }
60 
61     @LayoutlibDelegate
getUnicodeVersion()62     /*package*/ static String getUnicodeVersion() {
63         return "5.2";
64     }
65 
66     @LayoutlibDelegate
getAvailableBreakIteratorLocalesNative()67     /*package*/ static String[] getAvailableBreakIteratorLocalesNative() {
68         return new String[0];
69     }
70 
71     @LayoutlibDelegate
getAvailableCalendarLocalesNative()72     /*package*/ static String[] getAvailableCalendarLocalesNative() {
73         return new String[0];
74     }
75 
76     @LayoutlibDelegate
getAvailableCollatorLocalesNative()77     /*package*/ static String[] getAvailableCollatorLocalesNative() {
78         return new String[0];
79     }
80 
81     @LayoutlibDelegate
getAvailableDateFormatLocalesNative()82     /*package*/ static String[] getAvailableDateFormatLocalesNative() {
83         return new String[0];
84     }
85 
86     @LayoutlibDelegate
getAvailableLocalesNative()87     /*package*/ static String[] getAvailableLocalesNative() {
88         return new String[0];
89     }
90 
91     @LayoutlibDelegate
getAvailableNumberFormatLocalesNative()92     /*package*/ static String[] getAvailableNumberFormatLocalesNative() {
93         return new String[0];
94     }
95 
96     @LayoutlibDelegate
getAvailableCurrencyCodes()97     /*package*/ static String[] getAvailableCurrencyCodes() {
98         return new String[0];
99     }
100 
101     @LayoutlibDelegate
getCurrencyCode(String locale)102     /*package*/ static String getCurrencyCode(String locale) {
103         return "";
104     }
105 
106     @LayoutlibDelegate
getCurrencyDisplayName(String locale, String currencyCode)107     /*package*/ static String getCurrencyDisplayName(String locale, String currencyCode) {
108         return "";
109     }
110 
111     @LayoutlibDelegate
getCurrencyFractionDigits(String currencyCode)112     /*package*/ static int getCurrencyFractionDigits(String currencyCode) {
113         return 0;
114     }
115 
116     @LayoutlibDelegate
getCurrencySymbol(String locale, String currencyCode)117     /*package*/ static String getCurrencySymbol(String locale, String currencyCode) {
118         return "";
119     }
120 
121     @LayoutlibDelegate
getDisplayCountryNative(String countryCode, String locale)122     /*package*/ static String getDisplayCountryNative(String countryCode, String locale) {
123         return "";
124     }
125 
126     @LayoutlibDelegate
getDisplayLanguageNative(String languageCode, String locale)127     /*package*/ static String getDisplayLanguageNative(String languageCode, String locale) {
128         return "";
129     }
130 
131     @LayoutlibDelegate
getDisplayVariantNative(String variantCode, String locale)132     /*package*/ static String getDisplayVariantNative(String variantCode, String locale) {
133         return "";
134     }
135 
136     @LayoutlibDelegate
getISO3CountryNative(String locale)137     /*package*/ static String getISO3CountryNative(String locale) {
138         return "";
139     }
140 
141     @LayoutlibDelegate
getISO3LanguageNative(String locale)142     /*package*/ static String getISO3LanguageNative(String locale) {
143         return "";
144     }
145 
146     @LayoutlibDelegate
addLikelySubtags(String locale)147     /*package*/ static String addLikelySubtags(String locale) {
148         return "";
149     }
150 
151     @LayoutlibDelegate
getScript(String locale)152     /*package*/ static String getScript(String locale) {
153         return "";
154     }
155 
156     @LayoutlibDelegate
getISOLanguagesNative()157     /*package*/ static String[] getISOLanguagesNative() {
158         return Locale.getISOLanguages();
159     }
160 
161     @LayoutlibDelegate
getISOCountriesNative()162     /*package*/ static String[] getISOCountriesNative() {
163         return Locale.getISOCountries();
164     }
165 
166     @LayoutlibDelegate
initLocaleDataImpl(String locale, LocaleData result)167     /*package*/ static boolean initLocaleDataImpl(String locale, LocaleData result) {
168 
169         // Used by Calendar.
170         result.firstDayOfWeek = Integer.valueOf(1);
171         result.minimalDaysInFirstWeek = Integer.valueOf(1);
172 
173         // Used by DateFormatSymbols.
174         result.amPm = new String[] { "AM", "PM" };
175         result.eras = new String[] { "BC", "AD" };
176 
177         result.longMonthNames = new String[] { "January", "February", "March", "April", "May",
178                 "June", "July", "August", "September", "October", "November", "December" };
179         result.shortMonthNames = new String[] { "Jan", "Feb", "Mar", "Apr", "May",
180                 "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
181         result.longStandAloneMonthNames = result.longMonthNames;
182         result.shortStandAloneMonthNames = result.shortMonthNames;
183 
184         result.longWeekdayNames = new String[] {
185                 "Monday" ,"Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" };
186         result.shortWeekdayNames = new String[] {
187                 "Mon" ,"Tue", "Wed", "Thu", "Fri", "Sat", "Sun" };
188         result.longStandAloneWeekdayNames = result.longWeekdayNames;
189         result.shortStandAloneWeekdayNames = result.shortWeekdayNames;
190 
191         result.fullTimeFormat = "";
192         result.longTimeFormat = "";
193         result.mediumTimeFormat = "";
194         result.shortTimeFormat = "";
195 
196         result.fullDateFormat = "";
197         result.longDateFormat = "";
198         result.mediumDateFormat = "";
199         result.shortDateFormat = "";
200 
201         // Used by DecimalFormatSymbols.
202         result.zeroDigit = '0';
203         result.decimalSeparator = '.';
204         result.groupingSeparator = ',';
205         result.patternSeparator = ' ';
206         result.percent = '%';
207         result.perMill = '\u2030';
208         result.monetarySeparator = ' ';
209         result.minusSign = '-';
210         result.exponentSeparator = "e";
211         result.infinity = "\u221E";
212         result.NaN = "NaN";
213         // Also used by Currency.
214         result.currencySymbol = "$";
215         result.internationalCurrencySymbol = "USD";
216 
217         // Used by DecimalFormat and NumberFormat.
218         result.numberPattern = "%f";
219         result.integerPattern = "%d";
220         result.currencyPattern = "%s";
221         result.percentPattern = "%f";
222 
223         return true;
224     }
225 }
226