1 package com.github.mygreen.supercsv.builder.standard;
2
3 import com.github.mygreen.supercsv.annotation.constraint.CsvLengthExact;
4 import com.github.mygreen.supercsv.annotation.constraint.CsvWordForbid;
5 import com.github.mygreen.supercsv.annotation.constraint.CsvLengthBetween;
6 import com.github.mygreen.supercsv.annotation.constraint.CsvLengthMax;
7 import com.github.mygreen.supercsv.annotation.constraint.CsvLengthMin;
8 import com.github.mygreen.supercsv.annotation.constraint.CsvPattern;
9 import com.github.mygreen.supercsv.annotation.constraint.CsvWordRequire;
10 import com.github.mygreen.supercsv.builder.AbstractProcessorBuilder;
11 import com.github.mygreen.supercsv.builder.Configuration;
12 import com.github.mygreen.supercsv.builder.FieldAccessor;
13 import com.github.mygreen.supercsv.cellprocessor.constraint.LengthExactFactory;
14 import com.github.mygreen.supercsv.cellprocessor.constraint.WordForbidFactory;
15 import com.github.mygreen.supercsv.cellprocessor.constraint.LengthBetweenFactory;
16 import com.github.mygreen.supercsv.cellprocessor.constraint.LengthMaxFactory;
17 import com.github.mygreen.supercsv.cellprocessor.constraint.LengthMinFactory;
18 import com.github.mygreen.supercsv.cellprocessor.constraint.PatternFactory;
19 import com.github.mygreen.supercsv.cellprocessor.constraint.WordRequireFactory;
20 import com.github.mygreen.supercsv.cellprocessor.format.TextFormatter;
21
22
23
24
25
26
27
28
29
30 public class StringProcessorBuilder extends AbstractProcessorBuilder<String> {
31
32 public StringProcessorBuilder() {
33 super();
34
35 }
36
37 @Override
38 protected void init() {
39 super.init();
40
41
42 registerForConstraint(CsvLengthBetween.class, new LengthBetweenFactory());
43 registerForConstraint(CsvLengthMin.class, new LengthMinFactory());
44 registerForConstraint(CsvLengthMax.class, new LengthMaxFactory());
45 registerForConstraint(CsvLengthExact.class, new LengthExactFactory());
46 registerForConstraint(CsvPattern.class, new PatternFactory());
47 registerForConstraint(CsvWordRequire.class, new WordRequireFactory());
48 registerForConstraint(CsvWordForbid.class, new WordForbidFactory());
49
50 }
51
52 @Override
53 protected TextFormatter<String> getDefaultFormatter(final FieldAccessor field, final Configuration config) {
54
55 return new TextFormatter<String>() {
56
57 @Override
58 public String parse(final String text) {
59 return text;
60 }
61
62 @Override
63 public String print(final String object) {
64 return object;
65 }
66
67 @Override
68 public void setValidationMessage(String validationMessage) {
69
70 }
71
72 };
73 }
74
75 }