Skip to content

Commit 0d469e7

Browse files
committed
Stop using deprecated Locale constructors
1 parent bad0448 commit 0d469e7

File tree

3 files changed

+27
-21
lines changed

3 files changed

+27
-21
lines changed

ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/IndexToolApplication.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2020 IBM Corporation and others.
2+
* Copyright (c) 2000, 2024 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -46,10 +46,10 @@ public synchronized Object start(IApplicationContext context) throws Exception {
4646
}
4747
Locale locale;
4848
if (localeStr.length() >= 5) {
49-
locale = new Locale(localeStr.substring(0, 2), localeStr.substring(3, 5));
49+
locale = Locale.of(localeStr.substring(0, 2), localeStr.substring(3, 5));
5050
}
5151
else {
52-
locale = new Locale(localeStr.substring(0, 2), ""); //$NON-NLS-1$
52+
locale = Locale.of(localeStr.substring(0, 2), ""); //$NON-NLS-1$
5353
}
5454
preindex(directory, locale);
5555
}

ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/DefaultAnalyzer.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2020 IBM Corporation and others.
2+
* Copyright (c) 2000, 2024 IBM Corporation and others.
33
*
44
* This program and the
55
* accompanying materials are made available under the terms of the Eclipse Public License 2.0
@@ -53,7 +53,7 @@ public DefaultAnalyzer(String localeString) {
5353
}
5454
if (locale == null && userLocale.getDisplayVariant().length() > 0) {
5555
// Check if the locale without variant is supported by BreakIterator
56-
Locale countryLocale = new Locale(userLocale.getLanguage(), userLocale.getCountry());
56+
Locale countryLocale = Locale.of(userLocale.getLanguage(), userLocale.getCountry());
5757
for (Locale availableLocale : availableLocales) {
5858
if (countryLocale.equals(availableLocale)) {
5959
locale = countryLocale;
@@ -63,7 +63,7 @@ public DefaultAnalyzer(String localeString) {
6363
}
6464
if (locale == null && userLocale.getCountry().length() > 0) {
6565
// Check if at least the language is supported by BreakIterator
66-
Locale language = new Locale(userLocale.getLanguage(), ""); //$NON-NLS-1$
66+
Locale language = Locale.of(userLocale.getLanguage(), ""); //$NON-NLS-1$
6767
for (Locale availableLocale : availableLocales) {
6868
if (language.equals(availableLocale)) {
6969
locale = language;
@@ -79,7 +79,7 @@ public DefaultAnalyzer(String localeString) {
7979
+ localeString
8080
+ ", or Java Virtual Machine needs to be upgraded to version with proper support for locale {0}.", //$NON-NLS-1$
8181
null);
82-
locale = new Locale("en", "US"); //$NON-NLS-1$ //$NON-NLS-2$
82+
locale = Locale.of("en", "US"); //$NON-NLS-1$ //$NON-NLS-2$
8383
}
8484
}
8585

@@ -95,11 +95,11 @@ private Locale getLocale(String clientLocale) {
9595
// break the string into tokens to get the Locale object
9696
StringTokenizer locales = new StringTokenizer(clientLocale, "_"); //$NON-NLS-1$
9797
if (locales.countTokens() == 1)
98-
return new Locale(locales.nextToken(), ""); //$NON-NLS-1$
98+
return Locale.of(locales.nextToken(), ""); //$NON-NLS-1$
9999
else if (locales.countTokens() == 2)
100-
return new Locale(locales.nextToken(), locales.nextToken());
100+
return Locale.of(locales.nextToken(), locales.nextToken());
101101
else if (locales.countTokens() == 3)
102-
return new Locale(locales.nextToken(), locales.nextToken(), locales.nextToken());
102+
return Locale.of(locales.nextToken(), locales.nextToken(), locales.nextToken());
103103
else
104104
return Locale.getDefault();
105105
}

ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/QueryBuilder.java

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2016 IBM Corporation and others.
2+
* Copyright (c) 2000, 2024 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -14,20 +14,28 @@
1414
* Sopot Cela - Bug 466829
1515
*******************************************************************************/
1616
package org.eclipse.help.internal.search;
17-
import java.io.*;
17+
import java.io.IOException;
18+
import java.io.Reader;
19+
import java.io.StringReader;
1820
import java.util.ArrayList;
1921
import java.util.Collection;
2022
import java.util.Iterator;
2123
import java.util.List;
2224
import java.util.Locale;
2325
import java.util.StringTokenizer;
2426

25-
import org.apache.lucene.analysis.*;
27+
import org.apache.lucene.analysis.Analyzer;
28+
import org.apache.lucene.analysis.TokenStream;
2629
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
27-
import org.apache.lucene.index.*;
28-
import org.apache.lucene.search.*;
30+
import org.apache.lucene.index.Term;
31+
import org.apache.lucene.search.BooleanClause;
32+
import org.apache.lucene.search.BooleanQuery;
2933
import org.apache.lucene.search.BooleanQuery.Builder;
30-
import org.eclipse.help.internal.base.*;
34+
import org.apache.lucene.search.BoostQuery;
35+
import org.apache.lucene.search.PhraseQuery;
36+
import org.apache.lucene.search.Query;
37+
import org.eclipse.help.internal.base.BaseHelpSystem;
38+
import org.eclipse.help.internal.base.HelpBasePlugin;
3139
/**
3240
* Build query acceptable by the search engine.
3341
*/
@@ -57,10 +65,9 @@ public QueryBuilder(String searchWords, AnalyzerDescriptor analyzerDesc) {
5765
this.searchWords = searchWords;
5866
String language = analyzerDesc.getLang();
5967
if (language.length() >= 5) {
60-
this.locale = new Locale(language.substring(0, 2), language
61-
.substring(3, 5));
68+
this.locale = Locale.of(language.substring(0, 2), language.substring(3, 5));
6269
} else {
63-
this.locale = new Locale(language.substring(0, 2), ""); //$NON-NLS-1$
70+
this.locale = Locale.of(language.substring(0, 2), ""); //$NON-NLS-1$
6471
}
6572
this.analyzerDesc = analyzerDesc;
6673
this.analyzer = analyzerDesc.getAnalyzer();
@@ -297,8 +304,7 @@ private List<Query> getRequiredQueries(List<QueryWordsToken> tokens, String[] fi
297304
}
298305
private Query orQueries(Collection<Query> queries) {
299306
Builder builder = new BooleanQuery.Builder();
300-
for (Iterator<Query> it = queries.iterator(); it.hasNext();) {
301-
Query q = it.next();
307+
for (Query q : queries) {
302308
builder.add(q, BooleanClause.Occur.SHOULD);
303309
}
304310
return builder.build();

0 commit comments

Comments
 (0)