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

DateFormatSymbols Class Reference

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

#include <dtfmtsym.h>

List of all members.

Public Methods

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

 DateFormatSymbols (const Locale& locale, UErrorCode& status)
 Construct a DateFormatSymbols object by loading format data from resources for the given locale. 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...


Static Public Methods

const UnicodeStringgetPatternChars (void)
 Get the non-localized date-time pattern characters. More...


Private Types

enum  {
  kEras, kMonths, kShortMonths, kWeekdays,
  kShortWeekdays, kAmPms, kZoneStrings
}
 The member fIsOwned is a bit field with flags indicating which of the arrays we own. More...


Private Methods

void initField (UnicodeString **field, int32_t& length, const ResourceBundle data, uint8_t ownfield, UErrorCode &status)
void initializeData (const Locale&, UErrorCode& status, UBool useLastResortData = FALSE)
 Called by the constructors to actually load data from the resources.

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

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 and reset the fIsOwned flag to indicate that arrays have been deleted.

void disposeZoneStrings (void)
 Delete just the zone strings, if they are owned by this object. More...

void setIsOwned (int32_t which, UBool isOwned)
 Sets the fIsOwned flag for the specfied string array. More...

UBool isOwned (int32_t which) const
 Tests the fIsOwned flag for the specified string array. 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...

uint8_t fIsOwned

Static Private Methods

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).


Static Private Attributes

UnicodeString fgPatternChars
 Unlocalized date-time pattern characters. More...

const UnicodeString fgLastResortMonthNames []
 These are static arrays we use only in the case where we have no resource data. More...

const UnicodeString fgLastResortDayNames []
const UnicodeString fgLastResortAmPmMarkers []
const UnicodeString fgLastResortEras []
const UnicodeString fgLastResortZoneStrings []
UnicodeString** fgLastResortZoneStringsH

Friends

class  SimpleDateFormat


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.

New DateFormatSymbols sub-classes may be added to support SimpleDateFormat for date-time formatting for additional locales.

Definition at line 58 of file dtfmtsym.h.


Member Enumeration Documentation

anonymous enum [private]
 

The member fIsOwned is a bit field with flags indicating which of the arrays we own.

This is necessary since the user may alter our symbols, but in most cases, will not, so we do not want to copy these arrays unless necessary.

Enumeration values:
kEras  
kMonths  
kShortMonths  
kWeekdays  
kShortWeekdays  
kAmPms  
kZoneStrings  

Definition at line 379 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.

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   Output param set to success of failure. Failure results if the resources for the default cannot be found or cannot be loaded
Stable:

DateFormatSymbols::DateFormatSymbols ( const Locale & locale,
UErrorCode & status )
 

Construct a DateFormatSymbols object by loading format data from resources for the given locale.

Parameters:
locale   Locale to load format data from.
status   Output param set to success of failure. Failure results if the resources for the locale cannot be found or cannot be loaded
Stable:

DateFormatSymbols::DateFormatSymbols ( const DateFormatSymbols & )
 

Copy constructor.

Stable:

DateFormatSymbols::~DateFormatSymbols ( )
 

Destructor.

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

Stable:


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).

void DateFormatSymbols::assignArray ( UnicodeString *& dstArray,
int32_t & dstCount,
const UnicodeString * srcArray,
int32_t srcCount,
const DateFormatSymbols & other,
int32_t which ) [private]
 

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

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. The fIsOwned flags are not checked or set by this method; that is the caller's responsibility.

void DateFormatSymbols::dispose ( void ) [private]
 

Delete all the storage owned by this object and reset the fIsOwned flag to indicate that arrays have been deleted.

void DateFormatSymbols::disposeZoneStrings ( void ) [private]
 

Delete just the zone strings, if they are owned by this object.

This method does NOT modify fIsOwned; the caller must handle that.

const UnicodeString * DateFormatSymbols::getAmPmStrings ( int32_t & count ) const
 

Gets AM/PM strings.

For example: "AM" and "PM".

Returns:
the weekday strings. (DateFormatSymbols retains ownership.)
Stable:

const UnicodeString * DateFormatSymbols::getEras ( int32_t & count ) const
 

Gets era strings.

For example: "AD" and "BC".

Returns:
the era strings.
Stable:

UnicodeString & DateFormatSymbols::getLocalPatternChars ( UnicodeString & result ) const
 

Gets localized date-time pattern characters.

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

Returns:
the localized date-time pattern characters.
Stable:

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:

const UnicodeString & DateFormatSymbols::getPatternChars ( void ) [inline, static]
 

Get the non-localized date-time pattern characters.

Stable:

Definition at line 227 of file dtfmtsym.h.

const UnicodeString * DateFormatSymbols::getShortMonths ( int32_t & count ) const
 

Gets short month strings.

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

Returns:
the short month strings. (DateFormatSymbols retains ownership.)
Stable:

const UnicodeString * DateFormatSymbols::getShortWeekdays ( int32_t & count ) const
 

Gets short weekday strings.

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

Returns:
the short weekday strings. (DateFormatSymbols retains ownership.)
Stable:

const UnicodeString * DateFormatSymbols::getWeekdays ( int32_t & count ) const
 

Gets weekday strings.

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

Returns:
the weekday strings. (DateFormatSymbols retains ownership.)
Stable:

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:

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

void DateFormatSymbols::initializeData ( const Locale &,
UErrorCode & status,
UBool useLastResortData = FALSE ) [private]
 

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

UBool DateFormatSymbols::isOwned ( int32_t which ) const [inline, private]
 

Tests the fIsOwned flag for the specified string array.

