Class LcData
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 ClassesModifier and TypeClassDescriptionstatic classNested class describing a locale's data. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringfindMatchingLocale(String sCurrencySymbol, String sRadixSymbol, String sGroupingSymbol) Finds a locale who's currency, radix and grouping symbols match all of the given symbols.static LcData.LcRunTimeDataGets the locale data for the given locale from this class's runtime store.getAbbrMonthName(int month) Gets the abbreviated name of the given month of the year.getAbbrWeekdayName(int weekday) Gets the abbreviated name of the given day of the week.Gets the name of the currency.Gets the radix of the currency.Gets the symbol of the currency.getDateFormat(int style) Gets the date format in the given style.getDateTimeFormat(int style, int type) Gets the datetime format in the given style.Gets the date time pattern.getEraName(int era) Gets the name of the given era.Gets the grouping symbol.getLocalDateFormat(int style) Gets the local date format in the given style.Gets the local datetime format.Gets this LcData object's locale.static voidgetLocaleNames(List<String> oLocales) Gets all the supported locale names.getLocalTimeFormat(int style) Gets the local time format in the given style.getMeridiemName(int aspect) Gets the name of the given aspect of the meridiem.getMonthName(int month) Gets the name of the given month of the year.Gets the negative symbol.getNumberFormat(int style, int option) Gets the number format in the given style.intgetNumberPrecision(String sVal) Gets the decimal precision of the given numeric string.getNumericFormat(int style) Gets the numeric format in the given style.Gets the percent symbol.Gets the positive symbol.Gets the radix symbol.getTimeFormat(int style) Gets the time format in the given style.Gets the list of typefaces.getWeekDayName(int weekday) Gets the name of the given day of the week.Gets the native zero digit symbol.static voidreset()Reset this class's runtime store of locale data to its internal defaults.static voidupdate(LcData.LcRunTimeData oLcData) Updates (replaces) this class's runtime store of data for the given locale with the given locale data.static booleanvalidate(LcData.LcRunTimeData oLcData) Validates the given runtime locale data.static final intwithPrecision(int prec) static final intwithWidth(int width)
-
Field Details
-
SUN
public static final int SUN- See Also:
-
MON
public static final int MON- See Also:
-
TUE
public static final int TUE- See Also:
-
WED
public static final int WED- See Also:
-
THU
public static final int THU- See Also:
-
FRI
public static final int FRI- See Also:
-
SAT
public static final int SAT- See Also:
-
JAN
public static final int JAN- See Also:
-
FEB
public static final int FEB- See Also:
-
MAR
public static final int MAR- See Also:
-
APR
public static final int APR- See Also:
-
MAY
public static final int MAY- See Also:
-
JUN
public static final int JUN- See Also:
-
JUL
public static final int JUL- See Also:
-
AUG
public static final int AUG- See Also:
-
SEP
public static final int SEP- See Also:
-
OCT
public static final int OCT- See Also:
-
NOV
public static final int NOV- See Also:
-
DEC
public static final int DEC- See Also:
-
AM
public static final int AM- See Also:
-
PM
public static final int PM- See Also:
-
BC
public static final int BC- See Also:
-
AD
public static final int AD- See Also:
-
DEFLT
public static final int DEFLT- See Also:
-
FULL
public static final int FULL- See Also:
-
LONG
public static final int LONG- See Also:
-
MED
public static final int MED- See Also:
-
SHORT
public static final int SHORT- See Also:
-
NUMERIC
public static final int NUMERIC- See Also:
-
CURRENCY
public static final int CURRENCY- See Also:
-
PERCENT
public static final int PERCENT- See Also:
-
NUM_DECIMAL
public static final int NUM_DECIMAL- See Also:
-
NUM_GROUPING
public static final int NUM_GROUPING- See Also:
-
NUM_PERCENT
public static final int NUM_PERCENT- See Also:
-
NUM_MINUS
public static final int NUM_MINUS- See Also:
-
NUM_ZERO
public static final int NUM_ZERO- See Also:
-
CUR_SYMBOL
public static final int CUR_SYMBOL- See Also:
-
CUR_ISONAME
public static final int CUR_ISONAME- See Also:
-
CUR_DECIMAL
public static final int CUR_DECIMAL- See Also:
-
DEFLT_FMT
public static final int DEFLT_FMT- See Also:
-
SHORT_FMT
public static final int SHORT_FMT- See Also:
-
MED_FMT
public static final int MED_FMT- See Also:
-
LONG_FMT
public static final int LONG_FMT- See Also:
-
FULL_FMT
public static final int FULL_FMT- See Also:
-
INTEGRAL_FMT
public static final int INTEGRAL_FMT- See Also:
-
DECIMAL_FMT
public static final int DECIMAL_FMT- See Also:
-
CURRENCY_FMT
public static final int CURRENCY_FMT- See Also:
-
PERCENT_FMT
public static final int PERCENT_FMT- See Also:
-
WITHOUT_RADIX
public static final int WITHOUT_RADIX- See Also:
-
WITHOUT_GROUPINGS
public static final int WITHOUT_GROUPINGS- See Also:
-
WITH_GROUPINGS
public static final int WITH_GROUPINGS- See Also:
-
WITH_ZEDS
public static final int WITH_ZEDS- See Also:
-
WITH_EIGHTS
public static final int WITH_EIGHTS- See Also:
-
WITH_RADIX
public static final int WITH_RADIX- See Also:
-
KEEP_NINES
public static final int KEEP_NINES- See Also:
-
WITHOUT_CATEGORIES
public static final int WITHOUT_CATEGORIES- See Also:
-
WITH_CATEGORIES
public static final int WITH_CATEGORIES- See Also:
-
-
Constructor Details
-
LcData
Instantiates an LcData object for the given locale.- Parameters:
locale- the locale name.
-
-
Method Details
-
withWidth
public static final int withWidth(int width) -
withPrecision
public static final int withPrecision(int prec) -
getLocale
Gets this LcData object's locale.- Returns:
- Locale name (e.g., "ar_SA").
-
validate
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
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
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
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
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
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
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
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
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
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
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
Gets the date time pattern.- Returns:
- The date time pattern.
-
getDateTimeFormat
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
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
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
Gets the local datetime format.This method is not functional yet.
- Returns:
- The date time format.
-
getNumericFormat
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
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
Gets the decimal precision of the given numeric string.- Returns:
- The decimal precision or 0 for integral values.
-
getCurrencyName
Gets the name of the currency.- Returns:
- The currency name or the empty string upon error.
-
getCurrencySymbol
Gets the symbol of the currency.- Returns:
- The currency symbol or the empty string upon error.
-
getCurrencyRadix
Gets the radix of the currency.- Returns:
- The currency radix or the empty string upon error.
-
getRadixSymbol
Gets the radix symbol.- Returns:
- The radix symbol or the empty string upon error.
-
getGroupingSymbol
Gets the grouping symbol.- Returns:
- The grouping symbol or the empty string upon error.
-
getPercentSymbol
Gets the percent symbol.- Returns:
- The percent symbol or the empty string upon error.
-
getTypefaces
Gets the list of typefaces.- Returns:
- The list of typefaces which is possibly empty upon error.
-
getNegativeSymbol
Gets the negative symbol.- Returns:
- The negative symbol or the empty string upon error.
-
getZeroSymbol
Gets the native zero digit symbol.- Returns:
- The zero symbol or the empty string upon error.
-
getPositiveSymbol
Gets the positive symbol.- Returns:
- The positive symbol or the empty string upon error.
-
getLocaleNames
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 String findMatchingLocale(String sCurrencySymbol, String sRadixSymbol, 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.
-