Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

DateFormatSymbols Class Reference

DateFormatSymbols is a public class for encapsulating localizable date-time formatting data -- including timezone data. More...

#include <dtfmtsym.h>

Inheritance diagram for DateFormatSymbols::

UObject UMemory List of all members.

Public Methods

 DateFormatSymbols (UErrorCode &status)
 Construct a DateFormatSymbols object by loading format data from resources for the default locale, in the default calendar (Gregorian). More...

 DateFormatSymbols (const Locale &locale, UErrorCode &status)
 Construct a DateFormatSymbols object by loading format data from resources for the given locale, in the default calendar (Gregorian). More...

 DateFormatSymbols (const char *type, UErrorCode &status)
 Construct a DateFormatSymbols object by loading format data from resources for the default locale, in the default calendar (Gregorian). More...

 DateFormatSymbols (const Locale &locale, const char *type, UErrorCode &status)
 Construct a DateFormatSymbols object by loading format data from resources for the given locale, in the default calendar (Gregorian). More...

 DateFormatSymbols (const DateFormatSymbols &)
 Copy constructor. More...

DateFormatSymbols & operator= (const DateFormatSymbols &)
 Assignment operator. More...

 ~DateFormatSymbols ()
 Destructor. More...

UBool operator== (const DateFormatSymbols &other) const
 Return true if another object is semantically equal to this one. More...

UBool operator!= (const DateFormatSymbols &other) const
 Return true if another object is semantically unequal to this one. More...

const UnicodeStringgetEras (int32_t &count) const
 Gets era strings. More...

void setEras (const UnicodeString *eras, int32_t count)
 Sets era strings. More...

const UnicodeStringgetMonths (int32_t &count) const
 Gets month strings. More...

void setMonths (const UnicodeString *months, int32_t count)
 Sets month strings. More...

const UnicodeStringgetShortMonths (int32_t &count) const
 Gets short month strings. More...

void setShortMonths (const UnicodeString *shortMonths, int32_t count)
 Sets short month strings. More...

const UnicodeStringgetWeekdays (int32_t &count) const
 Gets weekday strings. More...

void setWeekdays (const UnicodeString *weekdays, int32_t count)
 Sets weekday strings. More...

const UnicodeStringgetShortWeekdays (int32_t &count) const
 Gets short weekday strings. More...

void setShortWeekdays (const UnicodeString *shortWeekdays, int32_t count)
 Sets short weekday strings. More...

const UnicodeStringgetAmPmStrings (int32_t &count) const
 Gets AM/PM strings. More...

void setAmPmStrings (const UnicodeString *ampms, int32_t count)
 Sets ampm strings. More...

const UnicodeString ** getZoneStrings (int32_t &rowCount, int32_t &columnCount) const
 Gets timezone strings. More...

void setZoneStrings (const UnicodeString *const *strings, int32_t rowCount, int32_t columnCount)
 Sets timezone strings. More...

UnicodeStringgetLocalPatternChars (UnicodeString &result) const
 Gets localized date-time pattern characters. More...

void setLocalPatternChars (const UnicodeString &newLocalPatternChars)
 Sets localized date-time pattern characters. More...

virtual UClassID getDynamicClassID () const
 ICU "poor man's RTTI", returns a UClassID for the actual class. More...


Static Public Methods

const UChar * getPatternUChars (void)
 Get the non-localized date-time pattern characters. More...

UClassID getStaticClassID ()
 ICU "poor man's RTTI", returns a UClassID for this class. More...


Private Types

typedef enum DateFormatSymbols::LastResortSize LastResortSize
enum  LastResortSize {
  kMonthNum = 13, kMonthLen = 3, kDayNum = 8, kDayLen = 2,
  kAmPmNum = 2, kAmPmLen = 3, kEraNum = 2, kEraLen = 3,
  kZoneNum = 5, kZoneLen = 4
}

Private Methods

 DateFormatSymbols ()
