Skip to content

Commit

Permalink
MONDRIAN: Remove obsolete resources (days of the week, decimal separa…
Browse files Browse the repository at this point in the history
…tor, etc.) from MondrianResource.

[git-p4: depot-paths = "//open/mondrian/": change = 6991]
  • Loading branch information
julianhyde committed Jun 23, 2006
1 parent ad8b9e4 commit d33f4cc
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 306 deletions.
101 changes: 0 additions & 101 deletions src/main/mondrian/olap/Util.java
Expand Up @@ -61,106 +61,6 @@ public class Util extends XOMUtil {
private static final Random metaRandom =
createRandom(MondrianProperties.instance().TestSeed.get());

/**
* Set default method to create a {@link mondrian.util.Format.FormatLocale}
* from a {@link Locale}. Hopefully this location is initialized before
* {@link mondrian.util.Format} is first used for the first time.
*/
static {
Format.setLocaleFormatFactory(createLocaleFormatFactory());
}

/**
* Creates a {@link Format.LocaleFormatFactory} which derives locale
* information from {@link MondrianResource}, and registers it as the
* default factory.
*/
private static Format.LocaleFormatFactory createLocaleFormatFactory0() {
return new Format.LocaleFormatFactory() {
public Format.FormatLocale get(Locale locale) {
MondrianResource res = MondrianResource.instance(locale);
if (res == null ||
!res.getLocale().equals(locale)) {
return null;
}
char thousandSeparator = res.FormatThousandSeparator.str().charAt(0);
char decimalPlaceholder = res.FormatDecimalPlaceholder.str().charAt(0);
String dateSeparator = res.FormatDateSeparator.str();
String timeSeparator = res.FormatTimeSeparator.str();
String currencySymbol = res.FormatCurrencySymbol.str();
String currencyFormat = res.FormatCurrencyFormat.str();
String[] daysOfWeekShort = {
"",
res.FormatShortDaysSun.str(),
res.FormatShortDaysMon.str(),
res.FormatShortDaysTue.str(),
res.FormatShortDaysWed.str(),
res.FormatShortDaysThu.str(),
res.FormatShortDaysFri.str(),
res.FormatShortDaysSat.str(),
};
String[] daysOfWeekLong = {
"",
res.FormatLongDaysSunday.str(),
res.FormatLongDaysMonday.str(),
res.FormatLongDaysTuesday.str(),
res.FormatLongDaysWednesday.str(),
res.FormatLongDaysThursday.str(),
res.FormatLongDaysFriday.str(),
res.FormatLongDaysSaturday.str(),
};
String[] monthsShort = {
res.FormatShortMonthsJan.str(),
res.FormatShortMonthsFeb.str(),
res.FormatShortMonthsMar.str(),
res.FormatShortMonthsApr.str(),
res.FormatShortMonthsMay.str(),
res.FormatShortMonthsJun.str(),
res.FormatShortMonthsJul.str(),
res.FormatShortMonthsAug.str(),
res.FormatShortMonthsSep.str(),
res.FormatShortMonthsOct.str(),
res.FormatShortMonthsNov.str(),
res.FormatShortMonthsDec.str(),
"",
};
String[] monthsLong = {
res.FormatLongMonthsJanuary.str(),
res.FormatLongMonthsFebruary.str(),
res.FormatLongMonthsMarch.str(),
res.FormatLongMonthsApril.str(),
res.FormatLongMonthsMay.str(),
res.FormatLongMonthsJune.str(),
res.FormatLongMonthsJuly.str(),
res.FormatLongMonthsAugust.str(),
res.FormatLongMonthsSeptember.str(),
res.FormatLongMonthsOctober.str(),
res.FormatLongMonthsNovember.str(),
res.FormatLongMonthsDecember.str(),
"",
};
return Format.createLocale(
thousandSeparator, decimalPlaceholder, dateSeparator,
timeSeparator, currencySymbol, currencyFormat,
daysOfWeekShort, daysOfWeekLong, monthsShort,
monthsLong, locale);
}
};
}

/**
* Creates a {@link Format.LocaleFormatFactory} which derives locale
* information from {@link MondrianResource}, and registers it as the
* default factory.
*/
private static Format.LocaleFormatFactory createLocaleFormatFactory() {
return new Format.LocaleFormatFactory() {
public Format.FormatLocale get(Locale locale) {
return Format.createLocale(locale);
}
};
}

/**
* Encodes string for MDX (escapes ] as ]] inside a name).
*/
Expand All @@ -179,7 +79,6 @@ public static String mdxEncodeString(String st) {
return retString.toString();
}


/**
* Converts a string into a double-quoted string.
*/
Expand Down
178 changes: 0 additions & 178 deletions src/main/mondrian/resource/MondrianResource.xml
Expand Up @@ -749,184 +749,6 @@
</message>
<!-- Aggregate tables: end -->

<!-- Resources related to format specifications ========================= -->

<message id="8000000" name="FormatThousandSeparator">
<text>,</text>
</message>

<message id="8000001" name="FormatDecimalPlaceholder">
<text>.</text>
</message>

<message id="8000002" name="FormatDateSeparator">
<text>/</text>
</message>

<message id="8000003" name="FormatTimeSeparator">
<text>:</text>
</message>

<message id="8000004" name="FormatCurrencySymbol">
<text>$</text>
</message>

<message id="8000005" name="FormatCurrencyFormat">
<text>$#,##0.00</text>
</message>

<message id="8000006" name="FormatShortDaysSun">
<text>Sun</text>
</message>

<message id="8000007" name="FormatShortDaysMon">
<text>Mon</text>
</message>

<message id="8000008" name="FormatShortDaysTue">
<text>Tue</text>
</message>

<message id="8000009" name="FormatShortDaysWed">
<text>Wed</text>
</message>

<message id="8000010" name="FormatShortDaysThu">
<text>Thu</text>
</message>

<message id="8000011" name="FormatShortDaysFri">
<text>Fri</text>
</message>

<message id="8000012" name="FormatShortDaysSat">
<text>Sat</text>
</message>

<message id="8000013" name="FormatLongDaysSunday">
<text>Sunday</text>
</message>

<message id="8000014" name="FormatLongDaysMonday">
<text>Monday</text>
</message>

<message id="8000015" name="FormatLongDaysTuesday">
<text>Tuesday</text>
</message>

<message id="8000016" name="FormatLongDaysWednesday">
<text>Wednesday</text>
</message>

<message id="8000017" name="FormatLongDaysThursday">
<text>Thursday</text>
</message>

<message id="8000018" name="FormatLongDaysFriday">
<text>Friday</text>
</message>

<message id="8000019" name="FormatLongDaysSaturday">
<text>Saturday</text>
</message>

<message id="8000020" name="FormatShortMonthsJan">
<text>Jan</text>
</message>

<message id="8000021" name="FormatShortMonthsFeb">
<text>Feb</text>
</message>

<message id="8000022" name="FormatShortMonthsMar">
<text>Mar</text>
</message>

<message id="8000023" name="FormatShortMonthsApr">
<text>Apr</text>
</message>

<message id="8000024" name="FormatShortMonthsMay">
<text>May</text>
</message>

<message id="8000025" name="FormatShortMonthsJun">
<text>Jun</text>
</message>

<message id="8000026" name="FormatShortMonthsJul">
<text>Jul</text>
</message>

<message id="8000027" name="FormatShortMonthsAug">
<text>Aug</text>
</message>

<message id="8000028" name="FormatShortMonthsSep">
<text>Sep</text>
</message>

<message id="8000029" name="FormatShortMonthsOct">
<text>Oct</text>
</message>

<message id="8000030" name="FormatShortMonthsNov">
<text>Nov</text>
</message>

<message id="8000031" name="FormatShortMonthsDec">
<text>Dec</text>
</message>

<message id="8000032" name="FormatLongMonthsJanuary">
<text>January</text>
</message>

<message id="8000033" name="FormatLongMonthsFebruary">
<text>February</text>
</message>

<message id="8000034" name="FormatLongMonthsMarch">
<text>March</text>
</message>

<message id="8000035" name="FormatLongMonthsApril">
<text>April</text>
</message>

<message id="8000036" name="FormatLongMonthsMay">
<text>May</text>
</message>

<message id="8000037" name="FormatLongMonthsJune">
<text>June</text>
</message>

<message id="8000038" name="FormatLongMonthsJuly">
<text>July</text>
</message>

<message id="8000039" name="FormatLongMonthsAugust">
<text>August</text>
</message>

<message id="8000040" name="FormatLongMonthsSeptember">
<text>September</text>
</message>

<message id="8000041" name="FormatLongMonthsOctober">
<text>October</text>
</message>

<message id="8000042" name="FormatLongMonthsNovember">
<text>November</text>
</message>

<message id="8000043" name="FormatLongMonthsDecember">
<text>December</text>
</message>

<!-- End of last error section ============================================ -->

</resourceBundle>
Expand Down
30 changes: 3 additions & 27 deletions src/main/mondrian/util/Format.java
Expand Up @@ -143,8 +143,6 @@ public boolean removeEldestEntry(Map.Entry entry) {
'\0', '\0', null, null, null, null, null, null, null, null,
Locale.US);

private static LocaleFormatFactory localeFormatFactory;

/**
* Formats an object using a format string, according to a given locale.
*
Expand Down Expand Up @@ -1594,29 +1592,25 @@ public static synchronized FormatLocale getBestFormatLocale(Locale locale)

private static FormatLocale getFormatLocaleUsingFactory(Locale locale)
{
LocaleFormatFactory factory = getLocaleFormatFactory();
if (factory == null) {
return null;
}
FormatLocale formatLocale;
// Lookup full locale, e.g. "en-US-Boston"
if (!locale.getVariant().equals("")) {
formatLocale = factory.get(locale);
formatLocale = createLocale(locale);
if (formatLocale != null) {
return formatLocale;
}
locale = new Locale(locale.getLanguage(), locale.getCountry());
}
// Lookup language and country, e.g. "en-US"
if (!locale.getCountry().equals("")) {
formatLocale = factory.get(locale);
formatLocale = createLocale(locale);
if (formatLocale != null) {
return formatLocale;
}
locale = new Locale(locale.getLanguage());
}
// Lookup language, e.g. "en"
formatLocale = factory.get(locale);
formatLocale = createLocale(locale);
if (formatLocale != null) {
return formatLocale;
}
Expand Down Expand Up @@ -2107,24 +2101,6 @@ public String getFormatString()
return formatString;
}

/**
* Defines the factory used to create a {@link FormatLocale} for locales.
*
* <p>Also clears the cache, so that locales from the previous factory (if
* any) are no longer used.
*/
public static void setLocaleFormatFactory(LocaleFormatFactory factory) {
localeFormatFactory = factory;
mapLocaleToFormatLocale.clear(); // clear cache
}

/**
* Returns the factory used to create a {@link FormatLocale} for locales.
*/
public static LocaleFormatFactory getLocaleFormatFactory() {
return localeFormatFactory;
}

/**
* Locates a {@link Format.FormatLocale} for a given locale.
*/
Expand Down

0 comments on commit d33f4cc

Please sign in to comment.