Enable build with iniparser v 3.1
[platform/framework/native/appfw.git] / src / locales / FLcl_DateTimeSymbolsImpl.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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 /**
18  * @file        FLcl_DateTimeSymbolsImpl.cpp
19  * @brief       This is the implementation file for _DateTimeSymbolsImpl class.
20  */
21
22 #include <unique_ptr.h>
23
24 #include <FBaseSysLog.h>
25 #include <FLclDateTimeSymbols.h>
26 #include "FLcl_DateTimeSymbolsImpl.h"
27 #include "FLcl_LocaleData.h"
28 #include "FLcl_LocaleImpl.h"
29 #include "FLcl_LocaleManagerImpl.h"
30
31 using namespace Tizen::Base;
32 using namespace Tizen::Base::Collection;
33 using namespace Tizen::Base::Utility;
34
35 namespace Tizen { namespace Locales
36 {
37
38 static const int ERAS_COUNT = 2;
39 static const int MONTH_COUNT = 12;
40 static const int WEEKDAYS_COUNT = 7;
41 static const int AM_PM_COUNT =2;
42
43 static const int MAX_TIMEZONE_NAME = 4;
44
45 _DateTimeSymbolsImpl::_DateTimeSymbolsImpl(void)
46         : __pErasList(null)
47         , __pMonthsList(null)
48         , __pShortMonthsList(null)
49         , __pWeekdaysList(null)
50         , __pShortWeekdaysList(null)
51         , __pAmPmList(null)
52         , __pTimeZonesMap(null)
53         , __pIcuDateFormatSymbols(null)
54         , __CalendarType(CALENDAR_GREGORIAN)
55 {
56 }
57
58 _DateTimeSymbolsImpl::~_DateTimeSymbolsImpl(void)
59 {
60         ReleaseAll();
61         if (__pIcuDateFormatSymbols)
62         {
63                 delete __pIcuDateFormatSymbols;
64         }
65 }
66
67 result
68 _DateTimeSymbolsImpl::Initialize(CalendarType calendarType)
69 {
70         return Initialize(_LocaleManagerImpl::GetSystemLocale(), calendarType);
71 }
72
73 result
74 _DateTimeSymbolsImpl::Initialize(const Locale& locale, CalendarType calendarType)
75 {
76         SysTryReturnResult(NID_LCL, _LocaleImpl::IsSupported(locale), E_INVALID_ARG, "Given locale is not supported");
77
78         UErrorCode ec = U_ZERO_ERROR;
79         __pIcuDateFormatSymbols = new U_ICU_NAMESPACE::DateFormatSymbols(_LocaleData::GetIcuLocale(locale), ec);
80         SysTryReturnResult(NID_LCL, __pIcuDateFormatSymbols, E_OUT_OF_MEMORY, "It is not enough memory.");
81
82         __pErasList = GetSymbolAttributeArrayN(DATE_FORMAT_SYM_ERA_LIST);
83         __pMonthsList = GetSymbolAttributeArrayN(DATE_FORMAT_SYM_MONTH_LIST);
84         __pShortMonthsList = GetSymbolAttributeArrayN(DATE_FORMAT_SYM_SHORT_MONTH_LIST);
85         __pWeekdaysList = GetSymbolAttributeArrayN(DATE_FORMAT_SYM_WEEKDAY_LIST);
86         __pShortWeekdaysList = GetSymbolAttributeArrayN(DATE_FORMAT_SYM_SHORT_WEEKDAY_LIST);
87         __pAmPmList = GetSymbolAttributeArrayN(DATE_FORMAT_SYM_AM_PM_LIST);
88         __CalendarType = calendarType;
89
90         return E_SUCCESS;
91 }
92
93 void
94 _DateTimeSymbolsImpl::Set(const _DateTimeSymbolsImpl* pOther)
95 {
96         SysTryReturnVoidResult(NID_LCL, pOther != null, E_INVALID_ARG,
97                                 "[%s] Invalid argument is used. pOther instance is invalid", GetErrorMessage(E_INVALID_ARG));
98         ReleaseAll();
99
100         __pErasList = CloneArrayListN(pOther->__pErasList);
101         __pMonthsList = CloneArrayListN(pOther->__pMonthsList);
102         __pShortMonthsList = CloneArrayListN(pOther->__pShortMonthsList);
103         __pWeekdaysList = CloneArrayListN(pOther->__pWeekdaysList);
104         __pShortWeekdaysList = CloneArrayListN(pOther->__pShortWeekdaysList);
105         __pAmPmList = CloneArrayListN(pOther->__pAmPmList);
106         if(pOther->__pTimeZonesMap)
107         {
108                 __pTimeZonesMap = CloneMultiHashMapN(pOther->__pTimeZonesMap);
109         }
110         __CalendarType = pOther->__CalendarType;
111
112         if(__pIcuDateFormatSymbols)
113         {
114                 delete __pIcuDateFormatSymbols;
115                 __pIcuDateFormatSymbols = null;
116         }
117         _DateTimeSymbolsImpl* pDTS = const_cast<_DateTimeSymbolsImpl*>(pOther);
118         __pIcuDateFormatSymbols = new U_ICU_NAMESPACE::DateFormatSymbols(*(pDTS->GetIcuSymbols()));
119         SysTryReturnVoidResult(NID_LCL, __pIcuDateFormatSymbols, E_OUT_OF_MEMORY, "It is not enough memory.");
120 }
121
122
123 result
124 _DateTimeSymbolsImpl::AddTimeZoneName(const String& timeZoneId, const String& concatenatedTimeZoneName, bool isOverwrite)
125 {
126         StringTokenizer tokenizer(concatenatedTimeZoneName, L"|");
127         SysTryReturnResult(NID_LCL, (tokenizer.GetTokenCount() == MAX_TIMEZONE_NAME),
128                         E_INVALID_ARG, "Invalid argument is used. %ls is invalid.", concatenatedTimeZoneName.GetPointer());
129         result r;
130
131         if (!isOverwrite)
132         {
133                 String tzName(timeZoneId);
134                 GetTimeZoneName(tzName, 0);
135
136                 r = GetLastResult();
137                 SysTryReturnResult(NID_LCL, r != E_SUCCESS, E_OBJ_ALREADY_EXIST, "The timeZoneId already exists.");
138         }
139
140         if (!__pTimeZonesMap)
141         {
142                 MultiHashMap* pMultiHashMap = new (std::nothrow) MultiHashMap(SingleObjectDeleter);
143                 SysTryReturnResult(NID_LCL, pMultiHashMap, E_OUT_OF_MEMORY, "Memory allocation failed.");
144                 pMultiHashMap->Construct();
145
146                 __pTimeZonesMap = (IMultiMap*) pMultiHashMap;
147         }
148
149         String token;
150         std::unique_ptr< String >pKey(new (std::nothrow) String(timeZoneId));
151         SysTryReturnResult(NID_LCL, pKey, E_OUT_OF_MEMORY, "Memory allocation failed");
152
153         r = E_OUT_OF_MEMORY;
154         while (tokenizer.HasMoreTokens())
155         {
156                 tokenizer.GetNextToken(token);
157                 std::unique_ptr< String >pValue(new (std::nothrow)String(token));
158                 if (pValue)
159                 {
160                         r = __pTimeZonesMap->Add(*pKey, *pValue);
161                         if (IsFailed(r))
162                         {
163                                 __pTimeZonesMap->Remove(*pKey,true);
164                                 return E_OUT_OF_MEMORY;
165                         }
166                         pValue.release();
167                 }
168         }
169
170         pKey.release();
171         return r;
172 }
173
174
175 const IList*
176 _DateTimeSymbolsImpl::GetAmPm(void) const
177 {
178         SysAssertf(__pAmPmList != null, "Not yet constructed! Construct() should be called before use");
179
180         ClearLastResult();
181         return __pAmPmList;
182 }
183
184
185 result
186 _DateTimeSymbolsImpl::SetAmPm(const String& amPm)
187 {
188         SysAssertf(__pAmPmList != null, "Not yet constructed! Construct() should be called before use");
189
190         std::unique_ptr< ArrayList > pTempArrayList(new (std::nothrow) ArrayList(SingleObjectDeleter));
191         SysTryReturnResult(NID_LCL, pTempArrayList != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
192
193         result r = SetList(pTempArrayList.get(), AM_PM_COUNT, amPm);
194         if (!IsFailed(r))
195         {
196                 delete __pAmPmList;
197                 __pAmPmList = pTempArrayList.release();
198                 int count = 0;
199                 U_ICU_NAMESPACE::UnicodeString* pIcuArray = _LocaleData::ConvertOspArrayToIcuStringArrayN(__pAmPmList, count);
200                 __pIcuDateFormatSymbols->setAmPmStrings(pIcuArray, count);
201                 delete[] pIcuArray;
202         }
203         return  r;
204 }
205
206 const IList*
207 _DateTimeSymbolsImpl::GetEras(void) const
208 {
209         SysAssertf(__pErasList != null, "Not yet constructed! Construct() should be called before use");
210         return __pErasList;
211 }
212
213 result
214 _DateTimeSymbolsImpl::SetEras(const String& eras)
215 {
216         SysAssertf(__pErasList != null, "Not yet constructed! Construct() should be called before use");
217
218         std::unique_ptr< ArrayList > pTempArrayList(new (std::nothrow) ArrayList(SingleObjectDeleter));
219         SysTryReturnResult(NID_LCL, pTempArrayList != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
220
221         result r = SetList(pTempArrayList.get(), ERAS_COUNT, eras);
222         if (!IsFailed(r))
223         {
224                 delete __pErasList;
225                 __pErasList = pTempArrayList.release();
226                 int count = 0;
227                 U_ICU_NAMESPACE::UnicodeString* pIcuArray = _LocaleData::ConvertOspArrayToIcuStringArrayN(__pErasList, count);
228                 __pIcuDateFormatSymbols->setEras(pIcuArray, count);
229                 delete[] pIcuArray;
230         }
231
232         return  r;
233 }
234
235 const IList*
236 _DateTimeSymbolsImpl::GetMonths(void) const
237 {
238         SysAssertf(__pMonthsList != null, "Not yet constructed! Construct() should be called before use");
239
240         ClearLastResult();
241         return __pMonthsList;
242 }
243
244 result
245 _DateTimeSymbolsImpl::SetMonths(const String& months)
246 {
247         SysAssertf(__pMonthsList != null, "Not yet constructed! Construct() should be called before use");
248
249         std::unique_ptr< ArrayList > pTempArrayList(new (std::nothrow) ArrayList(SingleObjectDeleter));
250         SysTryReturnResult(NID_LCL, pTempArrayList != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
251
252         result r = SetList(pTempArrayList.get(), MONTH_COUNT, months);
253         if (!IsFailed(r))
254         {
255                 delete __pMonthsList;
256                 __pMonthsList = pTempArrayList.release();
257                 int count = 0;
258                 U_ICU_NAMESPACE::UnicodeString* pIcuArray = _LocaleData::ConvertOspArrayToIcuStringArrayN(__pMonthsList, count);
259                 __pIcuDateFormatSymbols->setMonths(pIcuArray, count);
260                 delete[] pIcuArray;
261         }
262
263         return  r;
264 }
265 const IList*
266 _DateTimeSymbolsImpl::GetShortMonths(void) const
267 {
268         SysAssertf(__pShortMonthsList != null, "Not yet constructed! Construct() should be called before use");
269
270         ClearLastResult();
271         return __pShortMonthsList;
272 }
273
274 result
275 _DateTimeSymbolsImpl::SetShortMonths(const String& shortMonths)
276 {
277         SysAssertf(__pShortMonthsList != null, "Not yet constructed! Construct() should be called before use");
278
279         std::unique_ptr< ArrayList > pTempArrayList(new (std::nothrow) ArrayList(SingleObjectDeleter));
280         SysTryReturnResult(NID_LCL, pTempArrayList != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
281
282         result r = SetList(pTempArrayList.get(), MONTH_COUNT, shortMonths);
283         if (!IsFailed(r))
284         {
285                 delete __pShortMonthsList;
286                 __pShortMonthsList = pTempArrayList.release();
287                 int count = 0;
288                 U_ICU_NAMESPACE::UnicodeString* pIcuArray = _LocaleData::ConvertOspArrayToIcuStringArrayN(__pShortMonthsList, count);
289                 __pIcuDateFormatSymbols->setShortMonths(pIcuArray, count);
290                 delete[] pIcuArray;
291         }
292
293         return  r;
294 }
295
296 const IList*
297 _DateTimeSymbolsImpl::GetWeekdays(void) const
298 {
299         SysAssertf(__pWeekdaysList != null, "Not yet constructed! Construct() should be called before use");
300
301         ClearLastResult();
302         return __pWeekdaysList;
303 }
304
305 result
306 _DateTimeSymbolsImpl::SetWeekdays(const String& weekdays)
307 {
308         SysAssertf(__pWeekdaysList != null, "Not yet constructed! Construct() should be called before use");
309
310         std::unique_ptr< ArrayList > pTempArrayList(new (std::nothrow) ArrayList(SingleObjectDeleter));
311         SysTryReturnResult(NID_LCL, pTempArrayList != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
312
313         result r = SetList(pTempArrayList.get(), WEEKDAYS_COUNT, weekdays);
314         if (!IsFailed(r))
315         {
316                 delete __pWeekdaysList;
317                 __pWeekdaysList = pTempArrayList.release();
318                 int count = 0;
319                 U_ICU_NAMESPACE::UnicodeString* pIcuArray = _LocaleData::ConvertOspArrayToIcuStringArrayN(__pWeekdaysList, count);
320                 __pIcuDateFormatSymbols->setWeekdays(pIcuArray, count);
321                 delete[] pIcuArray;
322         }
323
324         return  r;
325 }
326
327
328 const IList*
329 _DateTimeSymbolsImpl::GetShortWeekdays(void) const
330 {
331         SysAssertf(__pShortWeekdaysList != null, "Not yet constructed! Construct() should be called before use");
332         ClearLastResult();
333         return __pShortWeekdaysList;
334 }
335
336 result
337 _DateTimeSymbolsImpl::SetShortWeekdays(const String& shortWeekdays)
338 {
339         SysAssertf(__pShortWeekdaysList != null, "Not yet constructed! Construct() should be called before use");
340
341         std::unique_ptr< ArrayList > pTempArrayList(new (std::nothrow) ArrayList(SingleObjectDeleter));
342         SysTryReturnResult(NID_LCL, pTempArrayList != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
343
344         result r = SetList(pTempArrayList.get(), WEEKDAYS_COUNT, shortWeekdays);
345         if (!IsFailed(r))
346         {
347                 delete __pShortWeekdaysList;
348                 __pShortWeekdaysList = pTempArrayList.release();
349                 int count = 0;
350                 U_ICU_NAMESPACE::UnicodeString* pIcuArray = _LocaleData::ConvertOspArrayToIcuStringArrayN(__pShortWeekdaysList, count);
351                 __pIcuDateFormatSymbols->setShortWeekdays(pIcuArray, count);
352                 delete[] pIcuArray;
353         }
354
355         return  r;
356 }
357
358
359 String
360 _DateTimeSymbolsImpl::GetTimeZoneName(Tizen::Base::String& timeZoneId, int timeZoneStyle)
361 {
362         SysTryReturn(NID_LCL, timeZoneStyle < MAX_TIMEZONE_NAME, String(), E_INVALID_ARG,
363                         "[%s] Invalid argument is used. timeZoneStyle(%d) is grater than MAX_TIMEZONE_NAME", GetErrorMessage(E_INVALID_ARG), timeZoneStyle);
364
365         ClearLastResult();
366
367         if (__pTimeZonesMap)
368         {
369                 std::unique_ptr< IEnumerator >pValueEnum(__pTimeZonesMap->GetValuesN(timeZoneId));
370
371                 if (pValueEnum != null)
372                 {
373                         int i = 0;
374                         String timeZoneName;
375                         while(pValueEnum->MoveNext() == E_SUCCESS)
376                         {
377                                 if (i++ == timeZoneStyle)
378                                 {
379                                         timeZoneName = *(static_cast<String*> (pValueEnum->GetCurrent()));
380                                 }
381                         }
382                         SetLastResult(E_SUCCESS);
383                         return timeZoneName;
384                 }
385         }
386
387         const IcuUnicodeString** pIcuMap = null;
388
389         int rowCount = 0;
390         int columnCount = 0;
391
392         pIcuMap = __pIcuDateFormatSymbols->getZoneStrings(rowCount, columnCount);
393         if (pIcuMap && rowCount && columnCount)
394         {
395                 for (int rc = 0; rc < rowCount; rc++)
396                 {
397                         if (timeZoneId == _LocaleData::GetOspString(pIcuMap[rc][0]))
398                         {
399                                 SetLastResult(E_SUCCESS);
400                                 return _LocaleData::GetOspString(pIcuMap[rc][timeZoneStyle+1]);
401                         }
402                 }
403         }
404         SetLastResult(E_OBJ_NOT_FOUND);
405         return String();
406 }
407
408 result
409 _DateTimeSymbolsImpl::SetTimeZoneName(const Tizen::Base::String& timeZoneId, const Tizen::Base::String& concatenatedTimeZoneName)
410 {
411         StringTokenizer tokenizer(concatenatedTimeZoneName, L"|");
412         SysTryReturnResult(NID_LCL, (tokenizer.GetTokenCount() == MAX_TIMEZONE_NAME),
413                         E_INVALID_ARG, "Invalid argument is used. %ls is invalid.", concatenatedTimeZoneName.GetPointer());
414
415         if (__pTimeZonesMap)
416         {
417                 bool check = true;
418                 __pTimeZonesMap->ContainsKey(timeZoneId, check);                           // checking if Time zone is already exist
419
420                 if (check)
421                 {
422                         __pTimeZonesMap->Remove(timeZoneId, true);
423                         return AddTimeZoneName(timeZoneId, concatenatedTimeZoneName, true);
424                 }
425         }
426
427         String tzName(timeZoneId);
428         GetTimeZoneName(tzName, 0);
429
430         result r = GetLastResult();
431
432         if(!IsFailed(r))
433         {
434                 return AddTimeZoneName(timeZoneId, concatenatedTimeZoneName, true);
435         }
436         return E_OBJ_NOT_FOUND;
437 }
438
439
440 IList*
441 _DateTimeSymbolsImpl::CloneArrayListN(const IList* pList) const
442 {
443         SysTryReturn(NID_LCL, pList, null, E_INVALID_ARG, "[%s] Invalid argument is used. pList is Null", GetErrorMessage(E_INVALID_ARG));
444
445         ClearLastResult();
446         std::unique_ptr< ArrayList > pClonedArrayList(new (std::nothrow) ArrayList(SingleObjectDeleter));
447         SysTryReturn(NID_LCL, pClonedArrayList, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
448
449         result r = pClonedArrayList->Construct(pList->GetCount());
450         SysTryReturn(NID_LCL, !IsFailed(r), null, r, "[%s] Unable to construct ArrayList.", GetErrorMessage(r));
451
452         for (int i = 0; i < pList->GetCount(); i++)
453         {
454                 std::unique_ptr< String > pClonedString(new (std::nothrow) String(*(static_cast<const String*>(pList->GetAt(i)))));
455                 SysTryReturn(NID_LCL, pClonedString, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
456
457                 r = pClonedArrayList->Add(pClonedString.get());
458                 SysTryReturn(NID_LCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed", GetErrorMessage(E_OUT_OF_MEMORY));
459
460                 pClonedString.release();
461         }
462
463         return pClonedArrayList.release();
464 }
465
466
467
468 IMultiMap*
469 _DateTimeSymbolsImpl::CloneMultiHashMapN(const Tizen::Base::Collection::IMultiMap* pMultiMap) const
470 {
471         SysTryReturn(NID_LCL, pMultiMap, null, E_INVALID_ARG, "[%s] Invalid argument is used. pMultiMap is null.", GetErrorMessage(E_INVALID_ARG));
472
473         ClearLastResult();
474
475         std::unique_ptr< MultiHashMap > pClonedMultiHashMap(new (std::nothrow) MultiHashMap(SingleObjectDeleter));
476         SysTryReturn(NID_LCL, pClonedMultiHashMap, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
477
478         result r = pClonedMultiHashMap->Construct();
479         SysTryReturn(NID_LCL, !IsFailed(r), null, r, "[%s] Unable to construct hash map.", GetErrorMessage(r));
480
481         std::unique_ptr< IList > pKeys(pMultiMap->GetKeysN());
482         r = GetLastResult();
483         SysTryReturn(NID_LCL, pKeys != null, null, r, "[%s] Unable to get key list.", GetErrorMessage(r));
484
485         for (int i = 0; i < pKeys->GetCount(); i++)
486         {
487                 String* pKey = static_cast< String* >(pKeys->GetAt(i));
488                 SysTryReturn(NID_LCL, pKey != null, null, r, "[%s] Propagated.", GetLastResult());
489
490                 std::unique_ptr< IEnumerator > pValueEnum(pMultiMap->GetValuesN(*pKey));
491                 r = GetLastResult();
492                 SysTryReturn(NID_LCL, pValueEnum != null, null, r, "[%s] Unable to get values for key.", GetErrorMessage(r));
493
494                 std::unique_ptr< String > pMapKey(new (std::nothrow)String(*pKey));
495                 SysTryReturn(NID_LCL, pMapKey != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
496
497                 while (pValueEnum->MoveNext() == E_SUCCESS)
498                 {
499                         std::unique_ptr< String > pTimeZoneName(new (std::nothrow) String(*(static_cast<String*> (pValueEnum->GetCurrent()))));
500                         if (pTimeZoneName)
501                         {
502                                 r = pClonedMultiHashMap->Add(pMapKey.get(), pTimeZoneName.get());
503                                 if (IsFailed(r))
504                                 {
505                                         pClonedMultiHashMap->Remove(*pMapKey,true);
506                                         break;
507                                 }
508
509                                 pTimeZoneName.release();
510                         }
511                         else
512                         {
513                                 pClonedMultiHashMap->Remove(*pMapKey,true);
514                                 break;
515                         }
516                 }
517
518                 pMapKey.release();
519         }
520
521         return pClonedMultiHashMap.release();
522 }
523
524 result
525 _DateTimeSymbolsImpl::SetList(Tizen::Base::Collection::ArrayList* pArrayList, int tokenCount, const Tizen::Base::String& stringWillBeTokenized)
526 {
527         StringTokenizer tokenizer(stringWillBeTokenized, L"|");
528
529         SysTryReturnResult(NID_LCL, (tokenizer.GetTokenCount() == tokenCount), E_INVALID_ARG,
530                                 "Invalid argument is used. stringWillBeTokenized=%ls", stringWillBeTokenized.GetPointer());
531         SysTryReturnResult(NID_LCL, pArrayList, E_INVALID_ARG, "Invalid argument is used. pArrayList should not be null");
532
533         result r = pArrayList->Construct(tokenCount);
534         if (!IsFailed(r))
535         {
536                 String token;
537                 std::unique_ptr< String > pListStr(null);
538                 while (tokenizer.GetNextToken(token) == E_SUCCESS)
539                 {
540                         pListStr.reset(new (std::nothrow) String(token));
541                         SysTryReturnResult(NID_LCL, pListStr, E_OUT_OF_MEMORY, "Memory allocation failed.");
542
543                         r = pArrayList->Add(pListStr.get());
544                         SysTryReturnResult(NID_LCL, r == E_SUCCESS, r, "Failed to add value to array list.");
545
546                         pListStr.release();
547                 }
548         }
549         return r;
550 }
551
552 void
553 _DateTimeSymbolsImpl::ReleaseList(IList* pList)
554 {
555         if (pList)
556         {
557                 delete pList;
558                 pList = null;
559         }
560 }
561
562 void
563 _DateTimeSymbolsImpl::ReleaseAll(void)
564 {
565         ReleaseList(__pErasList);
566         ReleaseList(__pMonthsList);
567         ReleaseList(__pShortMonthsList);
568         ReleaseList(__pWeekdaysList);
569         ReleaseList(__pShortWeekdaysList);
570         ReleaseList(__pAmPmList);
571
572         if (__pTimeZonesMap)
573         {
574                 delete __pTimeZonesMap;
575                 __pTimeZonesMap = null;
576         }
577 }
578
579 _DateTimeSymbolsImpl*
580 _DateTimeSymbolsImpl::GetDateTimeSymbolsImpl(DateTimeSymbols* pDateTimeSymbols)
581 {
582         return pDateTimeSymbols->__pDateTimeSymbolsImpl;
583 }
584
585 U_ICU_NAMESPACE::DateFormatSymbols*
586 _DateTimeSymbolsImpl::GetIcuSymbols(void)
587 {
588         return __pIcuDateFormatSymbols;
589 }
590
591 Tizen::Base::Collection::IList*
592 _DateTimeSymbolsImpl::GetSymbolAttributeArrayN(DateFormatSymbolsAttributes attributeName)
593 {
594         SysTryReturn(NID_LCL, __pIcuDateFormatSymbols, null, E_SYSTEM, "It is not initialized.");
595         ClearLastResult();
596         int count = 0;
597         const IcuUnicodeString* pIcuList = null;
598
599         switch (attributeName)
600         {
601                 case DATE_FORMAT_SYM_ERA_LIST:
602                 {
603                         pIcuList = __pIcuDateFormatSymbols->getEras(count);
604                         break;
605                 }
606                 case DATE_FORMAT_SYM_MONTH_LIST:
607                 {
608                         pIcuList = __pIcuDateFormatSymbols->getMonths(count);
609                         break;
610                 }
611                 case DATE_FORMAT_SYM_SHORT_MONTH_LIST:
612                 {
613                         pIcuList = __pIcuDateFormatSymbols->getShortMonths(count);
614                         break;
615                 }
616                 case DATE_FORMAT_SYM_WEEKDAY_LIST:
617                 {
618                         pIcuList = __pIcuDateFormatSymbols->getWeekdays(count);
619                         break;
620                 }
621                 case DATE_FORMAT_SYM_SHORT_WEEKDAY_LIST:
622                 {
623                         pIcuList = __pIcuDateFormatSymbols->getShortWeekdays(count);
624                         break;
625                 }
626                 case DATE_FORMAT_SYM_AM_PM_LIST:
627                 {
628                         pIcuList = __pIcuDateFormatSymbols->getAmPmStrings(count);
629                         break;
630                 }
631                 default:
632                 {
633                         SetLastResult(E_UNSUPPORTED_OPERATION);
634                         break;
635                 }
636         }
637
638         SysTryReturn(NID_LCL, pIcuList, null, E_SYSTEM, "It is faile to get symbols.");
639         return _LocaleData::ConvertIcuStringArrayToOspArrayN(pIcuList, count);
640 }
641
642
643 };
644 };      // Tizen::Locale
645