void initField (UnicodeString **field, int32_t &length, const ResourceBundle &data, UErrorCode &status)
void initField (UnicodeString **field, int32_t &length, const UChar *data, LastResortSize numStr, LastResortSize strLen, UErrorCode &status)
void initializeData (const Locale &, const char *type, UErrorCode &status, UBool useLastResortData=FALSE)
 Called by the constructors to actually load data from the resources. More...

void createZoneStrings (const UnicodeString *const *otherStrings)
 Create a copy, in fZoneStrings, of the given zone strings array. More...

int32_t getZoneIndex (const UnicodeString &ID) const
 Package private: used by SimpleDateFormat Gets the index for the given time zone ID to obtain the timezone strings for formatting. More...

int32_t _getZoneIndex (const UnicodeString &id) const
void dispose (void)
 Delete all the storage owned by this object. More...

void copyData (const DateFormatSymbols &other)
 Copy all of the other's data to this. More...

void disposeZoneStrings (void)
 Delete just the zone strings. More...


Static Private Methods

ResourceBundle getData (ResourceBundle &rb, const char *tag, const char *type, UErrorCode &status)
 Load data for specified 'type', falling back to gregorian if needed. More...

void assignArray (UnicodeString *&dstArray, int32_t &dstCount, const UnicodeString *srcArray, int32_t srcCount)
 Copy or alias an array in another object, as appropriate. More...

UBool arrayCompare (const UnicodeString *array1, const UnicodeString *array2, int32_t count)
 Return true if the given arrays' contents are equal, or if the arrays are identical (pointers are equal). More...


Private Attributes

UnicodeStringfEras
 Era strings. More...

int32_t fErasCount
UnicodeStringfMonths
 Month strings. More...

int32_t fMonthsCount
UnicodeStringfShortMonths
 Short month strings. More...

int32_t fShortMonthsCount
UnicodeStringfWeekdays
 Weekday strings. More...

int32_t fWeekdaysCount
UnicodeStringfShortWeekdays
 Short weekday strings. More...

int32_t fShortWeekdaysCount
UnicodeStringfAmPms
 Ampm strings. More...

int32_t fAmPmsCount
UnicodeString ** fZoneStrings
 The format data of all the timezones in this locale. More...

int32_t fZoneStringsRowCount
int32_t fZoneStringsColCount
UnicodeString fLocalPatternChars
 Localized date-time pattern characters. More...

char validLocale [50]
 valid/actual locale information these are always ICU locales, so the length should not be a problem. More...

char actualLocale [50]

Friends

class SimpleDateFormat
class DateFormatSymbolsSingleSetter

Detailed Description

DateFormatSymbols is a public class for encapsulating localizable date-time formatting data -- including timezone data.

DateFormatSymbols is used by DateFormat and SimpleDateFormat.

Rather than first creating a DateFormatSymbols to get a date-time formatter by using a SimpleDateFormat constructor, clients are encouraged to create a date-time formatter using the getTimeInstance(), getDateInstance(), or getDateTimeInstance() method in DateFormat. Each of these methods can return a date/time formatter initialized with a default format pattern along with the date-time formatting data for a given or default locale. After a formatter is created, clients may modify the format pattern using the setPattern function as so desired. For more information on using these formatter factory functions, see DateFormat.

If clients decide to create a date-time formatter with a particular format pattern and locale, they can do so with new SimpleDateFormat(aPattern, new DateFormatSymbols(aLocale)). This will load the appropriate date-time formatting data from the locale.

DateFormatSymbols objects are clonable. When clients obtain a DateFormatSymbols object, they can feel free to modify the date-time formatting data as necessary. For instance, clients can replace the localized date-time format pattern characters with the ones that they feel easy to remember. Or they can change the representative cities originally picked by default to using their favorite ones.

DateFormatSymbols are not expected to be subclassed. Data for a calendar is loaded out of resource bundles. The 'type' parameter indicates the type of calendar, for example, "gregorian" or "japanese". If the type is not gregorian (or NULL, or an empty string) then the type is appended to the resource name, for example, 'Eras_japanese' instead of 'Eras'. If the resource 'Eras_japanese' did not exist (even in root), then this class will fall back to just 'Eras', that is, Gregorian data. Therefore, the calendar implementor MUST ensure that the root locale at least contains any resources that are to be particularized for the calendar type.

