mirror of
https://github.com/apache/lucene.git
synced 2025-02-06 10:08:58 +00:00
LUCENE-4199: fix more default Locale uses
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene4199@1358761 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
700f867c7e
commit
3d964bea63
@ -1,5 +1,7 @@
|
||||
package org.apache.lucene.analysis.br;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
@ -21,6 +23,7 @@ package org.apache.lucene.analysis.br;
|
||||
* A stemmer for Brazilian Portuguese words.
|
||||
*/
|
||||
public class BrazilianStemmer {
|
||||
private static final Locale locale = new Locale("pt", "BR");
|
||||
|
||||
/**
|
||||
* Changed term
|
||||
@ -243,7 +246,7 @@ public class BrazilianStemmer {
|
||||
return null ;
|
||||
}
|
||||
|
||||
value = value.toLowerCase() ;
|
||||
value = value.toLowerCase(locale) ;
|
||||
for (j=0 ; j < value.length() ; j++) {
|
||||
if ((value.charAt(j) == 'á') ||
|
||||
(value.charAt(j) == 'â') ||
|
||||
|
@ -1,4 +1,7 @@
|
||||
package org.apache.lucene.analysis.de;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
// This file is encoded in UTF-8
|
||||
|
||||
/*
|
||||
@ -37,6 +40,8 @@ public class GermanStemmer
|
||||
* Amount of characters that are removed with <tt>substitute()</tt> while stemming.
|
||||
*/
|
||||
private int substCount = 0;
|
||||
|
||||
private static final Locale locale = new Locale("de", "DE");
|
||||
|
||||
/**
|
||||
* Stemms the given term to an unique <tt>discriminator</tt>.
|
||||
@ -47,7 +52,7 @@ public class GermanStemmer
|
||||
protected String stem( String term )
|
||||
{
|
||||
// Use lowercase for medium stemming.
|
||||
term = term.toLowerCase();
|
||||
term = term.toLowerCase(locale);
|
||||
if ( !isStemmable( term ) )
|
||||
return term;
|
||||
// Reset the StringBuilder.
|
||||
|
@ -20,6 +20,7 @@ package org.apache.lucene.analysis.sinks;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
|
||||
import org.apache.lucene.util.AttributeSource;
|
||||
@ -37,10 +38,11 @@ public class DateRecognizerSinkFilter extends TeeSinkTokenFilter.SinkFilter {
|
||||
protected CharTermAttribute termAtt;
|
||||
|
||||
/**
|
||||
* Uses {@link java.text.SimpleDateFormat#getDateInstance()} as the {@link java.text.DateFormat} object.
|
||||
* Uses {@link java.text.SimpleDateFormat#getDateInstance(DateFormat.DEFAULT, Locale.ROOT)} as
|
||||
* the {@link java.text.DateFormat} object.
|
||||
*/
|
||||
public DateRecognizerSinkFilter() {
|
||||
this(DateFormat.getDateInstance());
|
||||
this(DateFormat.getDateInstance(DateFormat.DEFAULT, Locale.ROOT));
|
||||
}
|
||||
|
||||
public DateRecognizerSinkFilter(DateFormat dateFormat) {
|
||||
|
@ -32,7 +32,8 @@ public class TestCharArrayIterator extends LuceneTestCase {
|
||||
}
|
||||
|
||||
public void testConsumeWordInstance() {
|
||||
BreakIterator bi = BreakIterator.getWordInstance();
|
||||
// we use the default locale, as its randomized by LuceneTestCase
|
||||
BreakIterator bi = BreakIterator.getWordInstance(Locale.getDefault());
|
||||
CharArrayIterator ci = CharArrayIterator.newWordInstance();
|
||||
for (int i = 0; i < 10000; i++) {
|
||||
char text[] = _TestUtil.randomUnicodeString(random()).toCharArray();
|
||||
@ -43,7 +44,8 @@ public class TestCharArrayIterator extends LuceneTestCase {
|
||||
|
||||
/* run this to test if your JRE is buggy
|
||||
public void testWordInstanceJREBUG() {
|
||||
BreakIterator bi = BreakIterator.getWordInstance();
|
||||
// we use the default locale, as its randomized by LuceneTestCase
|
||||
BreakIterator bi = BreakIterator.getWordInstance(Locale.getDefault());
|
||||
Segment ci = new Segment();
|
||||
for (int i = 0; i < 10000; i++) {
|
||||
char text[] = _TestUtil.randomUnicodeString(random).toCharArray();
|
||||
@ -60,7 +62,8 @@ public class TestCharArrayIterator extends LuceneTestCase {
|
||||
}
|
||||
|
||||
public void testConsumeSentenceInstance() {
|
||||
BreakIterator bi = BreakIterator.getSentenceInstance();
|
||||
// we use the default locale, as its randomized by LuceneTestCase
|
||||
BreakIterator bi = BreakIterator.getSentenceInstance(Locale.getDefault());
|
||||
CharArrayIterator ci = CharArrayIterator.newSentenceInstance();
|
||||
for (int i = 0; i < 10000; i++) {
|
||||
char text[] = _TestUtil.randomUnicodeString(random()).toCharArray();
|
||||
@ -71,7 +74,8 @@ public class TestCharArrayIterator extends LuceneTestCase {
|
||||
|
||||
/* run this to test if your JRE is buggy
|
||||
public void testSentenceInstanceJREBUG() {
|
||||
BreakIterator bi = BreakIterator.getSentenceInstance();
|
||||
// we use the default locale, as its randomized by LuceneTestCase
|
||||
BreakIterator bi = BreakIterator.getSentenceInstance(Locale.getDefault());
|
||||
Segment ci = new Segment();
|
||||
for (int i = 0; i < 10000; i++) {
|
||||
char text[] = _TestUtil.randomUnicodeString(random).toCharArray();
|
||||
|
@ -429,7 +429,7 @@ public class TaskSequence extends PerfTask {
|
||||
sb.append(padd);
|
||||
sb.append(!letChildReport ? ">" : (parallel ? "]" : "}"));
|
||||
if (fixedTime) {
|
||||
sb.append(" " + NumberFormat.getNumberInstance().format(runTimeSec) + "s");
|
||||
sb.append(" " + NumberFormat.getNumberInstance(Locale.ROOT).format(runTimeSec) + "s");
|
||||
} else if (repetitions>1) {
|
||||
sb.append(" * " + repetitions);
|
||||
} else if (repetitions==REPEAT_EXHAUST) {
|
||||
|
@ -18,6 +18,7 @@ package org.apache.lucene.benchmark.byTask.utils;
|
||||
*/
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Formatting utilities (for reports).
|
||||
@ -25,9 +26,9 @@ import java.text.NumberFormat;
|
||||
public class Format {
|
||||
|
||||
private static NumberFormat numFormat [] = {
|
||||
NumberFormat.getInstance(),
|
||||
NumberFormat.getInstance(),
|
||||
NumberFormat.getInstance(),
|
||||
NumberFormat.getInstance(Locale.ROOT),
|
||||
NumberFormat.getInstance(Locale.ROOT),
|
||||
NumberFormat.getInstance(Locale.ROOT),
|
||||
};
|
||||
private static final String padd = " ";
|
||||
|
||||
|
@ -19,6 +19,7 @@ package org.apache.lucene.benchmark.quality;
|
||||
import java.io.PrintWriter;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Results of quality benchmark run for a single query or for a set of queries.
|
||||
@ -141,7 +142,7 @@ public class QualityStats {
|
||||
logger.println(title);
|
||||
}
|
||||
prefix = prefix==null ? "" : prefix;
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
NumberFormat nf = NumberFormat.getInstance(Locale.ROOT);
|
||||
nf.setMaximumFractionDigits(3);
|
||||
nf.setMinimumFractionDigits(3);
|
||||
nf.setGroupingUsed(true);
|
||||
|
@ -19,6 +19,7 @@ package org.apache.lucene.benchmark.quality.utils;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.apache.lucene.benchmark.quality.QualityQuery;
|
||||
import org.apache.lucene.search.ScoreDoc;
|
||||
@ -45,7 +46,7 @@ public class SubmissionReport {
|
||||
public SubmissionReport (PrintWriter logger, String name) {
|
||||
this.logger = logger;
|
||||
this.name = name;
|
||||
nf = NumberFormat.getInstance();
|
||||
nf = NumberFormat.getInstance(Locale.ROOT);
|
||||
nf.setMaximumFractionDigits(4);
|
||||
nf.setMinimumFractionDigits(4);
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.lucene.codecs.BlockTreeTermsReader;
|
||||
@ -340,7 +341,7 @@ public class CheckIndex {
|
||||
* you only call this when the index is not opened by any
|
||||
* writer. */
|
||||
public Status checkIndex(List<String> onlySegments) throws IOException {
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
NumberFormat nf = NumberFormat.getInstance(Locale.ROOT);
|
||||
SegmentInfos sis = new SegmentInfos();
|
||||
Status result = new Status();
|
||||
result.dir = dir;
|
||||
|
@ -20,6 +20,7 @@ package org.apache.lucene.index;
|
||||
import java.io.IOException;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.apache.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.codecs.Codec;
|
||||
@ -181,7 +182,7 @@ class DocumentsWriterPerThread {
|
||||
private int flushedDocCount;
|
||||
DocumentsWriterDeleteQueue deleteQueue;
|
||||
DeleteSlice deleteSlice;
|
||||
private final NumberFormat nf = NumberFormat.getInstance();
|
||||
private final NumberFormat nf = NumberFormat.getInstance(Locale.ROOT);
|
||||
final Allocator byteBlockAllocator;
|
||||
|
||||
|
||||
|
@ -157,7 +157,7 @@ public class EncodingSpeed {
|
||||
}
|
||||
|
||||
static {
|
||||
nf = NumberFormat.getInstance();
|
||||
nf = NumberFormat.getInstance(Locale.ROOT);
|
||||
nf.setMaximumFractionDigits(4);
|
||||
nf.setMinimumFractionDigits(4);
|
||||
|
||||
|
@ -24,6 +24,7 @@ import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.lucene.analysis.*;
|
||||
@ -385,13 +386,15 @@ public class TestPrecedenceQueryParser extends LuceneTestCase {
|
||||
}
|
||||
|
||||
public String getDate(String s) throws Exception {
|
||||
DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
|
||||
// we use the default Locale since LuceneTestCase randomizes it
|
||||
DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault());
|
||||
return DateTools.dateToString(df.parse(s), DateTools.Resolution.DAY);
|
||||
}
|
||||
|
||||
private String getLocalizedDate(int year, int month, int day,
|
||||
boolean extendLastDate) {
|
||||
DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
|
||||
// we use the default Locale since LuceneTestCase randomizes it
|
||||
DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault());
|
||||
Calendar calendar = new GregorianCalendar();
|
||||
calendar.set(year, month, day);
|
||||
if (extendLastDate) {
|
||||
@ -441,7 +444,8 @@ public class TestPrecedenceQueryParser extends LuceneTestCase {
|
||||
|
||||
/** for testing DateTools support */
|
||||
private String getDate(String s, DateTools.Resolution resolution) throws Exception {
|
||||
DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
|
||||
// we use the default Locale since LuceneTestCase randomizes it
|
||||
DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault());
|
||||
return getDate(df.parse(s), resolution);
|
||||
}
|
||||
|
||||
|
@ -675,7 +675,8 @@ public class TestQPHelper extends LuceneTestCase {
|
||||
/** for testing DateTools support */
|
||||
private String getDate(String s, DateTools.Resolution resolution)
|
||||
throws Exception {
|
||||
DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
|
||||
// we use the default Locale since LuceneTestCase randomizes it
|
||||
DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault());
|
||||
return getDate(df.parse(s), resolution);
|
||||
}
|
||||
|
||||
@ -693,7 +694,8 @@ public class TestQPHelper extends LuceneTestCase {
|
||||
}
|
||||
|
||||
private String getLocalizedDate(int year, int month, int day) {
|
||||
DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
|
||||
// we use the default Locale since LuceneTestCase randomizes it
|
||||
DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault());
|
||||
Calendar calendar = new GregorianCalendar();
|
||||
calendar.clear();
|
||||
calendar.set(year, month, day);
|
||||
|
@ -581,7 +581,8 @@ public abstract class QueryParserTestBase extends LuceneTestCase {
|
||||
|
||||
/** for testing DateTools support */
|
||||
private String getDate(String s, DateTools.Resolution resolution) throws Exception {
|
||||
DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
|
||||
// we use the default Locale since LuceneTestCase randomizes it
|
||||
DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault());
|
||||
return getDate(df.parse(s), resolution);
|
||||
}
|
||||
|
||||
@ -591,7 +592,8 @@ public abstract class QueryParserTestBase extends LuceneTestCase {
|
||||
}
|
||||
|
||||
private String getLocalizedDate(int year, int month, int day) {
|
||||
DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
|
||||
// we use the default Locale since LuceneTestCase randomizes it
|
||||
DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault());
|
||||
Calendar calendar = new GregorianCalendar();
|
||||
calendar.clear();
|
||||
calendar.set(year, month, day);
|
||||
|
@ -28,6 +28,7 @@ import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* @lucene.experimental
|
||||
@ -107,7 +108,7 @@ public class QuadPrefixTree extends SpatialPrefixTree {
|
||||
}
|
||||
|
||||
public void printInfo() {
|
||||
NumberFormat nf = NumberFormat.getNumberInstance();
|
||||
NumberFormat nf = NumberFormat.getNumberInstance(Locale.ROOT);
|
||||
nf.setMaximumFractionDigits(5);
|
||||
nf.setMinimumFractionDigits(5);
|
||||
nf.setMinimumIntegerDigits(3);
|
||||
|
Loading…
x
Reference in New Issue
Block a user