ICU-6503 move date time pattern generator cache from date interval format to date time pattern generator. change FIXME to TODO
X-SVN-Rev: 24883
This commit is contained in:
parent
687f9bacd8
commit
98854bae7d
@ -1539,17 +1539,6 @@ public abstract class DateFormat extends UFormat {
|
||||
return new SimpleDateFormat(bestPattern, locale);
|
||||
}
|
||||
|
||||
/*
|
||||
* Package accessible.
|
||||
* Used by DateIntervalFormat
|
||||
* @internal ICU 4.1.1
|
||||
*/
|
||||
final static DateFormat getPatternInstance(String pattern, ULocale locale,
|
||||
DateTimePatternGenerator generator) {
|
||||
final String bestPattern = generator.getBestPattern(pattern);
|
||||
return new SimpleDateFormat(bestPattern, locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience overload
|
||||
* @draft ICU 4.0
|
||||
|
@ -285,8 +285,6 @@ public class DateIntervalFormat extends UFormat {
|
||||
|
||||
// Cache for the locale interval pattern
|
||||
private static ICUCache LOCAL_PATTERN_CACHE = new SimpleCache();
|
||||
// Cache for DateTimePatternGenerator
|
||||
private static ICUCache DTPNG_CACHE = new SimpleCache();
|
||||
|
||||
/*
|
||||
* The interval patterns for this locale.
|
||||
@ -342,17 +340,11 @@ public class DateIntervalFormat extends UFormat {
|
||||
fSkeleton = skeleton;
|
||||
fInfo = dtItvInfo;
|
||||
|
||||
String key = locale.toString();
|
||||
DateTimePatternGenerator generator = (DateTimePatternGenerator)DTPNG_CACHE.get(key);
|
||||
if ( generator == null ) {
|
||||
generator = DateTimePatternGenerator.getInstance(locale);
|
||||
DTPNG_CACHE.put(key, generator);
|
||||
}
|
||||
|
||||
DateFormat dtfmt = DateFormat.getPatternInstance(skeleton,locale,generator);
|
||||
fDateFormat = (SimpleDateFormat)dtfmt;
|
||||
fFromCalendar = (Calendar) dtfmt.getCalendar().clone();
|
||||
fToCalendar = (Calendar) dtfmt.getCalendar().clone();
|
||||
DateTimePatternGenerator generator = DateTimePatternGenerator.getInstance(locale);
|
||||
final String bestPattern = generator.getBestPattern(skeleton);
|
||||
fDateFormat = new SimpleDateFormat(bestPattern, locale);
|
||||
fFromCalendar = (Calendar) fDateFormat.getCalendar().clone();
|
||||
fToCalendar = (Calendar) fDateFormat.getCalendar().clone();
|
||||
initializePattern();
|
||||
}
|
||||
|
||||
@ -907,8 +899,7 @@ public class DateIntervalFormat extends UFormat {
|
||||
* @return interval patterns' hash map
|
||||
*/
|
||||
private HashMap initializeIntervalPattern(String fullPattern, ULocale locale) {
|
||||
String localeKey = locale.toString();
|
||||
DateTimePatternGenerator dtpng = (DateTimePatternGenerator)DTPNG_CACHE.get(localeKey);
|
||||
DateTimePatternGenerator dtpng = DateTimePatternGenerator.getInstance(locale);
|
||||
if ( fSkeleton == null ) {
|
||||
// fSkeleton is already set by getDateIntervalInstance()
|
||||
// or by getInstance(String skeleton, .... )
|
||||
@ -1207,7 +1198,6 @@ public class DateIntervalFormat extends UFormat {
|
||||
++vCount;
|
||||
timeSkeleton.append(ch);
|
||||
break;
|
||||
// FIXME: what is the difference between CAP_V/Z and LOW_V/Z
|
||||
case 'V':
|
||||
case 'Z':
|
||||
case 'k':
|
||||
|
@ -333,7 +333,7 @@ public class DateIntervalInfo implements Cloneable, Freezable, Serializable {
|
||||
if ( dii == null ) {
|
||||
// initialize data from scratch
|
||||
setup(locale);
|
||||
// FIXME: should put a clone in cache?
|
||||
// TODO: should put a clone in cache?
|
||||
// or put itself in cache?
|
||||
// DIICACHE.put(key, this);
|
||||
dii = (DateIntervalInfo)this.clone();
|
||||
@ -371,7 +371,7 @@ public class DateIntervalInfo implements Cloneable, Freezable, Serializable {
|
||||
// loop through all locales to get all available skeletons'
|
||||
// interval format
|
||||
ULocale parentLocale = locale;
|
||||
// FIXME: how to check for root
|
||||
// TODO: how to check for root
|
||||
//while ( !parentLocale.equals(ULocale.ROOT) ) {
|
||||
while (parentLocale != null && !parentLocale.equals(ULocale.ROOT)) {
|
||||
String name = parentLocale.getName();
|
||||
@ -881,7 +881,7 @@ public class DateIntervalInfo implements Cloneable, Freezable, Serializable {
|
||||
final int STRING_NUMERIC_DIFFERENCE = 0x100;
|
||||
final int BASE = 0x41;
|
||||
|
||||
// FIXME: hack for 'v' and 'z'
|
||||
// TODO: this is a hack for 'v' and 'z'
|
||||
// resource bundle only have time skeletons ending with 'v',
|
||||
// but not for time skeletons ending with 'z'.
|
||||
boolean replaceZWithV = false;
|
||||
|
@ -8,8 +8,10 @@
|
||||
package com.ibm.icu.text;
|
||||
|
||||
import com.ibm.icu.impl.CalendarData;
|
||||
import com.ibm.icu.impl.ICUCache;
|
||||
import com.ibm.icu.impl.ICUResourceBundle;
|
||||
import com.ibm.icu.impl.PatternTokenizer;
|
||||
import com.ibm.icu.impl.SimpleCache;
|
||||
import com.ibm.icu.impl.Utility;
|
||||
import com.ibm.icu.util.Calendar;
|
||||
import com.ibm.icu.util.Freezable;
|
||||
@ -123,7 +125,12 @@ public class DateTimePatternGenerator implements Freezable, Cloneable {
|
||||
* @stable ICU 3.6
|
||||
*/
|
||||
public static DateTimePatternGenerator getInstance(ULocale uLocale) {
|
||||
DateTimePatternGenerator result = new DateTimePatternGenerator();
|
||||
String localeKey = uLocale.toString();
|
||||
DateTimePatternGenerator result = (DateTimePatternGenerator)DTPNG_CACHE.get(localeKey);
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
result = new DateTimePatternGenerator();
|
||||
String lang = uLocale.getLanguage();
|
||||
if (lang.equals("zh") || lang.equals("ko") || lang.equals("ja")) {
|
||||
result.chineseMonthHack = true;
|
||||
@ -221,6 +228,7 @@ public class DateTimePatternGenerator implements Freezable, Cloneable {
|
||||
// decimal point for seconds
|
||||
DecimalFormatSymbols dfs = new DecimalFormatSymbols(uLocale);
|
||||
result.setDecimal(String.valueOf(dfs.getDecimalSeparator()));
|
||||
DTPNG_CACHE.put(localeKey, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1290,6 +1298,9 @@ public class DateTimePatternGenerator implements Freezable, Cloneable {
|
||||
|
||||
private static final int FRACTIONAL_MASK = 1<<FRACTIONAL_SECOND;
|
||||
private static final int SECOND_AND_FRACTIONAL_MASK = (1<<SECOND) | (1<<FRACTIONAL_SECOND);
|
||||
|
||||
// Cache for DateTimePatternGenerator
|
||||
private static ICUCache DTPNG_CACHE = new SimpleCache();
|
||||
|
||||
private void checkFrozen() {
|
||||
if (isFrozen()) {
|
||||
|
@ -315,7 +315,7 @@ public class TimeUnitFormat extends MeasureFormat {
|
||||
resultNumber = new Integer(2);
|
||||
} else {
|
||||
// should not happen.
|
||||
// FIXME: how to handle?
|
||||
// TODO: how to handle?
|
||||
resultNumber = new Integer(3);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user