Definition at line 71 of file dtfmtsym.h.


Member Typedef Documentation

typedef enum DateFormatSymbols::LastResortSize DateFormatSymbols::LastResortSize [private]
 


Member Enumeration Documentation

enum DateFormatSymbols::LastResortSize [private]
 

Enumeration values:
kMonthNum 
kMonthLen 
kDayNum 
kDayLen 
kAmPmNum 
kAmPmLen 
kEraNum 
kEraLen 
kZoneNum 
kZoneLen 

Definition at line 389 of file dtfmtsym.h.


Constructor & Destructor Documentation

DateFormatSymbols::DateFormatSymbols UErrorCode   status
 

Construct a DateFormatSymbols object by loading format data from resources for the default locale, in the default calendar (Gregorian).

NOTE: This constructor will never fail; if it cannot get resource data for the default locale, it will return a last-resort object based on hard-coded strings.

Parameters:
status  Status code. Failure results if the resources for the default cannot be found or cannot be loaded
Stable:
ICU 2.0

DateFormatSymbols::DateFormatSymbols const Locale   locale,
UErrorCode   status
 

Construct a DateFormatSymbols object by loading format data from resources for the given locale, in the default calendar (Gregorian).

Parameters:
locale  Locale to load format data from.
status  Status code. Failure results if the resources for the locale cannot be found or cannot be loaded
Stable:
ICU 2.0

DateFormatSymbols::DateFormatSymbols const char *    type,
UErrorCode   status
 

Construct a DateFormatSymbols object by loading format data from resources for the default locale, in the default calendar (Gregorian).

NOTE: This constructor will never fail; if it cannot get resource data for the default locale, it will return a last-resort object based on hard-coded strings.

Parameters:
type  Type of calendar (as returned by Calendar::getType). Will be used to access the correct set of strings. (NULL or empty string defaults to "gregorian".)
status  Status code. Failure results if the resources for the default cannot be found or cannot be loaded
Internal:
For internal use only.

DateFormatSymbols::DateFormatSymbols const Locale   locale,
const char *    type,
UErrorCode   status
 

Construct a DateFormatSymbols object by loading format data from resources for the given locale, in the default calendar (Gregorian).

Parameters:
locale  Locale to load format data from.
type  Type of calendar (as returned by Calendar::getType). Will be used to access the correct set of strings. (NULL or empty string defaults to "gregorian".)
status  Status code. Failure results if the resources for the locale cannot be found or cannot be loaded
Internal:
For internal use only.

DateFormatSymbols::DateFormatSymbols const DateFormatSymbols &   
 

Copy constructor.

Stable:
ICU 2.0

DateFormatSymbols::~DateFormatSymbols  
 

Destructor.

This is nonvirtual because this class is not designed to be subclassed.

Stable:
ICU 2.0

DateFormatSymbols::DateFormatSymbols   [private]
 


Member Function Documentation

int32_t DateFormatSymbols::_getZoneIndex const UnicodeString   id const [private]
 

UBool DateFormatSymbols::arrayCompare const UnicodeString   array1,
const UnicodeString   array2,
int32_t    count
[static, private]
 

Return true if the given arrays' contents are equal, or if the arrays are identical (pointers are equal).

Parameters:
array1  one array to be compared with.
array2  another array to be compared with.
count  the length of items to be copied.
Returns:
true if the given arrays' contents are equal, or if the arrays are identical (pointers are equal).

void DateFormatSymbols::assignArray UnicodeString *&    dstArray,
int32_t &    dstCount,
const UnicodeString   srcArray,
int32_t    srcCount
[static, private]
 

Copy or alias an array in another object, as appropriate.

