public class Locale extends Object implements DataConverter
Modifier and Type | Field and Description |
---|---|
static int |
AM_PM
Use with getString()/fromString() -
The full name of the AM/PM.
|
static int |
COUNTRY
Use with getString() -
The full name of the locale country.
|
static int |
COUNTRY_ENGLISH
Use with getString() -
The full English name of the locale country.
|
static int |
COUNTRY_NATIVE
Use with getString() -
The full native name of the locale country.
|
static int |
COUNTRY_SHORT
Use with getString() -
The three letter (uppercase) ISO country code.
|
static int |
CURRENCY
Use with getString()/fromString() -
Gets the currencty symbol.
|
static int |
CurrencyDecimalSeparator |
static int |
CurrencyDigits |
static int |
CurrencyGrouping |
static int |
CurrencySymbol |
static int |
CurrencyThousandsSeparator |
static int |
DATE_SEPARATOR
Use with getString() -
The character(s) for the date separator.
|
static int |
DAY
Use with getString()/fromString() -
The full name of the day which is equivalent to Monday to Sunday, where 1 == Monday, 2 == Tuesday.
|
static int |
DAY_OF_WEEK
Use with getString()/fromString() -
The full name of a DAY IN THE WEEK.
|
static int |
DAYS_IN_FIRST_WEEK
Use with getString() -
The minimum number of days required in the first week of the year.
|
static int |
DecimalSeparator |
static int |
defaultID
This is the ID to use as the default locale identifier.
|
static int |
DigitGrouping |
static int |
FIRST_DAY_OF_WEEK
Use with getString() -
The index of the first day of the week where 1 = Monday, 2 = Tuesday, ...
|
static int |
FORCE_CREATION
This is an options for createFor() it tells the system
to create a Locale that always reports the specified language and country
even if the Locale is not actually supported by the underlying system.
|
static int |
FORMAT_NO_ROUNDING
Option for format() methods.
|
static int |
FractionalDigits |
static int |
HAS_WILD_CARDS
A compare option.
|
static int |
IGNORE_CASE
An option for getStringComparer.
|
static int |
IGNORE_NONSPACE
An option for getStringComparer.
|
static int |
IGNORE_SYMBOLS
An option for getStringComparer.
|
static int |
InternationalCurrencyDigits |
static int |
InternationalCurrencySymbol |
static int |
LANGUAGE
Use with getString() -
The full name of the locale language.
|
static int |
LANGUAGE_ENGLISH
Use with getString() -
The ISO English name of the locale language.
|
static int |
LANGUAGE_NATIVE
Use with getString() -
The full native name of the locale language.
|
static int |
LANGUAGE_SHORT
Use with getString() -
The ISO two letter (lowercase) name of the locale language.
|
static int |
LeadingZeros |
static int |
ListSeparator |
static int |
LOCALE_NEUTRAL
This is the native Win32 definition of a Neutral locale ID.
|
static int |
LOCALE_SYSTEM_DEFAULT
This is the native Win32 definition of the system default locale ID.
|
static int |
LOCALE_USER_DEFAULT
This is the native Win32 definition of the user default locale ID.
|
static int |
LONG_DATE_FORMAT
Use with getString() -
The format for the long date display.
|
static int |
MONTH
Use with getString()/fromString() -
The full name of a month.
|
static int |
MONTH_YEAR_FORMAT
Use with getString() -
The correct format for displaying month and year only.
|
protected int |
myLocalID
Do not use or move this variable.
|
static int |
NativeDigits |
static int |
NegativeCurrencyMode |
static int |
NegativeNumberMode |
static int |
NegativeSign |
static int |
PositiveCurrencyMode |
static int |
PositiveSign |
static int |
SHORT_DATE_FORMAT
Use with getString() -
The format for the short date display.
|
static int |
SHORT_DAY
Use with getString()/fromString() -
The short name of the day which is equivalent to Monday to Sunday, where 1 == Monday, 2 == Tuesday.
|
static int |
SHORT_DAY_OF_WEEK
Use with getString()/fromString() -
The short name of a DAY IN THE WEEK.
|
static int |
SHORT_MONTH
Use with getString()/fromString() -
The short name of a month.
|
static int |
ThousandsSeparator |
static int |
TIME_FORMAT
Use with getString() -
The format for the time display.
|
static int |
TIME_SEPARATOR
Use with getString() -
The character(s) for the time separator.
|
static String |
unknownString
This is the value that will be returned by getString() in some instances if the
value is not known.
|
static int |
USMeasurment |
Constructor and Description |
---|
Locale()
Creates a new default Locale object.
|
Locale(boolean dontSetId)
This creates a Locale without an ID.
|
Locale(int id)
Creates a new Locale object with the specified ID.
|
Locale(Locale locale,
boolean forceSupport)
Create a Locale from a non-null java.util.Locale.
|
Locale(String language,
String country,
boolean forceSupport)
Create a Locale for the specified language and optional country.
|
Modifier and Type | Method and Description |
---|---|
static int |
calendarDayToLocaleDay(int calendarDay)
This converts the Calendar constants SUNDAY to SATURDAY to the locale representations
of these values in the range 1 to 7, where 1 = Monday and 7 = Sunday.
|
static int |
calendarMonthToLocaleMonth(int calendarMonth)
This converts the Calendar constants JANUARY to UNDECIMBER to the locale representations
of these values in the range 1 to 13, where 1 = January and 13 = UNDECIMBER
|
void |
changeCase(char[] ch,
int start,
int length,
boolean toUpper)
This converts the character array to either upper case or lower case.
|
char |
changeCase(char c,
boolean toUpper)
This converts the character to either upper case or lower case.
|
int |
compare(char[] one,
int oneOffset,
int oneLength,
char[] two,
int twoOffset,
int twoLength,
int options)
Compare two sections of character arrays.
|
int |
compare(char one,
char two,
int options)
Compare two characters.
|
int |
compare(String one,
String two,
int options)
Compare two strings.
|
static String |
convertCountryCode(String countryCode)
This will convert a three letter (uppercase) ISO country code to the two letter (uppercase) ISO country code
OR the other way.
|
boolean |
convertData(Wrapper source,
Class sourceType,
Wrapper dest,
Class destType)
Return true if the conversion was successfull.
|
static Locale |
createFor(String language,
String country,
int options) |
static int |
createID(String language,
String country,
int options)
This should create a locale ID based on
the ISO two character language and country codes.
|
boolean |
equals(Object other)
Returns if this object is considered equal to the other object.
|
CharArray |
format(double value,
String format,
CharArray destination,
int options)
This is for formatting floating point number values.
|
String |
format(double value,
String format,
int options)
This is for formatting floating point number values.
|
CharArray |
format(int value,
String format,
CharArray destination,
int options)
This is for formatting integer number values.
|
String |
format(int value,
String format,
int options)
This is for formatting integer number values.
|
CharArray |
format(long value,
String format,
CharArray destination,
int options)
This is for formatting long integer number values.
|
String |
format(long value,
String format,
int options)
This is for formatting long integer number values.
|
CharArray |
formatCurrency(double value,
String format,
CharArray destination,
int options)
This is for formatting floating point number values as currency.
|
String |
formatCurrency(double value,
String format,
int options)
This is for formatting floating point number values as currency.
|
static Locale |
fromJavaLocale(Locale locale)
Get a re-used eve.sys.Locale from a java.util.Locale.
|
int |
fromString(int what,
char[] data,
int offset,
int length,
int options)
This is the reverse of getString() - it takes a locale dependent string
and returns the value associated with it.
|
int |
fromString(int what,
String str,
int options)
This is the reverse of getString() - it takes a locale dependent string
and returns the value associated with it.
|
static int[] |
getAllIDs(int options)
Get an array of all supported Locale IDs
|
int |
getCalendarForMonth(Time time,
int[] dayOfWeekLayout,
int[] dayOfMonthLayout,
boolean wrapAround)
Get the calendar layout for the month/year that the specified Time is currently set for.
|
static Locale |
getDefault() |
String |
getString(int what)
This is the same as getString(what,0,0);
|
String |
getString(int what,
int forValue,
int options)
This is used to retrieve locale specific information as a String.
|
String |
getString(int what,
String defaultValue) |
Comparer |
getStringComparer(int options)
Get a locale specific string comparer.
|
int |
hashCode()
Returns a hashCode for the object.
|
static int |
localeDayToCalendarDay(int localeDay)
This converts locale values in the range 1 to 7, where 1 = Monday and 7 = Sunday
into the Calendar constants SUNDAY to SATURDAY.
|
static int |
localeMonthToCalendarMonth(int localeMonth)
This converts locale values in the range 1 to 13, where 1 = January and 13 = Undecimber
into the Calendar constants JANUARY to UNDECIMBER.
|
double |
parseCurrency(char[] value,
int offset,
int length,
String format) |
double |
parseCurrency(String value,
String format) |
double |
parseDouble(char[] value,
int offset,
int length,
String format) |
double |
parseDouble(String value,
String format) |
int |
parseInt(char[] value,
int offset,
int length,
String format) |
int |
parseInt(String value,
String format) |
long |
parseLong(char[] value,
int offset,
int length,
String format) |
long |
parseLong(String value,
String format) |
void |
set(int id)
Set the ID for this locale.
|
static boolean |
setDefault(String language,
String country,
int options)
This attempts to set what the default language and (optionally) country for the
application.
|
Locale |
toJavaLocale() |
static Locale |
toJavaLocale(int id) |
String |
toString()
This returns an object which implements LocalResource.
|
static boolean |
unknown(String value)
This checks if the value is either null or the unknownString.
|
protected int myLocalID
public static final int MONTH
public static final int SHORT_MONTH
public static final int DAY_OF_WEEK
public static final int SHORT_DAY_OF_WEEK
public static final int CURRENCY
public static final int AM_PM
public static final int DAY
public static final int SHORT_DAY
public static final int FIRST_DAY_OF_WEEK
public static final int LANGUAGE
public static final int LANGUAGE_ENGLISH
public static final int LANGUAGE_NATIVE
public static final int LANGUAGE_SHORT
public static final int TIME_SEPARATOR
public static final int DATE_SEPARATOR
public static final int TIME_FORMAT
public static final int SHORT_DATE_FORMAT
public static final int LONG_DATE_FORMAT
public static final int MONTH_YEAR_FORMAT
public static final int COUNTRY
public static final int COUNTRY_ENGLISH
public static final int COUNTRY_NATIVE
public static final int COUNTRY_SHORT
public static final int DAYS_IN_FIRST_WEEK
public static final int FORMAT_NO_ROUNDING
public static final int LOCALE_NEUTRAL
public static final int LOCALE_USER_DEFAULT
public static final int LOCALE_SYSTEM_DEFAULT
public static int defaultID
public static final String unknownString
public static final int ListSeparator
public static final int USMeasurment
public static final int DecimalSeparator
public static final int ThousandsSeparator
public static final int DigitGrouping
public static final int FractionalDigits
public static final int LeadingZeros
public static final int NegativeNumberMode
public static final int NativeDigits
public static final int CurrencySymbol
public static final int InternationalCurrencySymbol
public static final int CurrencyDecimalSeparator
public static final int CurrencyThousandsSeparator
public static final int CurrencyGrouping
public static final int CurrencyDigits
public static final int InternationalCurrencyDigits
public static final int PositiveCurrencyMode
public static final int NegativeCurrencyMode
public static final int PositiveSign
public static final int NegativeSign
public static final int FORCE_CREATION
public static final int IGNORE_CASE
public static final int IGNORE_NONSPACE
public static final int IGNORE_SYMBOLS
public static final int HAS_WILD_CARDS
public Locale()
public Locale(boolean dontSetId)
public Locale(String language, String country, boolean forceSupport) throws IllegalArgumentException
language
- The two letter lower case language specifier (e.g. "en").country
- The three letter upper case country specifier (e.g. "GBR"). This may be null.forceSupport
- If the specified language/country is not supported usually an IllegalArgumentException
will be thrown. However if this is true then a Locale will still be created, but it will only
be able to report its COUNTRY_SHORT and LANGUAGE_SHORT values (which will be same as the
language and country parameters).IllegalArgumentException
- If the specified language/country is not supported and
forceSupport is false.public Locale(Locale locale, boolean forceSupport) throws IllegalArgumentException
locale
- the Java Locale.forceSupport
- set this true if you want to force support for the locale.IllegalArgumentException
- if the locale is not supported and forceSupport is false.public Locale(int id)
id
- the ID to use for this locale.set(java.lang.String)
public int hashCode()
Object
public boolean equals(Object other)
Object
public static Locale fromJavaLocale(Locale locale)
locale
- the non-null java.util.Locale to get a corresponding eve.sys.Locale.public Locale toJavaLocale()
public static Locale getDefault()
public static boolean setDefault(String language, String country, int options)
language
- The two letter language code.country
- The three letter country code (optional).options
- If FORCE_CREATION is used as an option BUT the specified language/country does is not supported,
then the default locale will
still report this language and country as its language and country
but will not be able to provide any other info or services.public static Locale toJavaLocale(int id)
public void set(int id)
id
- the ID to use for this locale.public static String convertCountryCode(String countryCode)
public static int createID(String language, String country, int options)
language
- the ISO-639 two character language specifier.country
- the ISO-3166 three character country specifier - this can
be null and the first locale with the specified language will be used.options
- options for creating the ID. None are defined yet.public static Locale createFor(String language, String country, int options)
language
- the ISO-639 two character language specifier.country
- the ISO-3166 three character country specifier - this can
be null and the first locale with the specified language will be used.options
- options for creating the ID. The only supported option is FORCE_CREATIONpublic String getString(int what, int forValue, int options)
what
- should be one of MONTH, SHORT_MONTH, etc.forValue
- should be a value relative to the "what" parameter.
e.g. if (what == MONTH) value should be a number for 1 to 12.options
- options for getting the information. None are defined yet.public String getString(int what)
public int fromString(int what, char[] data, int offset, int length, int options)
what
- should be one of MONTH, SHORT_MONTH, DAY, SHORT_DAY or AM_PMdata
- an array of characters to parse.offset
- the start of the characters in the array.length
- the length of the characters to parse in the array.options
- options for getting the information. None are defined yet.public int fromString(int what, String str, int options)
what
- should be one of MONTH, SHORT_MONTH, DAY, SHORT_DAY or AM_PMstr
- should be a string to parse.options
- options for getting the information. None are defined yet.public Comparer getStringComparer(int options)
options
- IGNORE_CASE, IGNORE_NONSPACE, IGNORE_SYMBOLS possibly OR'ed together.public static int[] getAllIDs(int options)
options
- None defined yet.public int compare(char one, char two, int options)
one
- A charactertwo
- A characteroptions
- IGNORE_CASE.public int compare(char[] one, int oneOffset, int oneLength, char[] two, int twoOffset, int twoLength, int options)
one
- The first array.oneOffset
- The start index.oneLength
- The number of characters to compare.two
- The second array.twoOffset
- The start index.twoLength
- The number of characters to compare.options
- IGNORE_CASE, IGNORE_NONSPACE, IGNORE_SYMBOLS, HAS_WILD_CARDS.public int compare(String one, String two, int options)
one
- The first String.two
- The second Stringoptions
- IGNORE_CASE, IGNORE_NONSPACE, IGNORE_SYMBOLS, HAS_WILD_CARDS.public char changeCase(char c, boolean toUpper)
public void changeCase(char[] ch, int start, int length, boolean toUpper)
public String toString()
public static boolean unknown(String value)
public static int calendarDayToLocaleDay(int calendarDay)
public static int localeDayToCalendarDay(int localeDay)
public static int calendarMonthToLocaleMonth(int calendarMonth)
public static int localeMonthToCalendarMonth(int localeMonth)
public int parseInt(char[] value, int offset, int length, String format) throws NumberFormatException
NumberFormatException
public long parseLong(char[] value, int offset, int length, String format) throws NumberFormatException
NumberFormatException
public double parseDouble(char[] value, int offset, int length, String format) throws NumberFormatException
NumberFormatException
public double parseCurrency(char[] value, int offset, int length, String format) throws NumberFormatException
NumberFormatException
public int parseInt(String value, String format) throws NumberFormatException
NumberFormatException
public long parseLong(String value, String format) throws NumberFormatException
NumberFormatException
public double parseDouble(String value, String format) throws NumberFormatException
NumberFormatException
public double parseCurrency(String value, String format) throws NumberFormatException
NumberFormatException
public CharArray format(int value, String format, CharArray destination, int options)
value
- the value to format.format
- This should be String that can hold the following characters:destination
- the destination CharArray to append the data to, or null
to create and return a new one.options
- formatting options - none are currently defined for formatting
int or long values.public CharArray format(long value, String format, CharArray destination, int options)
value
- the value to format.format
- This should be String that can hold the following characters:destination
- the destination CharArray to append the data to, or null
to create and return a new one.options
- formatting options - none are currently defined for formatting
int or long values.public CharArray format(double value, String format, CharArray destination, int options)
value
- the value to format.format
- This should be String that can hold the following characters:No zeros before the decimal point indicates no fixed number of digits before the decimal point.
destination
- the destination CharArray to append the data to, or null
to create and return a new one.options
- formatting options - FORMAT_NO_ROUNDING to indicate that no
rounding of decimal values. should be done.public CharArray formatCurrency(double value, String format, CharArray destination, int options)
value
- the value to format.format
- This should be String that can hold the following characters:No zeros before the decimal point indicates no fixed number of digits before the decimal point.
destination
- the destination CharArray to append the data to, or null
to create and return a new one.options
- formatting options - FORMAT_NO_ROUNDING to indicate that no
rounding of decimal values. should be done.public String format(int value, String format, int options)
value
- the value to format.format
- This should be String that can hold the following characters:options
- formatting options - none are currently defined for formatting
int or long values.public String format(long value, String format, int options)
value
- the value to format.format
- This should be String that can hold the following characters:options
- formatting options - none are currently defined for formatting
int or long values.public String format(double value, String format, int options)
value
- the value to format.format
- This should be String that can hold the following characters:No zeros before the decimal point indicates no fixed number of digits before the decimal point.
options
- formatting options - FORMAT_NO_ROUNDING to indicate that no
rounding of decimal values. should be done.public String formatCurrency(double value, String format, int options)
value
- the value to format.format
- This should be String that can hold the following characters:No zeros before the decimal point indicates no fixed number of digits before the decimal point.
options
- formatting options - FORMAT_NO_ROUNDING to indicate that no
rounding of decimal values. should be done.public int getCalendarForMonth(Time time, int[] dayOfWeekLayout, int[] dayOfMonthLayout, boolean wrapAround)
time
- the Time specifying the month and year required.dayOfWeekLayout
- an array of 7 ints which will contain values from 1 = Monday to 7 = Sunday
in the appropriate location for the day of the week for the locale. The value at index 0
will be the first day of the week in this locale (which may be Monday, Sunday or possibly Saturday).dayOfMonthLayout
- an array of 35 or 42 integers where the values 1 to 31 will be stored with
1 being stored within the range 0 to 6 depending on what day it is in. The values 2, 3 etc
will follow sequentially from 1. It is possible that the values 31 and 30 may wrap around
and be placed at indexes 0 and 1 if wrapAround is true. Locations where there are no days will be set to 0.wrapAround
- if this is true then if the index of values 31 and/or 30 exceed 35 then they
will be wrapped to 0.public boolean convertData(Wrapper source, Class sourceType, Wrapper dest, Class destType)
DataConverter
convertData
in interface DataConverter