mirror of https://github.com/apache/lucene.git
use a pickier forLanguageTag
This commit is contained in:
parent
4a49d417a7
commit
d2cdf238f3
|
@ -20,7 +20,7 @@ import java.util.Locale;
|
|||
|
||||
/** A stemmer for Brazilian Portuguese words. */
|
||||
class BrazilianStemmer {
|
||||
private static final Locale locale = Locale.forLanguageTag("pt-BR");
|
||||
private static final Locale locale = Locale.Builder().setLanguageTag("pt-BR").build();
|
||||
|
||||
/** Changed term */
|
||||
private String TERM;
|
||||
|
|
|
@ -33,7 +33,7 @@ class GermanStemmer {
|
|||
/** Amount of characters that are removed with <code>substitute()</code> while stemming. */
|
||||
private int substCount = 0;
|
||||
|
||||
private static final Locale locale = Locale.forLanguageTag("de-DE");
|
||||
private static final Locale locale = Locale.Builder().setLanguageTag("de-DE").build();
|
||||
|
||||
/**
|
||||
* Stemms the given term to an unique <code>discriminator</code>.
|
||||
|
|
|
@ -39,7 +39,7 @@ public class ThaiTokenizer extends SegmentingTokenizerBase {
|
|||
public static final boolean DBBI_AVAILABLE;
|
||||
|
||||
private static final BreakIterator proto =
|
||||
BreakIterator.getWordInstance(Locale.forLanguageTag("th"));
|
||||
BreakIterator.getWordInstance(Locale.Builder().setLanguageTag("th").build());
|
||||
|
||||
static {
|
||||
// check that we have a working dictionary-based break iterator for thai
|
||||
|
|
|
@ -26,7 +26,7 @@ public class TestCollationKeyAnalyzer extends CollationTestBase {
|
|||
// Neither Java 1.4.2 nor 1.5.0 has Farsi Locale collation available in
|
||||
// RuleBasedCollator. However, the Arabic Locale seems to order the Farsi
|
||||
// characters properly.
|
||||
private Collator collator = Collator.getInstance(Locale.forLanguageTag("ar"));
|
||||
private Collator collator = Collator.getInstance(Locale.Builder().setLanguageTag("ar").build());
|
||||
private Analyzer analyzer;
|
||||
|
||||
@Override
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.apache.lucene.util.BytesRef;
|
|||
|
||||
public class TestICUCollationKeyAnalyzer extends CollationTestBase {
|
||||
|
||||
private Collator collator = Collator.getInstance(Locale.forLanguageTag("fa"));
|
||||
private Collator collator = Collator.getInstance(Locale.Builder().setLanguageTag("fa").build());
|
||||
private Analyzer analyzer;
|
||||
|
||||
@Override
|
||||
|
|
|
@ -65,7 +65,7 @@ public class NewLocaleTask extends PerfTask {
|
|||
}
|
||||
}
|
||||
|
||||
return Locale.forLanguageTag(sb.toString());
|
||||
return Locale.Builder().setLanguageTag(sb.toString()).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -797,15 +797,17 @@ public class TestPerfTasksLogic extends BenchmarkTestCase {
|
|||
|
||||
// specify just a language
|
||||
benchmark = execBenchmark(getLocaleConfig("de"));
|
||||
assertEquals(Locale.forLanguageTag("de"), benchmark.getRunData().getLocale());
|
||||
assertEquals(Locale.Builder().setLanguageTag("de").build(), benchmark.getRunData().getLocale());
|
||||
|
||||
// specify language + country
|
||||
benchmark = execBenchmark(getLocaleConfig("en,US"));
|
||||
assertEquals(Locale.forLanguageTag("en-US"), benchmark.getRunData().getLocale());
|
||||
assertEquals(
|
||||
Locale.Builder().setLanguageTag("en-US").build(), benchmark.getRunData().getLocale());
|
||||
|
||||
// specify language + country + variant
|
||||
benchmark = execBenchmark(getLocaleConfig("no,NO,NY"));
|
||||
assertEquals(Locale.forLanguageTag("no-NO-NY"), benchmark.getRunData().getLocale());
|
||||
assertEquals(
|
||||
Locale.Builder().setLanguageTag("no-NO-NY").build(), benchmark.getRunData().getLocale());
|
||||
}
|
||||
|
||||
private String[] getLocaleConfig(String localeParam) {
|
||||
|
@ -832,22 +834,28 @@ public class TestPerfTasksLogic extends BenchmarkTestCase {
|
|||
public void testCollator() throws Exception {
|
||||
// ROOT locale
|
||||
Benchmark benchmark = execBenchmark(getCollatorConfig("ROOT", "impl:jdk"));
|
||||
CollationKeyAnalyzer expected = new CollationKeyAnalyzer(Collator.getInstance(Locale.forLanguageTag("")));
|
||||
CollationKeyAnalyzer expected = new CollationKeyAnalyzer(Collator.getInstance(Locale.ROOT));
|
||||
assertEqualCollation(expected, benchmark.getRunData().getAnalyzer(), "foobar");
|
||||
|
||||
// specify just a language
|
||||
benchmark = execBenchmark(getCollatorConfig("de", "impl:jdk"));
|
||||
expected = new CollationKeyAnalyzer(Collator.getInstance(Locale.forLanguageTag("de")));
|
||||
expected =
|
||||
new CollationKeyAnalyzer(
|
||||
Collator.getInstance(Locale.Builder().setLanguageTag("de").build()));
|
||||
assertEqualCollation(expected, benchmark.getRunData().getAnalyzer(), "foobar");
|
||||
|
||||
// specify language + country
|
||||
benchmark = execBenchmark(getCollatorConfig("en,US", "impl:jdk"));
|
||||
expected = new CollationKeyAnalyzer(Collator.getInstance(Locale.forLanguageTag("en-US")));
|
||||
expected =
|
||||
new CollationKeyAnalyzer(
|
||||
Collator.getInstance(Locale.Builder().setLanguageTag("en-US").build()));
|
||||
assertEqualCollation(expected, benchmark.getRunData().getAnalyzer(), "foobar");
|
||||
|
||||
// specify language + country + variant
|
||||
benchmark = execBenchmark(getCollatorConfig("no,NO,NY", "impl:jdk"));
|
||||
expected = new CollationKeyAnalyzer(Collator.getInstance(Locale.forLanguageTag("no-NO-NY")));
|
||||
expected =
|
||||
new CollationKeyAnalyzer(
|
||||
Collator.getInstance(Locale.Builder().setLanguageTag("no-NO-NY").build()));
|
||||
assertEqualCollation(expected, benchmark.getRunData().getAnalyzer(), "foobar");
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ public class TestHtmlParser extends LuceneTestCase {
|
|||
public void testTurkish() throws Exception {
|
||||
final Locale saved = Locale.getDefault();
|
||||
try {
|
||||
Locale.setDefault(Locale.forLanguageTag("tr-TR"));
|
||||
Locale.setDefault(Locale.Builder().setLanguageTag("tr-TR").build());
|
||||
String text =
|
||||
"<html><HEAD><TITLE>ııı</TITLE></head><body>"
|
||||
+ "<IMG SRC=\"../images/head.jpg\" WIDTH=570 HEIGHT=47 BORDER=0 ALT=\"ş\">"
|
||||
|
|
|
@ -421,7 +421,7 @@ public final class QueryParserPaneProvider implements QueryParserTabOperator {
|
|||
.fuzzyMinSim(fuzzyMinSimFloat)
|
||||
.fuzzyPrefixLength(fuzzyPrefLenInt)
|
||||
.dateResolution(DateTools.Resolution.valueOf((String) dateResCB.getSelectedItem()))
|
||||
.locale(Locale.forLanguageTag(locationTF.getText()))
|
||||
.locale(Locale.Builder().setLanguageTag(locationTF.getText()).build())
|
||||
.timeZone(TimeZone.getTimeZone(timezoneTF.getText()))
|
||||
.typeMap(typeMap)
|
||||
.build();
|
||||
|
|
|
@ -68,7 +68,7 @@ public class TestNLS extends LuceneTestCase {
|
|||
}
|
||||
|
||||
public void testNLSLoading_xx_XX() {
|
||||
Locale locale = Locale.forLanguageTag("xx-XX");
|
||||
Locale locale = Locale.Builder().setLanguageTag("xx-XX").build();
|
||||
String message =
|
||||
NLS.getLocalizedMessage(
|
||||
MessagesTestBundle.Q0004E_INVALID_SYNTAX_ESCAPE_UNICODE_TRUNCATION, locale);
|
||||
|
|
Loading…
Reference in New Issue