diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/IndexToolApplication.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/IndexToolApplication.java index fbccf485d1a..e8c090c8d07 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/IndexToolApplication.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/IndexToolApplication.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2020 IBM Corporation and others. + * Copyright (c) 2000, 2024 IBM Corporation and others. * * This program and the accompanying materials * 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 { } Locale locale; if (localeStr.length() >= 5) { - locale = new Locale(localeStr.substring(0, 2), localeStr.substring(3, 5)); + locale = Locale.of(localeStr.substring(0, 2), localeStr.substring(3, 5)); } else { - locale = new Locale(localeStr.substring(0, 2), ""); //$NON-NLS-1$ + locale = Locale.of(localeStr.substring(0, 2), ""); //$NON-NLS-1$ } preindex(directory, locale); } diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/DefaultAnalyzer.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/DefaultAnalyzer.java index 1e907214e66..a77036ec1b5 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/DefaultAnalyzer.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/DefaultAnalyzer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2020 IBM Corporation and others. + * Copyright (c) 2000, 2024 IBM Corporation and others. * * This program and the * accompanying materials are made available under the terms of the Eclipse Public License 2.0 @@ -53,7 +53,7 @@ public DefaultAnalyzer(String localeString) { } if (locale == null && userLocale.getDisplayVariant().length() > 0) { // Check if the locale without variant is supported by BreakIterator - Locale countryLocale = new Locale(userLocale.getLanguage(), userLocale.getCountry()); + Locale countryLocale = Locale.of(userLocale.getLanguage(), userLocale.getCountry()); for (Locale availableLocale : availableLocales) { if (countryLocale.equals(availableLocale)) { locale = countryLocale; @@ -63,7 +63,7 @@ public DefaultAnalyzer(String localeString) { } if (locale == null && userLocale.getCountry().length() > 0) { // Check if at least the language is supported by BreakIterator - Locale language = new Locale(userLocale.getLanguage(), ""); //$NON-NLS-1$ + Locale language = Locale.of(userLocale.getLanguage(), ""); //$NON-NLS-1$ for (Locale availableLocale : availableLocales) { if (language.equals(availableLocale)) { locale = language; @@ -79,7 +79,7 @@ public DefaultAnalyzer(String localeString) { + localeString + ", or Java Virtual Machine needs to be upgraded to version with proper support for locale {0}.", //$NON-NLS-1$ null); - locale = new Locale("en", "US"); //$NON-NLS-1$ //$NON-NLS-2$ + locale = Locale.of("en", "US"); //$NON-NLS-1$ //$NON-NLS-2$ } } @@ -95,11 +95,11 @@ private Locale getLocale(String clientLocale) { // break the string into tokens to get the Locale object StringTokenizer locales = new StringTokenizer(clientLocale, "_"); //$NON-NLS-1$ if (locales.countTokens() == 1) - return new Locale(locales.nextToken(), ""); //$NON-NLS-1$ + return Locale.of(locales.nextToken(), ""); //$NON-NLS-1$ else if (locales.countTokens() == 2) - return new Locale(locales.nextToken(), locales.nextToken()); + return Locale.of(locales.nextToken(), locales.nextToken()); else if (locales.countTokens() == 3) - return new Locale(locales.nextToken(), locales.nextToken(), locales.nextToken()); + return Locale.of(locales.nextToken(), locales.nextToken(), locales.nextToken()); else return Locale.getDefault(); } diff --git a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/QueryBuilder.java b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/QueryBuilder.java index 4a198013a92..d5eb8be1831 100644 --- a/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/QueryBuilder.java +++ b/ua/org.eclipse.help.base/src/org/eclipse/help/internal/search/QueryBuilder.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2016 IBM Corporation and others. + * Copyright (c) 2000, 2024 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -14,7 +14,9 @@ * Sopot Cela - Bug 466829 *******************************************************************************/ package org.eclipse.help.internal.search; -import java.io.*; +import java.io.IOException; +import java.io.Reader; +import java.io.StringReader; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; @@ -22,12 +24,18 @@ import java.util.Locale; import java.util.StringTokenizer; -import org.apache.lucene.analysis.*; +import org.apache.lucene.analysis.Analyzer; +import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; -import org.apache.lucene.index.*; -import org.apache.lucene.search.*; +import org.apache.lucene.index.Term; +import org.apache.lucene.search.BooleanClause; +import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.BooleanQuery.Builder; -import org.eclipse.help.internal.base.*; +import org.apache.lucene.search.BoostQuery; +import org.apache.lucene.search.PhraseQuery; +import org.apache.lucene.search.Query; +import org.eclipse.help.internal.base.BaseHelpSystem; +import org.eclipse.help.internal.base.HelpBasePlugin; /** * Build query acceptable by the search engine. */ @@ -57,10 +65,9 @@ public QueryBuilder(String searchWords, AnalyzerDescriptor analyzerDesc) { this.searchWords = searchWords; String language = analyzerDesc.getLang(); if (language.length() >= 5) { - this.locale = new Locale(language.substring(0, 2), language - .substring(3, 5)); + this.locale = Locale.of(language.substring(0, 2), language.substring(3, 5)); } else { - this.locale = new Locale(language.substring(0, 2), ""); //$NON-NLS-1$ + this.locale = Locale.of(language.substring(0, 2), ""); //$NON-NLS-1$ } this.analyzerDesc = analyzerDesc; this.analyzer = analyzerDesc.getAnalyzer(); @@ -297,8 +304,7 @@ private List getRequiredQueries(List tokens, String[] fi } private Query orQueries(Collection queries) { Builder builder = new BooleanQuery.Builder(); - for (Iterator it = queries.iterator(); it.hasNext();) { - Query q = it.next(); + for (Query q : queries) { builder.add(q, BooleanClause.Occur.SHOULD); } return builder.build();