Definition at line 409 of file dtfmtsym.h.

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

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

Stable:

Definition at line 117 of file dtfmtsym.h.

DateFormatSymbols & DateFormatSymbols::operator= ( const DateFormatSymbols & )
 

Assignment operator.

Stable:

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

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

Stable:

Referenced by operator!=().

void DateFormatSymbols::setAmPmStrings ( const UnicodeString * ampms,
int32_t count )
 

Sets ampm strings.

For example: "AM" and "PM".

Parameters:
newAmpms   the new ampm strings. (not adopted; caller retains ownership)
Stable:

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:

void DateFormatSymbols::setIsOwned ( int32_t which,
UBool isOwned ) [inline, private]
 

Sets the fIsOwned flag for the specfied string array.

Definition at line 403 of file dtfmtsym.h.

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:

void DateFormatSymbols::setMonths ( const UnicodeString * months,
int32_t count )
 

Sets month strings.

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

Parameters:
newMonths   the new month strings. (not adopted; caller retains ownership)
Stable:

void DateFormatSymbols::setShortMonths ( const UnicodeString * shortMonths,
int32_t count )
 

Sets short month strings.

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

Parameters:
newShortMonths   the new short month strings. (not adopted; caller retains ownership)
Stable:

void DateFormatSymbols::setShortWeekdays ( const UnicodeString * shortWeekdays,
int32_t count )
 

Sets short weekday strings.

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

Parameters:
newShortWeekdays   the new short weekday strings. (not adopted; caller retains ownership)
Stable:

void DateFormatSymbols::setWeekdays ( const UnicodeString * weekdays,
int32_t count )
 

Sets weekday strings.

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

Parameters:
newWeekdays   the new weekday strings. (not adopted; caller retains ownership)
Stable:

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:


Friends And Related Function Documentation

class SimpleDateFormat [friend]
 

Definition at line 245 of file dtfmtsym.h.


Member Data Documentation

UnicodeString * DateFormatSymbols::fAmPms [private]
 

Ampm strings.

For example: "AM" and "PM".

Definition at line 280 of file dtfmtsym.h.

int32_t DateFormatSymbols::fAmPmsCount [private]
 

Definition at line 281 of file dtfmtsym.h.

UnicodeString * DateFormatSymbols::fEras [private]
 

Era strings.

For example: "AD" and "BC".

Definition at line 250 of file dtfmtsym.h.

int32_t DateFormatSymbols::fErasCount [private]
 

Definition at line 251 of file dtfmtsym.h.

uint8_t DateFormatSymbols::fIsOwned [private]
 

Definition at line 389 of file dtfmtsym.h.

UnicodeString DateFormatSymbols::fLocalPatternChars [private]
 

Localized date-time pattern characters.

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

Definition at line 293 of file dtfmtsym.h.

UnicodeString * DateFormatSymbols::fMonths [private]
 

Month strings.

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

Definition at line 256 of file dtfmtsym.h.

int32_t DateFormatSymbols::fMonthsCount [private]
 

Definition at line 257 of file dtfmtsym.h.

UnicodeString * DateFormatSymbols::fShortMonths [private]
 

Short month strings.

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

Definition at line 262 of file dtfmtsym.h.

int32_t DateFormatSymbols::fShortMonthsCount [private]
 

Definition at line 263 of file dtfmtsym.h.

UnicodeString * DateFormatSymbols::fShortWeekdays [private]
 

Short weekday strings.

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

Definition at line 274 of file dtfmtsym.h.

int32_t DateFormatSymbols::fShortWeekdaysCount [private]
 

Definition at line 275 of file dtfmtsym.h.

UnicodeString * DateFormatSymbols::fWeekdays [private]
 

Weekday strings.

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

Definition at line 268 of file dtfmtsym.h.

int32_t DateFormatSymbols::fWeekdaysCount [private]
 

Definition at line 269 of file dtfmtsym.h.

UnicodeString ** DateFormatSymbols::fZoneStrings [private]
 

The format data of all the timezones in this locale.

Definition at line 286 of file dtfmtsym.h.

int32_t DateFormatSymbols::fZoneStringsColCount [private]
 

Definition at line 288 of file dtfmtsym.h.

int32_t DateFormatSymbols::fZoneStringsRowCount [private]
 

Definition at line 287 of file dtfmtsym.h.

const UnicodeString DateFormatSymbols::fgLastResortAmPmMarkers[] [static, private]
 

Definition at line 368 of file dtfmtsym.h.

const UnicodeString DateFormatSymbols::fgLastResortDayNames[] [static, private]
 

Definition at line 367 of file dtfmtsym.h.

const UnicodeString DateFormatSymbols::fgLastResortEras[] [static, private]
 

Definition at line 369 of file dtfmtsym.h.

const UnicodeString DateFormatSymbols::fgLastResortMonthNames[] [static, private]
 

These are static arrays we use only in the case where we have no resource data.

Definition at line 366 of file dtfmtsym.h.

const UnicodeString DateFormatSymbols::fgLastResortZoneStrings[] [static, private]
 

Definition at line 370 of file dtfmtsym.h.

UnicodeString ** DateFormatSymbols::fgLastResortZoneStringsH [static, private]
 

Definition at line 371 of file dtfmtsym.h.

UnicodeString DateFormatSymbols::fgPatternChars [static, private]
 

Unlocalized date-time pattern characters.

For example: 'y', 'd', etc. All locales use the same these unlocalized pattern characters.

Definition at line 299 of file dtfmtsym.h.


The documentation for this class was generated from the following file:
Generated at Tue Jun 12 14:04:27 2001 for ICU 1.8.1 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000