Class LcData
- java.lang.Object
-
- com.adobe.xfa.ut.LcData
-
public class LcData extends java.lang.Object
LcData defines locale data objects in support of localization. The source of the localized data was originally Java's JDK 1.4. However this has long since been converted to use Unicode's CLDR 1.3 data. CLDR data has been slightly modified to conform to XFA standards.The C++ implementation stores locale data in a static store. Alas, the Java compiler's 64K data limit precludes us from doing the same. Instead, the Java implementation stores locale data in properties files -- one for each supported locale.
Here's a snippet of code illustrating the use of
LcData
to retrieve abbreviated month names, and retrieve a date format.import com.adobe.xfa.ut.LcData; ... LcData data = new lcData("es_ES"); String s = data.getAbbrMonthName(LcData.FEB); System.out.println(s); data = new lcData("pt_BR"); s = data.getDateFormat(LcData.SHORT); System.out.println(s);
Besides the static store, this class also maintains a more dynamic thread-local store. The application can provide its own locale data definitions to be stored in the runtime store. In general, when locale information is requested, the runtime store is searched first, then the static store. This happens on every single request, so if the runtime store changes between two calls on an LcData data instance, the two calls may return different results. In practice, LcData object have such limited lifespans that this doesn't become an issue.
To populate the runtime store, the application calls method LcData.update() with an instance of the nested class LcDada.LcRunTimeData. This class contains several arrays of strings that hold locale information. A number of public static final int constants provided may be used as indexes into these arrays.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LcData.LcRunTimeData
Nested class describing a locale's data.
-
Field Summary
Fields Modifier and Type Field Description static int
AD
static int
AM
static int
APR
static int
AUG
static int
BC
static int
CUR_DECIMAL
static int
CUR_ISONAME
static int
CUR_SYMBOL
static int
CURRENCY
static int
CURRENCY_FMT
static int
DEC
static int
DECIMAL_FMT
static int
DEFLT
static int
DEFLT_FMT
static int
FEB
static int
FRI
static int
FULL
static int
FULL_FMT
static int
INTEGRAL_FMT
static int
JAN
static int
JUL
static int
JUN
static int
KEEP_NINES
static int
LONG
static int
LONG_FMT
static int
MAR
static int
MAY
static int
MED
static int
MED_FMT
static int
MON
static int
NOV
static int
NUM_DECIMAL
static int
NUM_GROUPING
static int
NUM_MINUS
static int
NUM_PERCENT
static int
NUM_ZERO
static int
NUMERIC
static int
OCT
static int
PERCENT
static int
PERCENT_FMT
static int
PM
static int
SAT
static int
SEP
static int
SHORT
static int
SHORT_FMT
static int
SUN
static int
THU
static int
TUE
static int
WED
static int
WITH_CATEGORIES
static int
WITH_EIGHTS
static int
WITH_GROUPINGS
static int
WITH_RADIX
static int
WITH_ZEDS
static int
WITHOUT_CATEGORIES
static int
WITHOUT_GROUPINGS
static int
WITHOUT_RADIX
-
Constructor Summary
Constructors Constructor Description LcData(java.lang.String locale)
Instantiates an LcData object for the given locale.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.String
findMatchingLocale(java.lang.String sCurrencySymbol, java.lang.String sRadixSymbol, java.lang.String sGroupingSymbol)
Finds a locale who's currency, radix and grouping symbols match all of the given symbols.static LcData.LcRunTimeData
get(java.lang.String sLocale)
Gets the locale data for the given locale from this class's runtime store.java.lang.String
getAbbrMonthName(int month)
Gets the abbreviated name of the given month of the year.java.lang.String
getAbbrWeekdayName(int weekday)
Gets the abbreviated name of the given day of the week.java.lang.String
getCurrencyName()
Gets the name of the currency.java.lang.String
getCurrencyRadix()
Gets the radix of the currency.java.lang.String
getCurrencySymbol()
Gets the symbol of the currency.java.lang.String
getDateFormat(int style)
Gets the date format in the given style.java.lang.String
getDateTimeFormat(int style, int type)
Gets the datetime format in the given style.java.lang.String
getDateTimePattern()
Gets the date time pattern.java.lang.String
getEraName(int era)
Gets the name of the given era.java.lang.String
getGroupingSymbol()
Gets the grouping symbol.java.lang.String
getLocalDateFormat(int style)
Gets the local date format in the given style.java.lang.String
getLocalDateTimeFormat()
Gets the local datetime format.java.lang.String
getLocale()
Gets this LcData object's locale.static void
getLocaleNames(java.util.List<java.lang.String> oLocales)
Gets all the supported locale names.java.lang.String
getLocalTimeFormat(int style)
Gets the local time format in the given style.java.lang.String
getMeridiemName(int aspect)
Gets the name of the given aspect of the meridiem.java.lang.String
getMonthName(int month)
Gets the name of the given month of the year.java.lang.String
getNegativeSymbol()
Gets the negative symbol.java.lang.String
getNumberFormat(int style, int option)
Gets the number format in the given style.int
getNumberPrecision(java.lang.String sVal)
Gets the decimal precision of the given numeric string.java.lang.String
getNumericFormat(int style)
Gets the numeric format in the given style.java.lang.String
getPercentSymbol()
Gets the percent symbol.java.lang.String
getPositiveSymbol()
Gets the positive symbol.java.lang.String
getRadixSymbol()
Gets the radix symbol.java.lang.String
getTimeFormat(int style)
Gets the time format in the given style.java.util.List<java.lang.String>
getTypefaces()
Gets the list of typefaces.java.lang.String
getWeekDayName(int weekday)
Gets the name of the given day of the week.java.lang.String
getZeroSymbol()
Gets the native zero digit symbol.static void
reset()
Reset this class's runtime store of locale data to its internal defaults.static void
update(LcData.LcRunTimeData oLcData)
Updates (replaces) this class's runtime store of data for the given locale with the given locale data.static boolean
validate(LcData.LcRunTimeData oLcData)
Validates the given runtime locale data.static int
withPrecision(int prec)
static int
withWidth(int width)
-
-
-
Field Detail
-
SUN
public static final int SUN
- See Also:
- Constant Field Values
-
MON
public static final int MON
- See Also:
- Constant Field Values
-
TUE
public static final int TUE
- See Also:
- Constant Field Values
-
WED
public static final int WED
- See Also:
- Constant Field Values
-
THU
public static final int THU
- See Also:
- Constant Field Values
-
FRI
public static final int FRI
- See Also:
- Constant Field Values
-
SAT
public static final int SAT
- See Also:
- Constant Field Values
-
JAN
public static final int JAN
- See Also:
- Constant Field Values
-
FEB
public static final int FEB
- See Also:
- Constant Field Values
-
MAR
public static final int MAR
- See Also:
- Constant Field Values
-
APR
public static final int APR
- See Also:
- Constant Field Values
-
MAY
public static final int MAY
- See Also:
- Constant Field Values
-
JUN
public static final int JUN
- See Also:
- Constant Field Values
-
JUL
public static final int JUL
- See Also:
- Constant Field Values
-
AUG
public static final int AUG
- See Also:
- Constant Field Values
-
SEP
public static final int SEP
- See Also:
- Constant Field Values
-
OCT
public static final int OCT
- See Also:
- Constant Field Values
-
NOV
public static final int NOV
- See Also:
- Constant Field Values
-
DEC
public static final int DEC
- See Also:
- Constant Field Values
-
AM
public static final int AM
- See Also:
- Constant Field Values
-
PM
public static final int PM
- See Also:
- Constant Field Values
-
BC
public static final int BC
- See Also:
- Constant Field Values
-
AD
public static final int AD
- See Also:
- Constant Field Values
-
DEFLT
public static final int DEFLT
- See Also:
- Constant Field Values
-
FULL
public static final int FULL
- See Also:
- Constant Field Values
-
LONG
public static final int LONG
- See Also:
- Constant Field Values
-
MED
public static final int MED
- See Also:
- Constant Field Values
-
SHORT
public static final int SHORT
- See Also:
- Constant Field Values
-
NUMERIC
public static final int NUMERIC
- See Also:
- Constant Field Values
-
CURRENCY
public static final int CURRENCY
- See Also:
- Constant Field Values
-
PERCENT
public static final int PERCENT
- See Also:
- Constant Field Values
-
NUM_DECIMAL
public static final int NUM_DECIMAL
- See Also:
- Constant Field Values
-
NUM_GROUPING
public static final int NUM_GROUPING
- See Also:
- Constant Field Values
-
NUM_PERCENT
public static final int NUM_PERCENT
- See Also:
- Constant Field Values
-
NUM_MINUS
public static final int NUM_MINUS
- See Also:
- Constant Field Values
-
NUM_ZERO
public static final int NUM_ZERO
- See Also:
- Constant Field Values
-
CUR_SYMBOL
public static final int CUR_SYMBOL
- See Also:
- Constant Field Values
-
CUR_ISONAME
public static final int CUR_ISONAME
- See Also:
- Constant Field Values
-
CUR_DECIMAL
public static final int CUR_DECIMAL
- See Also:
- Constant Field Values
-
DEFLT_FMT
public static final int DEFLT_FMT
- See Also:
- Constant Field Values
-
SHORT_FMT
public static final int SHORT_FMT
- See Also:
- Constant Field Values
-
MED_FMT
public static final int MED_FMT
- See Also:
- Constant Field Values
-
LONG_FMT
public static final int LONG_FMT
- See Also:
- Constant Field Values
-
FULL_FMT
public static final int FULL_FMT
- See Also:
- Constant Field Values
-
INTEGRAL_FMT
public static final int INTEGRAL_FMT
- See Also:
- Constant Field Values
-
DECIMAL_FMT
public static final int DECIMAL_FMT
- See Also:
- Constant Field Values
-
CURRENCY_FMT
public static final int CURRENCY_FMT
- See Also:
- Constant Field Values
-
PERCENT_FMT
public static final int PERCENT_FMT
- See Also:
- Constant Field Values
-
WITHOUT_RADIX
public static final int WITHOUT_RADIX
- See Also:
- Constant Field Values
-
WITHOUT_GROUPINGS
public static final int WITHOUT_GROUPINGS
- See Also:
- Constant Field Values
-
WITH_GROUPINGS
public static final int WITH_GROUPINGS
- See Also:
- Constant Field Values
-
WITH_ZEDS
public static final int WITH_ZEDS
- See Also:
- Constant Field Values
-
WITH_EIGHTS
public static final int WITH_EIGHTS
- See Also:
- Constant Field Values
-
WITH_RADIX
public static final int WITH_RADIX
- See Also:
- Constant Field Values
-
KEEP_NINES
public static final int KEEP_NINES
- See Also:
- Constant Field Values
-
WITHOUT_CATEGORIES
public static final int WITHOUT_CATEGORIES
- See Also:
- Constant Field Values
-
WITH_CATEGORIES
public static final int WITH_CATEGORIES
- See Also:
- Constant Field Values
-
-
Method Detail
-
withWidth
public static final int withWidth(int width)
-
withPrecision
public static final int withPrecision(int prec)
-
getLocale
public java.lang.String getLocale()
Gets this LcData object's locale.- Returns:
- Locale name (e.g., "ar_SA").
-
validate
public static boolean validate(LcData.LcRunTimeData oLcData)
Validates the given runtime locale data. Applications should validate() the data before calling update().- Parameters:
oLcData
- the some runtime locale data.- Returns:
- Boolean true if valid and false otherwise.
-
reset
public static void reset()
Reset this class's runtime store of locale data to its internal defaults.
-
update
public static void update(LcData.LcRunTimeData oLcData)
Updates (replaces) this class's runtime store of data for the given locale with the given locale data.- Parameters:
oLcData
- the runtime locale data.
-
get
public static LcData.LcRunTimeData get(java.lang.String sLocale)
Gets the locale data for the given locale from this class's runtime store.- Parameters:
sLocale
- the locale name to search for.- Returns:
- The runtime locale data if found and null otherwise.
-
getWeekDayName
public java.lang.String getWeekDayName(int weekday)
Gets the name of the given day of the week.- Parameters:
weekday
- the day of the week in the range of values 0-6, where (0 = Sunday).- Returns:
- The weekday name, or the empty string upon error.
-
getAbbrWeekdayName
public java.lang.String getAbbrWeekdayName(int weekday)
Gets the abbreviated name of the given day of the week.- Parameters:
weekday
- the day of the week in the range of values 0-6, where (0 = Sunday).- Returns:
- The abbreviated weekday name, or the empty string upon error.
-
getMonthName
public java.lang.String getMonthName(int month)
Gets the name of the given month of the year.- Parameters:
month
- the month of the year in the range of values 0-11, where (0 = January).- Returns:
- The month name, or the empty string upon error.
-
getAbbrMonthName
public java.lang.String getAbbrMonthName(int month)
Gets the abbreviated name of the given month of the year.- Parameters:
month
- the month of the year in the range of values 0-11, where (0 = January).- Returns:
- The abbreviated month name, or the empty string upon error.
-
getMeridiemName
public java.lang.String getMeridiemName(int aspect)
Gets the name of the given aspect of the meridiem.- Parameters:
aspect
- an aspect of the meridiem in the range of values 0-1, where (0 = AM, 1 = PM).- Returns:
- The meridiem name, or the empty string upon error.
-
getEraName
public java.lang.String getEraName(int era)
Gets the name of the given era.- Parameters:
era
- an era of the calendar in the range of values 0-1, where (0 = BC, 1 = AD).- Returns:
- The era name, or the empty string upon error.
-
getDateFormat
public java.lang.String getDateFormat(int style)
Gets the date format in the given style.- Parameters:
style
- the style of the format in the range of values 0-4, where (0 = default, 1 = short, 2 = medium, 3 = long, 4 = full).- Returns:
- The date format.
-
getTimeFormat
public java.lang.String getTimeFormat(int style)
Gets the time format in the given style.- Parameters:
style
- the style of the format in the range of values 0-4, where (0 = default, 1 = short, 2 = medium, 3 = long, 4 = full).- Returns:
- The time format.
-
getDateTimePattern
public java.lang.String getDateTimePattern()
Gets the date time pattern.- Returns:
- The date time pattern.
-
getDateTimeFormat
public java.lang.String getDateTimeFormat(int style, int type)
Gets the datetime format in the given style.- Parameters:
style
- the style of the format in the range of values 0-4, where (0 = default, 1 = short, 2 = medium, 3 = long, 4 = full).type
- the type of the format in the range of values 0-1, where (0 = w/o picture categories, 1 = w picture categories).- Returns:
- The date time format.
-
getLocalDateFormat
public java.lang.String getLocalDateFormat(int style)
Gets the local date format in the given style.- Parameters:
style
- the style of the format in the range of values 0-4, where (0 = default, 1 = short, 2 = medium, 3 = long, 4 = full).- Returns:
- The date format.
-
getLocalTimeFormat
public java.lang.String getLocalTimeFormat(int style)
Gets the local time format in the given style.- Parameters:
style
- the style of the format in the range of values 0-4, where (0 = default, 1 = short, 2 = medium, 3 = long, 4 = full).- Returns:
- The time format.
-
getLocalDateTimeFormat
public java.lang.String getLocalDateTimeFormat()
Gets the local datetime format.This method is not functional yet.
- Returns:
- The date time format.
-
getNumericFormat
public java.lang.String getNumericFormat(int style)
Gets the numeric format in the given style.- Parameters:
style
- the style of the format in the range of values 0-2, where (0 = number, 1 = currency, 2 = percentage).- Returns:
- The numeric format.
-
getNumberFormat
public java.lang.String getNumberFormat(int style, int option)
Gets the number format in the given style.- Parameters:
style
- in the range of values 0-2, where (0 = integral, 1 = decimal, 2 = currency).option
- in the set of format options:- bit 1: reset => w/o commas; set => w/ commas.
- bit 2: reset => w/ fractional z's; set => w/ fractional 8's.
- bit 4: reset => w/o radix; set => w/ radix.
- bit 8-15: the precision.
- bit 16: reset => keep precision; set => trim precision.
- bit 17-24: the width.
-
getNumberPrecision
public int getNumberPrecision(java.lang.String sVal)
Gets the decimal precision of the given numeric string.- Returns:
- The decimal precision or 0 for integral values.
-
getCurrencyName
public java.lang.String getCurrencyName()
Gets the name of the currency.- Returns:
- The currency name or the empty string upon error.
-
getCurrencySymbol
public java.lang.String getCurrencySymbol()
Gets the symbol of the currency.- Returns:
- The currency symbol or the empty string upon error.
-
getCurrencyRadix
public java.lang.String getCurrencyRadix()
Gets the radix of the currency.- Returns:
- The currency radix or the empty string upon error.
-
getRadixSymbol
public java.lang.String getRadixSymbol()
Gets the radix symbol.- Returns:
- The radix symbol or the empty string upon error.
-
getGroupingSymbol
public java.lang.String getGroupingSymbol()
Gets the grouping symbol.- Returns:
- The grouping symbol or the empty string upon error.
-
getPercentSymbol
public java.lang.String getPercentSymbol()
Gets the percent symbol.- Returns:
- The percent symbol or the empty string upon error.
-
getTypefaces
public java.util.List<java.lang.String> getTypefaces()
Gets the list of typefaces.- Returns:
- The list of typefaces which is possibly empty upon error.
-
getNegativeSymbol
public java.lang.String getNegativeSymbol()
Gets the negative symbol.- Returns:
- The negative symbol or the empty string upon error.
-
getZeroSymbol
public java.lang.String getZeroSymbol()
Gets the native zero digit symbol.- Returns:
- The zero symbol or the empty string upon error.
-
getPositiveSymbol
public java.lang.String getPositiveSymbol()
Gets the positive symbol.- Returns:
- The positive symbol or the empty string upon error.
-
getLocaleNames
public static void getLocaleNames(java.util.List<java.lang.String> oLocales)
Gets all the supported locale names.- Parameters:
oLocales
- the List object to be populated with the name of all the locales for which we have data.
-
findMatchingLocale
public static java.lang.String findMatchingLocale(java.lang.String sCurrencySymbol, java.lang.String sRadixSymbol, java.lang.String sGroupingSymbol)
Finds a locale who's currency, radix and grouping symbols match all of the given symbols.- Parameters:
sCurrencySymbol
- the currency symbol to match.sRadixSymbol
- the decimal radix symbol to match.sGroupingSymbol
- the grouping separator symbol to match.- Returns:
- The matching locale name or the empty string upon failure.
-
-