2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FLcl_LocaleData.h
20 * @brief This is the header file for _LocaleData class.
22 #ifndef _FLCL_INTERNAL_LOCALE_DATA_H_
23 #define _FLCL_INTERNAL_LOCALE_DATA_H_
26 #include <unicode/locid.h>
27 #include <unicode/timezone.h>
28 #include <unicode/basictz.h>
29 #include <unicode/simpletz.h>
30 #include <unicode/decimfmt.h>
31 #include <unicode/dtfmtsym.h>
32 #include <unicode/smpdtfmt.h>
33 #include <unicode/calendar.h>
34 #include <unicode/gregocal.h>
35 #include <FLclLocale.h>
36 #include <FLclDateTimeSymbols.h>
37 #include <FLclDateTimeFormatter.h>
38 #include <FBaseString.h>
39 #include <FBaseColHashMap.h>
40 #include <FBaseColArrayList.h>
41 #include "FLcl_NumberFormatterImpl.h"
42 #include "FLcl_DateTimeSymbolsImpl.h"
43 #include "FLcl_FieldPosition.h"
46 typedef UParseError IcuUParseError;
47 typedef UDate IcuUDate;
48 typedef UChar IcuUChar;
50 typedef U_ICU_NAMESPACE::UnicodeString IcuUnicodeString;
51 typedef U_ICU_NAMESPACE::StringEnumeration IcuStringEnumeration;
52 typedef U_ICU_NAMESPACE::Locale IcuLocale;
53 typedef U_ICU_NAMESPACE::TimeZone IcuTimeZone;
54 typedef U_ICU_NAMESPACE::BasicTimeZone IcuBasicTimeZone;
55 typedef U_ICU_NAMESPACE::SimpleTimeZone IcuSimpleTimeZone;
56 typedef U_ICU_NAMESPACE::DecimalFormatSymbols IcuDecimalFormatSymbols;
57 typedef U_ICU_NAMESPACE::Calendar IcuCalendar;
58 typedef U_ICU_NAMESPACE::GregorianCalendar IcuGregorianCalendar;
59 typedef U_ICU_NAMESPACE::InitialTimeZoneRule IcuInitialTimeZoneRule;
60 typedef U_ICU_NAMESPACE::AnnualTimeZoneRule IcuAnnualTimeZoneRule;
61 typedef U_ICU_NAMESPACE::DateTimeRule IcuDateTimeRule;
62 typedef U_ICU_NAMESPACE::NumberFormat IcuNumberFormat;
63 typedef U_ICU_NAMESPACE::DecimalFormat IcuDecimalFormat;
64 typedef U_ICU_NAMESPACE::FieldPosition IcuFieldPosition;
66 typedef U_ICU_NAMESPACE::DateFormatSymbols IcuDateFormatSymbols;
67 typedef U_ICU_NAMESPACE::DateFormat IcuDateFormat;
68 typedef U_ICU_NAMESPACE::SimpleDateFormat IcuSimpleDateFormat;
70 namespace Tizen { namespace Locales
75 * Possible DST rule mode
83 AFTER_THE_SPECIFIED_DAY,
84 BEFORE_THE_SPECIFIED_DAY,
85 BACKWARD_FROM_END_OF_MONTH
90 * @brief This class is for loading the @e locale data.
93 * _LocaleData is represented locale data which is specific localized.
94 * This class is used by other classed in locale namespace to load the localized data.
99 : public Tizen::Base::Object
103 // Construct Operations
106 * Creates an @b uninitialized instance.
108 * @remarks After creating an instance of this class, you must explicitly call the @e Construct() method
109 * to initialize the instance.
116 * Destroys this instance.
118 virtual ~_LocaleData(void);
124 Tizen::Base::Collection::ArrayList* ConvertIcuStringArrayToOspArrayN(const IcuUnicodeString* pIcuStrList, int count);
125 IcuUnicodeString* ConvertOspArrayToIcuStringArrayN(const Tizen::Base::Collection::IList* pIcuStrList, int& count);
127 // Methods to support Locale
128 const IcuLocale& GetIcuLocale(void);
129 IcuLocale GetIcuLocale(const Tizen::Locales::Locale& ospLocale);
132 static Tizen::Base::String GetOspString(const IcuUnicodeString& icuStr);
133 static U_ICU_NAMESPACE::UnicodeString GetIcuString(const Tizen::Base::String& ospString);
134 static void GetIcuString(const Tizen::Base::String& ospStr, IcuUnicodeString& icuStr);
136 static IcuUDate GetIcuDate(Tizen::Base::DateTime date);
137 static IcuFieldPosition GetIcuFieldPosition(_FieldPosition pos);
139 // Methods to support Locale
140 bool IsLocaleSupported();
141 result SetLocale(const Locale& ospLocale);
143 // Methods to support NumberSymbols
144 result GetNumberSymbols(const Locale &locale, Tizen::Base::String symbols[]);
146 // Methods to support NumberFormatter
147 result SetNumberFormatter(const Locale& locale, NumberFormatterStyle style);
148 result FormatNumber(long number, _FieldPosition& pos, Tizen::Base::String& str);
149 result FormatNumber(double number, _FieldPosition& pos, Tizen::Base::String& str);
150 result ApplyNumberPattern(const Tizen::Base::String& pattern, bool localized);
152 Tizen::Base::String GetNumberFormatterStringAttributes(NumberFormatterAttributes attrName);
153 void SetNumberFormatterAttributes(const Tizen::Base::String& newValue, NumberFormatterAttributes attrName);
155 int GetNumberFormatterIntAttributes(NumberFormatterAttributes attrName);
156 void SetNumberFormatterAttributes(const int newValue, NumberFormatterAttributes attrName);
158 bool GetNumberFormatterBoolAttributes(NumberFormatterAttributes attrName);
159 void SetNumberFormatterAttributes(const bool newValue, NumberFormatterAttributes attrName);
162 // Methods to support DateTimeSymbols
163 result SetDateFormatSymbols(const Locale& locale);
164 Tizen::Base::Collection::IList* GetDateFormatSymbolAttrArrayN(DateFormatSymbolsAttributes attrName);
166 // Methods to support DateTimeFormatter
167 result SetDateTimeFormatter(DateTimeStyle dateStyle, DateTimeStyle timeStyle, const Locale& locale);
168 result FormatDateTime(const Tizen::Base::DateTime& date, Tizen::Base::String& str);
169 result FormatDateTime(const Calendar& calendar, Tizen::Base::String& str);
170 Tizen::Base::String GetDateTimePattern();
171 result SetDateTimePattern(const Tizen::Base::String& pattern);
172 DateTimeSymbols* GetDateTimeSymbolsN(DateTimeSymbols* pDateTimeSymbols);
173 result SetDateTimeSymbols(const DateTimeSymbols& newValue);
176 // Methods to support TimeZone
177 result SetStartTimeRule(IcuSimpleTimeZone& zone, const TimeRule* pOspTimeRule);
178 result SetEndTimeRule(IcuSimpleTimeZone& zone, const TimeRule* pOspTimeRule);
180 // Methods to support Calendar
181 void SetGregorianWeekCountData(const Locale& ospLocale, DayOfWeek& firstDayOfWeek, short& minDaysInFirstWeek);
183 // Lists from ICU TimeZone
184 Tizen::Base::Collection::IList* GetAvailableTimeZonesN(void);
185 Tizen::Base::Collection::IList* GetAvailableTimeZonesN(int rawOffset);
188 _LocaleData(const _LocaleData& localeData);
189 _LocaleData& operator =(const _LocaleData& localeData);
192 IcuLocale __icuLocale;
193 IcuDecimalFormat* __pIcuNumberFormatter;
194 IcuDateFormatSymbols* __pIcuDateFormatSymbols;
195 IcuSimpleDateFormat* __pIcuDateFormat;
201 #endif // _FLCL_INTERNAL_LOCALE_DATA_H_