Class LocaleInfo
- java.lang.Object
 - 
- com.microstrategy.utils.localization.LocaleInfo
 
 
- 
public class LocaleInfo extends java.lang.ObjectClass to provide locale-specific information such as date format, decimal separator, and thousands separator. Initialize a given instance of the class using aLocaleobject or a Windows LCID. getLocaleID and getLocale provide conversions between Windows- based locale ID's and JavaLocaleobjects when necessary.- Since:
 - MicroStrategy Web 7.3.1 or earlier
 
 
- 
- 
Field Summary
Fields Modifier and Type Field Description static intMASK_COUNTRYstatic intMASK_CUSTOM_VARIANTstatic intMASK_LANGUAGEstatic java.util.LocaleNEUTRALstatic java.lang.StringUNIT_CMCentimeter measurement unitsstatic java.lang.StringUNIT_INInch measurement unitsstatic java.lang.StringUNIT_MMMillimeter measurement unitsstatic java.lang.StringUNIT_PCPica measurement unitsstatic java.lang.StringUNIT_PTPoint measurement unitsstatic java.lang.StringUNIT_PXPixel measurement units 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static intconvertJavaLocaleToLCID(java.util.Locale jLocale)Converts a Java Locale to a Windows-based Locale ID.static java.util.LocaleconvertLCIDToJavaLocale(int localeID)Converts a Windows-based Locale ID to a Java Locale.static java.util.LocalefindBestSupportedLocale(java.util.Locale[] requested, java.util.Locale[] supported)Returns the best supported locale given a requested list locale.static java.util.LocalefindBestSupportedLocale(java.util.Locale target, java.util.Locale[] supported)java.lang.StringgetCurrencyFormatString()Returns the currency format string for the locale.java.lang.StringgetCurrencySymbol()Returns the currency symbol for the locale.intgetCurrencySymbolPosition()Returns the currency symbol position for the currency format corresponding to the locale.chargetDecimalSeparator()Returns the decimal separator for the locale.java.lang.StringgetDecimalSeparatorString()Returns the decimal separator for the locale as a String.chargetGroupingSeparator()Returns the grouping (thousands) separator for the locale.java.lang.StringgetGroupingSeparatorString()Returns the grouping (thousands) separator for the locale as a String.static LocaleInfogetInstance()Get a new LocaleInfo instance corresponding to the default locale.static LocaleInfogetInstance(int localeID)Get a new LocaleInfo instance corresponding to the Windows-based locale ID passed in.static LocaleInfogetInstance(java.util.Locale jLocale)Get a new LocaleInfo instance corresponding to the Locale passed in.java.lang.StringgetListSeparator()java.util.LocalegetLocale()Returns the Java Locale for this object.intgetLocaleID()Returns the Windows-based locale ID corresponding to the Java Locale for this object.java.lang.StringgetShortDateFormatString()Returns the short date format string for the locale.static voidinit(MessagesManager localesXML)static voidinit(java.io.InputStream localesXML)This should only be called ONCE during application initialization, as it's an expensive operation (involves file I/O and synchronization).static java.util.Locale[]parseAcceptLanguage(java.lang.String acceptLanguage)java.lang.StringresolveMeasurementUnits(java.lang.String unitPreference)The method will resolve the measurement units the application is supposed to work in association with the use preferences set. 
 - 
 
- 
- 
Field Detail
- 
MASK_CUSTOM_VARIANT
public static final int MASK_CUSTOM_VARIANT
- Since:
 - MicroStrategy Web 9.0.0
 - See Also:
 - Constant Field Values
 
 
- 
MASK_LANGUAGE
public static final int MASK_LANGUAGE
- Since:
 - MicroStrategy Web 9.0.0
 - See Also:
 - Constant Field Values
 
 
- 
MASK_COUNTRY
public static final int MASK_COUNTRY
- Since:
 - MicroStrategy Web 9.0.0
 - See Also:
 - Constant Field Values
 
 
- 
NEUTRAL
public static final java.util.Locale NEUTRAL
 
- 
UNIT_CM
public static final java.lang.String UNIT_CM
Centimeter measurement units- Since:
 - MicroStrategy Web 8.0.0
 - See Also:
 - Constant Field Values
 
 
- 
UNIT_IN
public static final java.lang.String UNIT_IN
Inch measurement units- Since:
 - MicroStrategy Web 8.0.0
 - See Also:
 - Constant Field Values
 
 
- 
UNIT_MM
public static final java.lang.String UNIT_MM
Millimeter measurement units- Since:
 - MicroStrategy Web 8.0.0
 - See Also:
 - Constant Field Values
 
 
- 
UNIT_PT
public static final java.lang.String UNIT_PT
Point measurement units- Since:
 - MicroStrategy Web 8.0.0
 - See Also:
 - Constant Field Values
 
 
- 
UNIT_PC
public static final java.lang.String UNIT_PC
Pica measurement units- Since:
 - MicroStrategy Web 8.0.0
 - See Also:
 - Constant Field Values
 
 
- 
UNIT_PX
public static final java.lang.String UNIT_PX
Pixel measurement units- Since:
 - MicroStrategy Web 8.0.0
 - See Also:
 - Constant Field Values
 
 
 - 
 
- 
Method Detail
- 
getInstance
public static LocaleInfo getInstance()
Get a new LocaleInfo instance corresponding to the default locale.- Returns:
 - Reference to a newly created LocaleInfo instance.
 
 
- 
getInstance
public static LocaleInfo getInstance(java.util.Locale jLocale)
Get a new LocaleInfo instance corresponding to the Locale passed in.- Parameters:
 jLocale- A java.util.Locale object corresponding to the locale for which you want formatting information.- Returns:
 - Reference to a newly created LocaleInfo instance.
 
 