Parameters:
dstArray  the copy destination array.
dstCount  fill in with the lenth of 'dstArray'.
srcArray  the source array to be copied.
srcCount  the length of items to be copied from the 'srcArray'.

void DateFormatSymbols::copyData const DateFormatSymbols &    other [private]
 

Copy all of the other's data to this.

Parameters:
other  the object to be copied.

void DateFormatSymbols::createZoneStrings const UnicodeString *const *    otherStrings [private]
 

Create a copy, in fZoneStrings, of the given zone strings array.

The member variables fZoneStringsRowCount and fZoneStringsColCount should be set already by the caller.

void DateFormatSymbols::dispose void    [private]
 

Delete all the storage owned by this object.

void DateFormatSymbols::disposeZoneStrings void    [private]
 

Delete just the zone strings.

const UnicodeString* DateFormatSymbols::getAmPmStrings int32_t &    count const
 

Gets AM/PM strings.

For example: "AM" and "PM".

Parameters:
count  Filled in with length of the array.
Returns:
the weekday strings. (DateFormatSymbols retains ownership.)
Stable:
ICU 2.0

ResourceBundle DateFormatSymbols::getData ResourceBundle   rb,
const char *    tag,
const char *    type,
UErrorCode   status
[static, private]
 

Load data for specified 'type', falling back to gregorian if needed.

Parameters:
rb  ResourceBundle
tag  Resource key to data
type  Calendar type
status  Error Status
Internal:
For internal use only.

virtual UClassID DateFormatSymbols::getDynamicClassID void    const [virtual]
 

ICU "poor man's RTTI", returns a UClassID for the actual class.

Stable:
ICU 2.2

Reimplemented from UObject.

const UnicodeString* DateFormatSymbols::getEras int32_t &    count const
 

Gets era strings.

For example: "AD" and "BC".

Parameters:
count  Filled in with length of the array.
Returns:
the era strings.
Stable:
ICU 2.0

UnicodeString& DateFormatSymbols::getLocalPatternChars UnicodeString   result const
 

Gets localized date-time pattern characters.

For example: 'u', 't', etc.

Parameters:
result  Output param which will receive the localized date-time pattern characters.
Returns:
A reference to 'result'.
Stable:
ICU 2.0

const UnicodeString* DateFormatSymbols::getMonths int32_t &    count const
 

Gets month strings.

For example: "January", "February", etc.

Parameters:
count  Filled in with length of the array.
Returns:
the month strings. (DateFormatSymbols retains ownership.)
Stable:
ICU 2.0

const UChar* DateFormatSymbols::getPatternUChars void    [static]
 

Get the non-localized date-time pattern characters.

Returns:
the non-localized date-time pattern characters
Stable:
ICU 2.0

const UnicodeString* DateFormatSymbols::getShortMonths int32_t &    count const
 

Gets short month strings.

For example: "Jan", "Feb", etc.

Parameters:
count  Filled in with length of the array.
Returns:
the short month strings. (DateFormatSymbols retains ownership.)
Stable:
ICU 2.0

const UnicodeString* DateFormatSymbols::getShortWeekdays int32_t &    count const
 

Gets short weekday strings.

For example: "Sun", "Mon", etc.

Parameters:
count  Filled in with length of the array.
Returns:
the short weekday strings. (DateFormatSymbols retains ownership.)
Stable:
ICU 2.0

UClassID DateFormatSymbols::getStaticClassID void    [static]
 

ICU "poor man's RTTI", returns a UClassID for this class.

Stable:
ICU 2.2

const UnicodeString* DateFormatSymbols::getWeekdays int32_t &    count const
 

Gets weekday strings.

For example: "Sunday", "Monday", etc.

Parameters:
count  Filled in with length of the array.
Returns:
the weekday strings. (DateFormatSymbols retains ownership.)
Stable:
ICU 2.0

int32_t DateFormatSymbols::getZoneIndex const UnicodeString   ID const [private]
 

Package private: used by SimpleDateFormat Gets the index for the given time zone ID to obtain the timezone strings for formatting.

