java.lang.Object | |
↳ | com.microstrategy.utils.localization.LocaleInfo |
Class to provide locale-specific information such as date format, decimal separator, and thousands separator. Initialize a given instance of the class using a java.util.Locale object or a Windows LCID. getLocaleID and getLocale provide conversions between Windows- based locale ID's and Java Locale objects when necessary.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | MASK_COUNTRY | ||||||||||
int | MASK_CUSTOM_VARIANT | ||||||||||
int | MASK_LANGUAGE | ||||||||||
String | UNIT_CM | Centimeter measurement units | |||||||||
String | UNIT_IN | Inch measurement units | |||||||||
String | UNIT_MM | Millimeter measurement units | |||||||||
String | UNIT_PC | Pica measurement units | |||||||||
String | UNIT_PT | Point measurement units | |||||||||
String | UNIT_PX | Pixel measurement units |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
public static final Locale | NEUTRAL |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
static int |
convertJavaLocaleToLCID(Locale jLocale)
Converts a Java Locale to a Windows-based Locale ID.
| ||||||||||
static Locale |
convertLCIDToJavaLocale(int localeID)
Converts a Windows-based Locale ID to a Java Locale.
| ||||||||||
static Locale |
findBestSupportedLocale(Locale[] requested, Locale[] supported)
Returns the best supported locale given a requested list locale.
| ||||||||||
static Locale | findBestSupportedLocale(Locale target, Locale[] supported) | ||||||||||
String |
getCurrencyFormatString()
Returns the currency format string for the locale.
| ||||||||||
String |
getCurrencySymbol()
Returns the currency symbol for the locale.
| ||||||||||
int |
getCurrencySymbolPosition()
Returns the currency symbol position for the currency format corresponding to the locale.
| ||||||||||
char |
getDecimalSeparator()
Returns the decimal separator for the locale.
| ||||||||||
String |
getDecimalSeparatorString()
Returns the decimal separator for the locale as a String.
| ||||||||||
char |
getGroupingSeparator()
Returns the grouping (thousands) separator for the locale.
| ||||||||||
String |
getGroupingSeparatorString()
Returns the grouping (thousands) separator for the locale as a String.
| ||||||||||
static LocaleInfo |
getInstance()
Get a new LocaleInfo instance corresponding to the default locale.
| ||||||||||
static LocaleInfo |
getInstance(Locale jLocale)
Get a new LocaleInfo instance corresponding to the Locale passed in.
| ||||||||||
static LocaleInfo |
getInstance(int localeID)
Get a new LocaleInfo instance corresponding to the Windows-based locale ID passed
in.
| ||||||||||
String | getListSeparator() | ||||||||||
Locale |
getLocale()
Returns the Java Locale for this object.
| ||||||||||
int |
getLocaleID()
Returns the Windows-based locale ID corresponding to the Java Locale for this object.
| ||||||||||
String |
getShortDateFormatString()
Returns the short date format string for the locale.
| ||||||||||
static void |
init(InputStream localesXML)
This should only be called ONCE during application initialization,
as it's an expensive operation (involves file I/O and synchronization).
| ||||||||||
static void | init(MessagesManager localesXML) | ||||||||||
static Locale[] | parseAcceptLanguage(String acceptLanguage) | ||||||||||
String |
resolveMeasurementUnits(String unitPreference)
The method will resolve the measurement units the application is supposed
to work in association with the use preferences set.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Centimeter measurement units
Inch measurement units
Millimeter measurement units
Pica measurement units
Point measurement units
Pixel measurement units
Converts a Java Locale to a Windows-based Locale ID.
jLocale | Java locale |
---|
IllegalArgumentException | Indicates that a Windows-based locale ID could not be found for the Java Locale passed in. |
---|
Converts a Windows-based Locale ID to a Java Locale. If the LCID is not codified in this class
or declared in locales.xml, a custom Locale instance will be returned with getLanguage()
= LCID & MASK_LANGUAGE
, getCountry()
= (LCID & MASK_COUNTRY
) >>> 8, and
getVariant()
= (LCID & MASK_CUSTOM_VARIANT
) >>> 24.
localeID | the LCID |
---|
IllegalArgumentException |
---|
Returns the best supported locale given a requested list locale. If either requested or supported arrays are empty, null is returned.
Returns the currency format string for the locale. Note that the string returned is not localized (for example, "," and "." are used for the grouping and decimal separators, repectively). The character used for the currency symbol is 'ยค'.
UnsupportedOperationException | Thrown if decimal format information could not be obtained for the locale. |
---|
Returns the currency symbol for the locale. This can be multiple characters.
Returns the currency symbol position for the currency format corresponding to the locale.
This will be a value from EnumGridNumberCurrencyPosition
.
Only the positive currency format string is considered when locating the position. The
algorithm is as follows: If the symbol is found in the currency format prefix, we return
LEFT_SPACE if the symbol is followed by a space and LEFT otherwise. If the symbol is
found in the currency format suffix, we return RIGHT_SPACE if the symbol is preceeded by
a space and RIGHT otherwise. If the symbol is not found in the format string, we return LEFT.
UnsupportedOperationException | Thrown if decimal format information could not be obtained for the locale. |
---|
Returns the decimal separator for the locale. This is the same symbol that would be returned by DecimalFormatSymbols.getDecimalSeparator. For example, in the U.S. locale, this would be '.'.
Returns the decimal separator for the locale as a String. This is the same symbol that would be returned by DecimalFormatSymbols.getDecimalSeparator. For example, in the U.S. locale, this would be ".". Note that the locale may have a different monetary decimal separator.
Returns the grouping (thousands) separator for the locale. This is the same symbol that would be returned by DecimalFormatSymbols.getGroupingSeparator. For example, in the U.S. locale, this would be ','.
Returns the grouping (thousands) separator for the locale as a String. This is the same symbol that would be returned by DecimalFormatSymbols.getGroupingSeparator. For example, in the U.S. locale, this would be ",".
Get a new LocaleInfo instance corresponding to the default locale.
Get a new LocaleInfo instance corresponding to the Locale passed in.
jLocale | A java.util.Locale object corresponding to the locale for which you want formatting information. |
---|
Get a new LocaleInfo instance corresponding to the Windows-based locale ID passed in.
localeID | A Windows-based locale ID corresponding to the locale for which you want formatting information. |
---|
IllegalArgumentException | Indicates that a Java Locale could not be found for the Windows-based locale ID passed in. |
---|
Returns the Java Locale for this object.
Returns the Windows-based locale ID corresponding to the Java Locale for this object. If this object was initialized with a Windows-based locale ID, then that locale ID will be returned. Otherwise, the internal Java Locale will be converted to a Windows locale ID.
UnsupportedOperationException | Thrown in the event that the object was not originally initialized with a Windows LCID, and the internal Java Locale could not be converted into a Windows LCID. |
---|
Returns the short date format string for the locale. This is the same date format that would be returned by SimpleDateFormat.toPattern, assuming the date style is DateFormat.SHORT. For example, in the U.S. locale, this would be "M/d/yy".
UnsupportedOperationException | Thrown if the locale does not support returning a date format string. |
---|
This should only be called ONCE during application initialization, as it's an expensive operation (involves file I/O and synchronization). It's important to ensure all commonly utilized locales are declared in locales.xml for optimal performance.
localesXML | locales.xml file location |
---|
SAXException | thrown if an error occurs while parsing. |
---|---|
IOException | thrown if an error occurs while reading file. |
acceptLanguage | The HTTP Accept-Language header value as defined by http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html |
---|
The method will resolve the measurement units the application is supposed to work in association with the use preferences set.
unitPreference | String to represent the preference for measurement unit. |
---|