• 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
getIcuVersion()47     /*package*/ static String getIcuVersion() {
48         return "unknown_layoutlib";
49     }
50 
51     @LayoutlibDelegate
getUnicodeVersion()52     /*package*/ static String getUnicodeVersion() {
53         return "5.2";
54     }
55 
56     @LayoutlibDelegate
getAvailableBreakIteratorLocalesNative()57     /*package*/ static String[] getAvailableBreakIteratorLocalesNative() {
58         return new String[0];
59     }
60 
61     @LayoutlibDelegate
getAvailableCalendarLocalesNative()62     /*package*/ static String[] getAvailableCalendarLocalesNative() {
63         return new String[0];
64     }
65 
66     @LayoutlibDelegate
getAvailableCollatorLocalesNative()67     /*package*/ static String[] getAvailableCollatorLocalesNative() {
68         return new String[0];
69     }
70 
71     @LayoutlibDelegate
getAvailableDateFormatLocalesNative()72     /*package*/ static String[] getAvailableDateFormatLocalesNative() {
73         return new String[0];
74     }
75 
76     @LayoutlibDelegate
getAvailableLocalesNative()77     /*package*/ static String[] getAvailableLocalesNative() {
78         return new String[0];
79     }
80 
81     @LayoutlibDelegate
getAvailableNumberFormatLocalesNative()82     /*package*/ static String[] getAvailableNumberFormatLocalesNative() {
83         return new String[0];
84     }
85 
86     @LayoutlibDelegate
getAvailableCurrencyCodes()87     /*package*/ static String[] getAvailableCurrencyCodes() {
88         return new String[0];
89     }
90 
91     @LayoutlibDelegate
getCurrencyCode(String locale)92     /*package*/ static String getCurrencyCode(String locale) {
93         return "";
94     }
95 
96     @LayoutlibDelegate
getCurrencyDisplayName(String locale, String currencyCode)97     /*package*/ static String getCurrencyDisplayName(String locale, String currencyCode) {
98         return "";
99     }
100 
101     @LayoutlibDelegate
getCurrencyFractionDigits(String currencyCode)102     /*package*/ static int getCurrencyFractionDigits(String currencyCode) {
103         return 0;
104     }
105 
106     @LayoutlibDelegate
getCurrencySymbol(String locale, String currencyCode)107     /*package*/ static String getCurrencySymbol(String locale, String currencyCode) {
108         return "";
109     }
110 
111     @LayoutlibDelegate
getDisplayCountryNative(String countryCode, String locale)112     /*package*/ static String getDisplayCountryNative(String countryCode, String locale) {
113         return "";
114     }
115 
116     @LayoutlibDelegate
getDisplayLanguageNative(String languageCode, String locale)117     /*package*/ static String getDisplayLanguageNative(String languageCode, String locale) {
118         return "";
119     }
120 
121     @LayoutlibDelegate
getDisplayVariantNative(String variantCode, String locale)122     /*package*/ static String getDisplayVariantNative(String variantCode, String locale) {
123         return "";
124     }
125 
126     @LayoutlibDelegate
getISO3CountryNative(String locale)127     /*package*/ static String getISO3CountryNative(String locale) {
128         return "";
129     }
130 
131     @LayoutlibDelegate
getISO3LanguageNative(String locale)132     /*package*/ static String getISO3LanguageNative(String locale) {
133         return "";
134     }
135 
136     @LayoutlibDelegate
addLikelySubtags(String locale)137     /*package*/ static String addLikelySubtags(String locale) {
138         return "";
139     }
140 
141     @LayoutlibDelegate
getScript(String locale)142     /*package*/ static String getScript(String locale) {
143         return "";
144     }
145 
146     @LayoutlibDelegate
getISOLanguagesNative()147     /*package*/ static String[] getISOLanguagesNative() {
148         return Locale.getISOLanguages();
149     }
150 
151     @LayoutlibDelegate
getISOCountriesNative()152     /*package*/ static String[] getISOCountriesNative() {
153         return Locale.getISOCountries();
154     }
155 
156     @LayoutlibDelegate
initLocaleDataImpl(String locale, LocaleData result)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