Methods Summary |
---|
protected abstract java.lang.Object[][] | getContents()fetch the entire resource contents.
|
public static java.lang.String | getDateString(java.lang.String dayOfWeek, java.lang.String date, java.lang.String month, java.lang.String year)Returns a locale-specific formatted date string. By default,
it will return like "Fri, 05 Dec 2000".
String lStr = null;
if (res != null) {
if (res.lookup == null) {
res.loadLookup();
}
lStr = res.getLocalizedDateString(dayOfWeek, date, month, year);
}
return (lStr != null) ? lStr :
(dayOfWeek + ", " + date + " " + month + " " + year);
|
public static java.lang.String | getDateTimeString(java.lang.String dayOfWeek, java.lang.String date, java.lang.String month, java.lang.String year, java.lang.String hour, java.lang.String min, java.lang.String sec, java.lang.String ampm)Returns a locale-specific formatted date and time string. By
default, it will like return "Fri, 05 Dec 2000 10:05:59 PM".
String lStr = null;
if (res != null) {
if (res.lookup == null) {
res.loadLookup();
}
lStr = res.getLocalizedDateTimeString(dayOfWeek, date, month, year,
hour, min, sec, ampm);
}
return (lStr != null) ? lStr :
(dayOfWeek + ", " + date + " " + month + " " + year + " " +
hour + ":" + min + ":" + sec +
((ampm == null) ? "" : (" " + ampm)));
|
public static int | getFirstDayOfWeek()Returns what the first day of the week is; e.g., Sunday in US,
Monday in France.
if (res == null) {
return java.util.Calendar.SUNDAY;
}
return res.getLocalizedFirstDayOfWeek();
|
protected abstract java.lang.String | getLocalizedDateString(java.lang.String dayOfWeek, java.lang.String date, java.lang.String month, java.lang.String year)get the localized version of the date string.
|
protected abstract java.lang.String | getLocalizedDateTimeString(java.lang.String dayOfWeek, java.lang.String date, java.lang.String month, java.lang.String year, java.lang.String hour, java.lang.String min, java.lang.String sec, java.lang.String ampm)Returns a locale-specific formatted date and time string. By
default, it will like return "Fri, 05 Dec 2000 10:05:59 PM".
|
protected abstract int | getLocalizedFirstDayOfWeek()get the localized first day of week.
|
protected abstract java.lang.String | getLocalizedTimeString(java.lang.String hour, java.lang.String min, java.lang.String sec, java.lang.String ampm)Returns a locale-specific formatted time string. By default,
it will return like "10:05:59 PM".
|
public static java.lang.String | getString(java.lang.String key)Returns a localized string for the argument string.
String lStr = null;
if (res != null) {
if (res.lookup == null) {
res.loadLookup();
}
lStr = (String) res.lookup.get(key);
}
return (lStr != null) ? lStr : key;
|
public static java.lang.String | getString(java.lang.String key, java.lang.String[] values)Returns a localized string for the argument string after substituting
values for the "%d" tokens in the localized string, where "d" is 1-9
and representing a values 0-8 in an array. The tokens can be in any
order in the string. If the localized String is not found
the key is used as the localized string. If a "%" is not followed by
1-9 then the "%" is dropped but the next char is put directly into the
output string, so "%%" will be "%" in the output and not count as part
of a token. Another example would be that "%a" would be just be "a".
For example, given "%2 had a little %1." and {"lamb", "Mary"} and there
is no localized string for the key, the result would be:
"Mary had a little lamb."
boolean tokenMarkerFound = false;
StringBuffer output;
char currentChar;
int length;
String str = getString(key);
if (str == null) {
return null;
}
length = str.length();
output = new StringBuffer(length * 2); // try to avoid resizing
for (int i = 0; i < length; i++) {
currentChar = str.charAt(i);
if (tokenMarkerFound) {
if (currentChar < '1" || currentChar > '9") {
// covers the "%%" case
output.append(currentChar);
} else {
// substitute a value, "1" is index 0 into the value array
output.append(values[currentChar - '1"]);
}
tokenMarkerFound = false;
} else if (currentChar == '%") {
tokenMarkerFound = true;
} else {
output.append(currentChar);
}
}
return output.toString();
|
public static java.lang.String | getTimeString(java.lang.String hour, java.lang.String min, java.lang.String sec, java.lang.String ampm)Returns a locale-specific formatted time string. By default,
it will return like "10:05:59 PM".
String lStr = null;
if (res != null) {
if (res.lookup == null) {
res.loadLookup();
}
lStr = res.getLocalizedTimeString(hour, min, sec, ampm);
}
return (lStr != null) ? lStr :
(hour + ":" + min + ":" + sec +
((ampm == null) ? "" : (" " + ampm)));
|
public static boolean | isAMPMafterTime()Returns whether the AM_PM field comes after the time field or
not.
if (res == null) {
return true;
}
return res.isLocalizedAMPMafterTime();
|
protected abstract boolean | isLocalizedAMPMafterTime()localized indication of where the AM/PM indicator is placed.
|
private void | loadLookup()load the lookup table.
if (lookup != null)
return;
Object[][] contents = getContents();
Hashtable tmp = new Hashtable(contents.length);
for (int i = 0; i < contents.length; ++i) {
tmp.put(contents[i][0], contents[i][1]);
}
lookup = tmp;
|