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