The time zone ID is just for programmatic lookup. NOT LOCALIZED!!!

Parameters:
ID  the given time zone ID.
Returns:
the index of the given time zone ID. Returns -1 if the given time zone ID can't be located in the DateFormatSymbols object.
See also:
java.util.SimpleTimeZone

const UnicodeString** DateFormatSymbols::getZoneStrings int32_t &    rowCount,
int32_t &    columnCount
const
 

Gets timezone strings.

These strings are stored in a 2-dimensional array.

Parameters:
rowCount  Output param to receive number of rows.
columnCount  Output param to receive number of columns.
Returns:
The timezone strings as a 2-d array. (DateFormatSymbols retains ownership.)
Stable:
ICU 2.0

void DateFormatSymbols::initField UnicodeString **    field,
int32_t &    length,
const UChar *    data,
LastResortSize    numStr,
LastResortSize    strLen,
UErrorCode   status
[private]
 

void DateFormatSymbols::initField UnicodeString **    field,
int32_t &    length,
const ResourceBundle   data,
UErrorCode   status
[private]
 

void DateFormatSymbols::initializeData const Locale  ,
const char *    type,
UErrorCode   status,
UBool    useLastResortData = FALSE
[private]
 

Called by the constructors to actually load data from the resources.

Parameters:
locale  The locale to get symbols for.
type  Calendar Type (as from Calendar::getType())
status  Input/output parameter, set to success or failure code upon return.
useLastResortData  determine if use last resort data

UBool DateFormatSymbols::operator!= const DateFormatSymbols &    other const [inline]
 

Return true if another object is semantically unequal to this one.

Parameters:
other  the DateFormatSymbols object to be compared with.
Returns:
true if other is semantically unequal to this.
Stable:
ICU 2.0

Definition at line 171 of file dtfmtsym.h.

DateFormatSymbols& DateFormatSymbols::operator= const DateFormatSymbols &   
 

Assignment operator.

Stable:
ICU 2.0

UBool DateFormatSymbols::operator== const DateFormatSymbols &    other const
 

Return true if another object is semantically equal to this one.

Parameters:
other  the DateFormatSymbols object to be compared with.
Returns:
true if other is semantically equal to this.
Stable:
ICU 2.0

void DateFormatSymbols::setAmPmStrings const UnicodeString   ampms,
int32_t    count
 

Sets ampm strings.

For example: "AM" and "PM".

Parameters:
ampms  the new ampm strings. (not adopted; caller retains ownership)
count  Filled in with length of the array.
Stable:
ICU 2.0

void DateFormatSymbols::setEras const UnicodeString   eras,
int32_t    count
 

Sets era strings.

For example: "AD" and "BC".

Parameters:
eras  Array of era strings (DateFormatSymbols retains ownership.)
count  Filled in with length of the array.
Stable:
ICU 2.0

void DateFormatSymbols::setLocalPatternChars const UnicodeString   newLocalPatternChars
 

Sets localized date-time pattern characters.

For example: 'u', 't', etc.

Parameters:
newLocalPatternChars  the new localized date-time pattern characters.
Stable:
ICU 2.0

void DateFormatSymbols::setMonths const UnicodeString   months,
int32_t    count
 

Sets month strings.

For example: "January", "February", etc.

Parameters:
months  the new month strings. (not adopted; caller retains ownership)
count  Filled in with length of the array.
Stable:
ICU 2.0

void DateFormatSymbols::setShortMonths const UnicodeString   shortMonths,
int32_t    count
 

Sets short month strings.

For example: "Jan", "Feb", etc.

Parameters:
count  Filled in with length of the array.
shortMonths  the new short month strings. (not adopted; caller retains ownership)
Stable:
ICU 2.0

void DateFormatSymbols::setShortWeekdays const UnicodeString   shortWeekdays,
int32_t    count
 

Sets short weekday strings.

For example: "Sun", "Mon", etc.

Parameters:
shortWeekdays  the new short weekday strings. (not adopted; caller retains ownership)
count  Filled in with length of the array.
Stable:
ICU 2.0

