use of com.yahoo.prelude.hitfield.ImmutableFieldPart in project vespa by vespa-engine.
the class QuotingSearcher method translate.
private List<FieldPart> translate(String toQuote, QuoteTable translations, boolean isToken) {
List<FieldPart> newFieldParts = null;
int lastIdx = 0;
for (int i = 0; i < toQuote.length(); i++) {
String quote = translations.get(toQuote.charAt(i));
if (quote != null) {
if (newFieldParts == null) {
newFieldParts = new ArrayList<>();
}
if (lastIdx != i) {
newFieldParts.add(new StringFieldPart(toQuote.substring(lastIdx, i), isToken));
}
String initContent = Character.toString(toQuote.charAt(i));
newFieldParts.add(new ImmutableFieldPart(initContent, quote, isToken));
lastIdx = i + 1;
}
}
if (lastIdx > 0 && lastIdx < toQuote.length()) {
newFieldParts.add(new StringFieldPart(toQuote.substring(lastIdx), isToken));
}
return newFieldParts;
}
Aggregations