summaryrefslogtreecommitdiffstats
path: root/container-search
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2021-05-04 13:02:37 +0200
committerJon Bratseth <bratseth@gmail.com>2021-05-04 13:02:37 +0200
commite63dd633b8a12d34db1f779cc67d9f005cf9d445 (patch)
treed4aad3d05b075b340546b3d811626d680a4b8768 /container-search
parentb4b7eb04fda65f6b365848ee8709f4795aa9bf00 (diff)
No functional changes
Diffstat (limited to 'container-search')
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/query/parser/AbstractParser.java3
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/query/parser/SpecialTokenRegistry.java21
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/query/parser/SpecialTokens.java14
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/query/parser/Tokenizer.java8
4 files changed, 22 insertions, 24 deletions
diff --git a/container-search/src/main/java/com/yahoo/prelude/query/parser/AbstractParser.java b/container-search/src/main/java/com/yahoo/prelude/query/parser/AbstractParser.java
index 902be7e15dd..732466748eb 100644
--- a/container-search/src/main/java/com/yahoo/prelude/query/parser/AbstractParser.java
+++ b/container-search/src/main/java/com/yahoo/prelude/query/parser/AbstractParser.java
@@ -19,7 +19,6 @@ import java.util.*;
* @author bratseth
* @author Steinar Knutsen
*/
-@SuppressWarnings("deprecation")
public abstract class AbstractParser implements CustomParser {
/** The current submodes of this parser */
@@ -48,7 +47,7 @@ public abstract class AbstractParser implements CustomParser {
* of these may be active at the same time. SubModes are activated or
* deactivated by specifying special indexes in the query.
*/
- final class Submodes {
+ static final class Submodes {
/**
* Url mode allows "_" and "-" as word characters. Default is false
diff --git a/container-search/src/main/java/com/yahoo/prelude/query/parser/SpecialTokenRegistry.java b/container-search/src/main/java/com/yahoo/prelude/query/parser/SpecialTokenRegistry.java
index be2d9f9f68b..f1798948361 100644
--- a/container-search/src/main/java/com/yahoo/prelude/query/parser/SpecialTokenRegistry.java
+++ b/container-search/src/main/java/com/yahoo/prelude/query/parser/SpecialTokenRegistry.java
@@ -2,15 +2,17 @@
package com.yahoo.prelude.query.parser;
import com.yahoo.config.subscription.ConfigGetter;
-import com.yahoo.config.subscription.ConfigSubscriber;
import com.yahoo.vespa.configdefinition.SpecialtokensConfig;
import com.yahoo.vespa.configdefinition.SpecialtokensConfig.Tokenlist;
import com.yahoo.vespa.configdefinition.SpecialtokensConfig.Tokenlist.Tokens;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import java.util.logging.Logger;
-
/**
* A <i>registry</i> which is responsible for knowing the current
* set of special tokens. The default registry returns empty token lists
@@ -26,10 +28,10 @@ public class SpecialTokenRegistry {
private static final SpecialTokens nullSpecialTokens = new SpecialTokens();
/**
- * The current authorative special token lists, indexed on name.
+ * The current special token lists, indexed on name.
* These lists are unmodifiable and used directly by clients of this
*/
- private Map<String,SpecialTokens> specialTokenMap = new HashMap<>();
+ private Map<String, SpecialTokens> specialTokenMap = new HashMap<>();
private boolean frozen = false;
@@ -47,8 +49,7 @@ public class SpecialTokenRegistry {
try {
build(new ConfigGetter<>(SpecialtokensConfig.class).getConfig(configId));
} catch (Exception e) {
- log.config(
- "No special tokens are configured (" + e.getMessage() + ")");
+ log.config("No special tokens are configured (" + e.getMessage() + ")");
}
}
@@ -111,13 +112,11 @@ public class SpecialTokenRegistry {
specialTokenMap = tokens;
}
-
/**
- * Returns the currently authorative list of special tokens for
- * a given name.
+ * Returns the list of special tokens for a given name.
*
* @param name the name of the special tokens to return
- * null, the empth string or the string "default" returns
+ * null, the empty string or the string "default" returns
* the default ones
* @return a read-only list of SpecialToken instances, an empty list if this name
* has no special tokens
diff --git a/container-search/src/main/java/com/yahoo/prelude/query/parser/SpecialTokens.java b/container-search/src/main/java/com/yahoo/prelude/query/parser/SpecialTokens.java
index f45ecefefa6..6f1fad1a6c1 100644
--- a/container-search/src/main/java/com/yahoo/prelude/query/parser/SpecialTokens.java
+++ b/container-search/src/main/java/com/yahoo/prelude/query/parser/SpecialTokens.java
@@ -52,7 +52,7 @@ public class SpecialTokens {
if (!caseIndependentLength(token)) {
return;
}
- // TODO are special tokens correctly unicode normalized in reagards to query parsing?
+ // TODO: Are special tokens correctly unicode normalized in regards to query parsing?
final SpecialToken specialTokenToAdd = new SpecialToken(token, replace);
currentMaximumLength = Math.max(currentMaximumLength, specialTokenToAdd.token.length());
specialTokens.add(specialTokenToAdd);
@@ -62,11 +62,11 @@ public class SpecialTokens {
private boolean caseIndependentLength(String token) {
// XXX not fool proof length test, should test codepoint by codepoint for mixed case user input? not even that will necessarily be 100% robust...
String asLow = toLowerCase(token);
- // TODO put along with the global toLowerCase
+ // TODO: Put along with the global toLowerCase
String asHigh = token.toUpperCase(Locale.ENGLISH);
if (asLow.length() != token.length() || asHigh.length() != token.length()) {
- log.log(Level.SEVERE, "Special token '" + token + "' has case sensitive length. Ignoring the token."
- + " Please report this message in a bug to the Vespa team.");
+ log.log(Level.SEVERE, "Special token '" + token + "' has case sensitive length. Ignoring the token." +
+ " Please report this message in a bug to the Vespa team.");
return false;
} else {
return true;
@@ -84,7 +84,7 @@ public class SpecialTokens {
public SpecialToken tokenize(String string, boolean substring) {
// XXX detonator pattern token.length may be != the length of the
// matching data in string, ref caseIndependentLength(String)
- final String input = toLowerCase(string.substring(0, Math.min(string.length(), currentMaximumLength)));
+ String input = toLowerCase(string.substring(0, Math.min(string.length(), currentMaximumLength)));
for (Iterator<SpecialToken> i = specialTokens.iterator(); i.hasNext();) {
SpecialTokens.SpecialToken special = i.next();
@@ -118,9 +118,9 @@ public class SpecialTokens {
/** An immutable special token */
public final static class SpecialToken implements Comparable<SpecialToken> {
- private String token;
+ private final String token;
- private String replace;
+ private final String replace;
public SpecialToken(String token, String replace) {
this.token = toLowerCase(token);
diff --git a/container-search/src/main/java/com/yahoo/prelude/query/parser/Tokenizer.java b/container-search/src/main/java/com/yahoo/prelude/query/parser/Tokenizer.java
index 2dc2254df68..686ceefc460 100644
--- a/container-search/src/main/java/com/yahoo/prelude/query/parser/Tokenizer.java
+++ b/container-search/src/main/java/com/yahoo/prelude/query/parser/Tokenizer.java
@@ -216,9 +216,9 @@ public final class Tokenizer {
}
private int consumeSpecialToken(int start) {
- SpecialTokens.SpecialToken specialToken=getSpecialToken(start);
- if (specialToken==null) return start;
- tokens.add(specialToken.toToken(start,source));
+ SpecialTokens.SpecialToken specialToken = getSpecialToken(start);
+ if (specialToken == null) return start;
+ tokens.add(specialToken.toToken(start, source));
return start + specialToken.token().length();
}
@@ -229,7 +229,7 @@ public final class Tokenizer {
private int consumeExact(int start,Index index) {
if (index.getExactTerminator() == null) return consumeHeuristicExact(start);
- return consumeToTerminator(start,index.getExactTerminator());
+ return consumeToTerminator(start, index.getExactTerminator());
}
private boolean looksLikeExactEnd(int end) {