void DateFormatSymbols::setWeekdays const UnicodeString   weekdays,
int32_t    count
 

Sets weekday strings.

For example: "Sunday", "Monday", etc.

Parameters:
weekdays  the new weekday strings. (not adopted; caller retains ownership)
count  Filled in with length of the array.
Stable:
ICU 2.0

void DateFormatSymbols::setZoneStrings const UnicodeString *const *    strings,
int32_t    rowCount,
int32_t    columnCount
 

Sets timezone strings.

These strings are stored in a 2-dimensional array.

Parameters:
strings  The timezone strings as a 2-d array to be copied. (not adopted; caller retains ownership)
rowCount  The number of rows (count of first index).
columnCount  The number of columns (count of second index).
Stable:
ICU 2.0


Friends And Related Function Documentation

friend class DateFormatSymbolsSingleSetter [friend]
 

Definition at line 330 of file dtfmtsym.h.

friend class SimpleDateFormat [friend]
 

Definition at line 329 of file dtfmtsym.h.


Member Data Documentation

char DateFormatSymbols::actualLocale[50] [private]
 

Definition at line 385 of file dtfmtsym.h.

UnicodeString* DateFormatSymbols::fAmPms [private]
 

Ampm strings.

For example: "AM" and "PM".

Definition at line 365 of file dtfmtsym.h.

int32_t DateFormatSymbols::fAmPmsCount [private]
 

Definition at line 366 of file dtfmtsym.h.

UnicodeString* DateFormatSymbols::fEras [private]
 

Era strings.

For example: "AD" and "BC".

Definition at line 335 of file dtfmtsym.h.

int32_t DateFormatSymbols::fErasCount [private]
 

Definition at line 336 of file dtfmtsym.h.

UnicodeString DateFormatSymbols::fLocalPatternChars [private]
 

Localized date-time pattern characters.

For example: use 'u' as 'y'.

Definition at line 378 of file dtfmtsym.h.

UnicodeString* DateFormatSymbols::fMonths [private]
 

Month strings.

For example: "January", "February", etc.

Definition at line 341 of file dtfmtsym.h.

int32_t DateFormatSymbols::fMonthsCount [private]
 

Definition at line 342 of file dtfmtsym.h.

UnicodeString* DateFormatSymbols::fShortMonths [private]
 

Short month strings.

For example: "Jan", "Feb", etc.

Definition at line 347 of file dtfmtsym.h.

int32_t DateFormatSymbols::fShortMonthsCount [private]
 

Definition at line 348 of file dtfmtsym.h.

UnicodeString* DateFormatSymbols::fShortWeekdays [private]
 

Short weekday strings.

For example: "Sun", "Mon", etc.

Definition at line 359 of file dtfmtsym.h.

int32_t DateFormatSymbols::fShortWeekdaysCount [private]
 

Definition at line 360 of file dtfmtsym.h.

UnicodeString* DateFormatSymbols::fWeekdays [private]
 

Weekday strings.

For example: "Sunday", "Monday", etc.

Definition at line 353 of file dtfmtsym.h.

int32_t DateFormatSymbols::fWeekdaysCount [private]
 

Definition at line 354 of file dtfmtsym.h.

UnicodeString** DateFormatSymbols::fZoneStrings [private]
 

The format data of all the timezones in this locale.

Definition at line 371 of file dtfmtsym.h.

int32_t DateFormatSymbols::fZoneStringsColCount [private]
 

Definition at line 373 of file dtfmtsym.h.

int32_t DateFormatSymbols::fZoneStringsRowCount [private]
 

Definition at line 372 of file dtfmtsym.h.

char DateFormatSymbols::validLocale[50] [private]
 

valid/actual locale information these are always ICU locales, so the length should not be a problem.

Definition at line 384 of file dtfmtsym.h.


The documentation for this class was generated from the following file:
Generated on Mon Nov 24 14:36:27 2003 for ICU 2.8 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001