blob: 561c5b8789984b6941f4da020abf509558e94bbe (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.schema.fieldoperation;
import com.yahoo.schema.document.NormalizeLevel;
import com.yahoo.schema.document.SDField;
/**
* @author Einar M R Rosenvinge
*/
public class NormalizingOperation implements FieldOperation {
private final NormalizeLevel.Level level;
public NormalizingOperation(String setting) {
if ("none".equals(setting)) {
this.level = NormalizeLevel.Level.NONE;
} else if ("codepoint".equals(setting)) {
this.level = NormalizeLevel.Level.CODEPOINT;
} else if ("lowercase".equals(setting)) {
this.level = NormalizeLevel.Level.LOWERCASE;
} else if ("accent".equals(setting)) {
this.level = NormalizeLevel.Level.ACCENT;
} else if ("all".equals(setting)) {
this.level = NormalizeLevel.Level.ACCENT;
} else {
throw new IllegalArgumentException("invalid normalizing setting: " + setting);
}
}
public void apply(SDField field) {
field.setNormalizing(new NormalizeLevel(level, true));
}
}
|