- 
getInstance
public static LocaleInfo getInstance(int localeID) throws java.lang.IllegalArgumentException
Get a new LocaleInfo instance corresponding to the Windows-based locale ID passed in.- Parameters:
 localeID- A Windows-based locale ID corresponding to the locale for which you want formatting information.- Returns:
 - Reference to a newly created LocaleInfo instance.
 - Throws:
 java.lang.IllegalArgumentException- Indicates that a Java Locale could not be found for the Windows-based locale ID passed in.
 
- 
init
public static void init(java.io.InputStream localesXML) throws org.xml.sax.SAXException, java.io.IOExceptionThis 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.- Parameters:
 localesXML- locales.xml file location- Throws:
 org.xml.sax.SAXException- thrown if an error occurs while parsing.java.io.IOException- thrown if an error occurs while reading file.- Since:
 - MicroStrategy Web 9.0.0
 
 
- 
init
public static void init(MessagesManager localesXML)
- Since:
 - MicroStrategy Web 9.0.0
 
 
- 
getShortDateFormatString
public java.lang.String getShortDateFormatString() throws java.lang.UnsupportedOperationExceptionReturns 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".- Returns:
 - The short date format string for the locale.
 - Throws:
 java.lang.UnsupportedOperationException- Thrown if the locale does not support returning a date format string.
 
- 
getDecimalSeparator
public char getDecimalSeparator()
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.
 
 
- 
getGroupingSeparator
public char getGroupingSeparator()
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 separator for the locale.
 
 
- 
getListSeparator
public java.lang.String getListSeparator()
- Since:
 - MicroStrategy Web 9.0.0
 
 
- 
getDecimalSeparatorString
public java.lang.String getDecimalSeparatorString()
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 decimal separator for the locale.
 
 
- 
getGroupingSeparatorString
public java.lang.String getGroupingSeparatorString()
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 ",".- Returns:
 - The grouping separator for the locale.
 
 
- 
getCurrencyFormatString
public java.lang.String getCurrencyFormatString() throws java.lang.UnsupportedOperationExceptionReturns 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 'ยค'.- Returns:
 - The currency format string for the locale.
 - Throws:
 java.lang.UnsupportedOperationException- Thrown if decimal format information could not be obtained for the locale.
 
- 
getCurrencySymbol
public java.lang.String getCurrencySymbol()
Returns the currency symbol for the locale. This can be multiple characters.- Returns:
 - The currency symbol for the locale.
 
 
- 
getCurrencySymbolPosition
public int getCurrencySymbolPosition() throws java.lang.UnsupportedOperationExceptionReturns the currency symbol position for the currency format corresponding to the locale. This will be a value fromEnumGridNumberCurrencyPosition. 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.- Returns:
 - The currency symbol position for the currency format corresponding to the locale.
 - Throws:
 java.lang.UnsupportedOperationException- Thrown if decimal format information could not be obtained for the locale.
 
- 
getLocale
public java.util.Locale getLocale()
Returns the Java Locale for this object.- Returns:
 - java.util.Locale
 
 
- 
getLocaleID
public int getLocaleID() throws java.lang.UnsupportedOperationExceptionReturns 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.- Returns:
 - The Windows-based locale ID corresponding to the internal locale.
 - Throws:
 java.lang.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.
 
- 
resolveMeasurementUnits
public java.lang.String resolveMeasurementUnits(java.lang.String unitPreference)
The method will resolve the measurement units the application is supposed to work in association with the use preferences set.- Parameters:
 unitPreference- String to represent the preference for measurement unit.- Returns:
 - The associated units constant.
 - Since:
 - MicroStrategy Web 8.0.0
 
 
- 
convertLCIDToJavaLocale
public static java.util.Locale convertLCIDToJavaLocale(int localeID) throws java.lang.IllegalArgumentExceptionConverts 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 withLocale.getLanguage()= LCID &MASK_LANGUAGE,Locale.getCountry()= (LCID &MASK_COUNTRY) >>> 8, andLocale.getVariant()= (LCID &MASK_CUSTOM_VARIANT) >>> 24.- Parameters:
 localeID- the LCID- Returns:
 - java.util.Locale
 - Throws:
 java.lang.IllegalArgumentException
 
- 
convertJavaLocaleToLCID
public static int convertJavaLocaleToLCID(java.util.Locale jLocale) throws java.lang.IllegalArgumentExceptionConverts a Java Locale to a Windows-based Locale ID.- Parameters:
 jLocale- Java locale- Returns:
 - localeID int
 - Throws:
 java.lang.IllegalArgumentException- Indicates that a Windows-based locale ID could not be found for the Java Locale passed in.
 
- 
findBestSupportedLocale
public static java.util.Locale findBestSupportedLocale(java.util.Locale target, java.util.Locale[] supported)- Since:
 - MicroStrategy Web 9.0.0
 
 
- 
findBestSupportedLocale
public static java.util.Locale findBestSupportedLocale(java.util.Locale[] requested, java.util.Locale[] supported)Returns the best supported locale given a requested list locale. If either requested or supported arrays are empty, null is returned.- Returns:
 - the best supported locale
 - Since:
 - MicroStrategy Web 9.0.0
 
 
- 
parseAcceptLanguage
public static java.util.Locale[] parseAcceptLanguage(java.lang.String acceptLanguage)
- Parameters:
 acceptLanguage- The HTTP Accept-Language header value as defined by http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html- Returns:
 - requested locales array sorted by quality, highest first
 - Since:
 - MicroStrategy Web 9.0.0
 
 
 - 
 
 -