Package adams.core.management
Class LocaleHelper
- java.lang.Object
-
- adams.core.management.LocaleHelper
-
-
Field Summary
Fields Modifier and Type Field Description static String
FILENAME
the props file.static String
LOCALE
the locale to use.static String
LOCALE_DEFAULT
the constant for the system's default locale.static String
LOCALE_EN_US
the constant for the en_US locale.protected char
m_DecimalSeparator
the character for the decimal point.protected char
m_GroupingSeparator
the character for the grouping.protected Locale
m_LocaleEnUS
en_US locale instance.protected boolean
m_Modified
whether the settings got modified.protected Properties
m_Properties
the properties.protected static LocaleHelper
m_Singleton
the singleton.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description char
getDecimalSeparator()
Returns the character representing the separator for the decimals, i.e., "." in english locales.char
getDecimalSeparator(Locale locale)
Returns the character representing the separator for the decimals for the specified locale, i.e., "." in english locales.Locale
getDefault()
Returns the default locale.Locale
getEnUS()
Returns the en_US locale.char
getGroupingSeparator()
Returns the character representing the separator for the grouping, i.e., "," in english locales.char
getGroupingSeparator(Locale locale)
Returns the character representing the separator for the grouping for the specified locale, i.e., "," in english locales.static String[]
getIDs()
Returns all the locale IDs, includingLOCALE_DEFAULT
.String
getLocale()
Returns the locale.NumberFormat
getNumberFormat()
Returns the number format for the default locale.NumberFormat
getNumberFormat(Locale locale)
Returns the number format for the specified locale.NumberFormat
getNumberFormatEnUS()
Returns the number format for the en_US locale.static LocaleHelper
getSingleton()
Returns the singleton.protected void
initialize()
Initializes the helper.void
initializeLocale()
Initializes the locale with the current settings.boolean
isModified()
Whether the settings got modified.void
reload()
Reloads the properties file.boolean
save()
Saves the settings in the user's home directory.void
setDefault(String value)
Sets the new default locale.void
setDefault(Locale value)
Sets the new default locale.void
setLocale(String value)
Updates the locale.static String
toString(Locale l)
Returns the locale as string.static Locale
valueOf(String str)
Returns a locale generated from the string (eg en, en_US).
-
-
-
Field Detail
-
FILENAME
public static final String FILENAME
the props file.- See Also:
- Constant Field Values
-
LOCALE
public static final String LOCALE
the locale to use.- See Also:
- Constant Field Values
-
LOCALE_DEFAULT
public static final String LOCALE_DEFAULT
the constant for the system's default locale.- See Also:
- Constant Field Values
-
LOCALE_EN_US
public static final String LOCALE_EN_US
the constant for the en_US locale.- See Also:
- Constant Field Values
-
m_Singleton
protected static LocaleHelper m_Singleton
the singleton.
-
m_Properties
protected Properties m_Properties
the properties.
-
m_Modified
protected boolean m_Modified
whether the settings got modified.
-
m_DecimalSeparator
protected char m_DecimalSeparator
the character for the decimal point.
-
m_GroupingSeparator
protected char m_GroupingSeparator
the character for the grouping.
-
m_LocaleEnUS
protected Locale m_LocaleEnUS
en_US locale instance.
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the helper.
-
initializeLocale
public void initializeLocale()
Initializes the locale with the current settings.
-
isModified
public boolean isModified()
Whether the settings got modified.- Returns:
- true if modified
-
getLocale
public String getLocale()
Returns the locale.- Returns:
- the locale
-
setLocale
public void setLocale(String value)
Updates the locale.- Parameters:
value
- the locale
-
getDefault
public Locale getDefault()
Returns the default locale.- Returns:
- the default
-
setDefault
public void setDefault(String value)
Sets the new default locale.- Parameters:
value
- the new default
-
setDefault
public void setDefault(Locale value)
Sets the new default locale.- Parameters:
value
- the new default
-
getEnUS
public Locale getEnUS()
Returns the en_US locale.- Returns:
- the en_US locale
-
getDecimalSeparator
public char getDecimalSeparator()
Returns the character representing the separator for the decimals, i.e., "." in english locales.- Returns:
- the character
-
getDecimalSeparator
public char getDecimalSeparator(Locale locale)
Returns the character representing the separator for the decimals for the specified locale, i.e., "." in english locales.- Parameters:
locale
- the locale to get the separator for- Returns:
- the character
-
getGroupingSeparator
public char getGroupingSeparator()
Returns the character representing the separator for the grouping, i.e., "," in english locales.- Returns:
- the character
-
getGroupingSeparator
public char getGroupingSeparator(Locale locale)
Returns the character representing the separator for the grouping for the specified locale, i.e., "," in english locales.- Parameters:
locale
- the locale to get the separator for- Returns:
- the character
-
getNumberFormat
public NumberFormat getNumberFormat()
Returns the number format for the default locale. Grouping is always disabled.- Returns:
- the format
- See Also:
getNumberFormat(Locale)
-
getNumberFormat
public NumberFormat getNumberFormat(Locale locale)
Returns the number format for the specified locale. Grouping is always disabled.- Parameters:
locale
- the locale to get the format for- Returns:
- the format
-
getNumberFormatEnUS
public NumberFormat getNumberFormatEnUS()
Returns the number format for the en_US locale. Grouping is always disabled.- Returns:
- the format
- See Also:
getNumberFormat(Locale)
-
reload
public void reload()
Reloads the properties file. Discards any unsaved settings.
-
save
public boolean save()
Saves the settings in the user's home directory.- Returns:
- true if successfully saved
-
getSingleton
public static LocaleHelper getSingleton()
Returns the singleton.- Returns:
- the singleton
-
toString
public static String toString(Locale l)
Returns the locale as string.- Parameters:
l
- the locale object to convert- Returns:
- the generated string
-
valueOf
public static Locale valueOf(String str)
Returns a locale generated from the string (eg en, en_US).- Parameters:
str
- the string to convert to a locale- Returns:
- the generated locale
-
getIDs
public static String[] getIDs()
Returns all the locale IDs, includingLOCALE_DEFAULT
.- Returns:
- the IDs
-
-