2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file FLcl_LocaleData.h
19 * @brief This is the header file for _LocaleData class.
21 #ifndef _FLCL_INTERNAL_LOCALE_DATA_H_
22 #define _FLCL_INTERNAL_LOCALE_DATA_H_
25 #include <unicode/locid.h>
26 #include <unicode/timezone.h>
27 #include <unicode/basictz.h>
28 #include <unicode/simpletz.h>
29 #include <unicode/decimfmt.h>
30 #include <unicode/dtfmtsym.h>
31 #include <unicode/smpdtfmt.h>
32 #include <unicode/calendar.h>
33 #include <unicode/gregocal.h>
34 #include <FLclLocale.h>
35 #include <FLclDateTimeSymbols.h>
36 #include <FLclDateTimeFormatter.h>
37 #include <FBaseString.h>
38 #include <FBaseColHashMap.h>
39 #include <FBaseColArrayList.h>
40 #include "FLcl_NumberFormatterImpl.h"
41 #include "FLcl_DateTimeSymbolsImpl.h"
42 #include "FLcl_FieldPosition.h"
45 typedef UParseError IcuUParseError;
46 typedef UDate IcuUDate;
47 typedef UChar IcuUChar;
49 typedef U_ICU_NAMESPACE::UnicodeString IcuUnicodeString;
50 typedef U_ICU_NAMESPACE::StringEnumeration IcuStringEnumeration;
51 typedef U_ICU_NAMESPACE::Locale IcuLocale;
52 typedef U_ICU_NAMESPACE::TimeZone IcuTimeZone;
53 typedef U_ICU_NAMESPACE::BasicTimeZone IcuBasicTimeZone;
54 typedef U_ICU_NAMESPACE::SimpleTimeZone IcuSimpleTimeZone;
55 typedef U_ICU_NAMESPACE::DecimalFormatSymbols IcuDecimalFormatSymbols;
56 typedef U_ICU_NAMESPACE::Calendar IcuCalendar;
57 typedef U_ICU_NAMESPACE::GregorianCalendar IcuGregorianCalendar;
58 typedef U_ICU_NAMESPACE::InitialTimeZoneRule IcuInitialTimeZoneRule;
59 typedef U_ICU_NAMESPACE::AnnualTimeZoneRule IcuAnnualTimeZoneRule;
60 typedef U_ICU_NAMESPACE::DateTimeRule IcuDateTimeRule;
61 typedef U_ICU_NAMESPACE::NumberFormat IcuNumberFormat;
62 typedef U_ICU_NAMESPACE::DecimalFormat IcuDecimalFormat;
63 typedef U_ICU_NAMESPACE::FieldPosition IcuFieldPosition;
65 typedef U_ICU_NAMESPACE::DateFormatSymbols IcuDateFormatSymbols;
66 typedef U_ICU_NAMESPACE::DateFormat IcuDateFormat;
67 typedef U_ICU_NAMESPACE::SimpleDateFormat IcuSimpleDateFormat;
69 namespace Tizen { namespace Locales
74 * Possible DST rule mode
82 AFTER_THE_SPECIFIED_DAY,
83 BEFORE_THE_SPECIFIED_DAY,
84 BACKWARD_FROM_END_OF_MONTH
89 * @brief This class is for loading the @e locale data.
92 * _LocaleData is represented locale data which is specific localized.
93 * This class is used by other classed in locale namespace to load the localized data.
98 : public Tizen::Base::Object
102 // Construct Operations
105 * Creates an @b uninitialized instance.
107 * @remarks After creating an instance of this class, you must explicitly call the @e Construct() method
108 * to initialize the instance.
115 * Destroys this instance.
117 virtual ~_LocaleData(void);
123 Tizen::Base::Collection::ArrayList* ConvertIcuStringArrayToOspArrayN(const IcuUnicodeString* pIcuStrList, int count);
124 IcuUnicodeString* ConvertOspArrayToIcuStringArrayN(const Tizen::Base::Collection::IList* pIcuStrList, int& count);
126 // Methods to support Locale
127 const IcuLocale& GetIcuLocale(void);
128 IcuLocale GetIcuLocale(const Tizen::Locales::Locale& ospLocale);
131 static Tizen::Base::String GetOspString(const IcuUnicodeString& icuStr);
132 static U_ICU_NAMESPACE::UnicodeString GetIcuString(const Tizen::Base::String& ospString);
133 static void GetIcuString(const Tizen::Base::String& ospStr, IcuUnicodeString& icuStr);
135 static IcuUDate GetIcuDate(Tizen::Base::DateTime date);
136 static IcuFieldPosition GetIcuFieldPosition(_FieldPosition pos);
138 // Methods to support Locale
139 bool IsLocaleSupported();
140 result SetLocale(const Locale& ospLocale);
142 // Methods to support NumberSymbols
143 result GetNumberSymbols(const Locale &locale, Tizen::Base::String symbols[]);
145 // Methods to support NumberFormatter
146 result SetNumberFormatter(const Locale& locale, NumberFormatterStyle style);
147 result FormatNumber(long number, _FieldPosition& pos, Tizen::Base::String& str);
148 result FormatNumber(double number, _FieldPosition& pos, Tizen::Base::String& str);
149 result ApplyNumberPattern(const Tizen::Base::String& pattern, bool localized);
151 Tizen::Base::String GetNumberFormatterStringAttributes(NumberFormatterAttributes attrName);
152 void SetNumberFormatterAttributes(const Tizen::Base::String& newValue, NumberFormatterAttributes attrName);
154 int GetNumberFormatterIntAttributes(NumberFormatterAttributes attrName);
155 void SetNumberFormatterAttributes(const int newValue, NumberFormatterAttributes attrName);
157 bool GetNumberFormatterBoolAttributes(NumberFormatterAttributes attrName);
158 void SetNumberFormatterAttributes(const bool newValue, NumberFormatterAttributes attrName);
161 // Methods to support DateTimeSymbols
162 result SetDateFormatSymbols(const Locale& locale);
163 Tizen::Base::Collection::IList* GetDateFormatSymbolAttrArrayN(DateFormatSymbolsAttributes attrName);
165 // Methods to support DateTimeFormatter
166 result SetDateTimeFormatter(DateTimeStyle dateStyle, DateTimeStyle timeStyle, const Locale& locale);
167 result FormatDateTime(const Tizen::Base::DateTime& date, Tizen::Base::String& str);
168 result FormatDateTime(const Calendar& calendar, Tizen::Base::String& str);
169 Tizen::Base::String GetDateTimePattern();
170 result SetDateTimePattern(const Tizen::Base::String& pattern);
171 DateTimeSymbols* GetDateTimeSymbolsN(DateTimeSymbols* pDateTimeSymbols);
172 result SetDateTimeSymbols(const DateTimeSymbols& newValue);
175 // Methods to support TimeZone
176 result SetStartTimeRule(IcuSimpleTimeZone& zone, const TimeRule* pOspTimeRule);
177 result SetEndTimeRule(IcuSimpleTimeZone& zone, const TimeRule* pOspTimeRule);
179 // Methods to support Calendar
180 void SetGregorianWeekCountData(const Locale& ospLocale, DayOfWeek& firstDayOfWeek, short& minDaysInFirstWeek);
182 // Lists from ICU TimeZone
183 Tizen::Base::Collection::IList* GetAvailableTimeZonesN(void);
184 Tizen::Base::Collection::IList* GetAvailableTimeZonesN(int rawOffset);
187 _LocaleData(const _LocaleData& localeData);
188 _LocaleData& operator =(const _LocaleData& localeData);
191 IcuLocale __icuLocale;
192 IcuDecimalFormat* __pIcuNumberFormatter;
193 IcuDateFormatSymbols* __pIcuDateFormatSymbols;
194 IcuSimpleDateFormat* __pIcuDateFormat;
200 #endif // _FLCL_INTERNAL_LOCALE_DATA_H_