summaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/schema/fieldoperation/NormalizingOperation.java
diff options
context:
space:
mode:
Diffstat (limited to 'config-model/src/main/java/com/yahoo/schema/fieldoperation/NormalizingOperation.java')
-rw-r--r--config-model/src/main/java/com/yahoo/schema/fieldoperation/NormalizingOperation.java34
1 files changed, 34 insertions, 0 deletions
diff --git a/config-model/src/main/java/com/yahoo/schema/fieldoperation/NormalizingOperation.java b/config-model/src/main/java/com/yahoo/schema/fieldoperation/NormalizingOperation.java
new file mode 100644
index 00000000000..561c5b87899
--- /dev/null
+++ b/config-model/src/main/java/com/yahoo/schema/fieldoperation/NormalizingOperation.java
@@ -0,0 +1,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));
+ }
+
+}