embulk-parser-poi_excel 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +35 -0
- data/build.gradle +1 -1
- data/classpath/embulk-parser-poi_excel-0.1.2.jar +0 -0
- data/src/main/java/org/embulk/parser/poi_excel/PoiExcelColumnValueType.java +2 -3
- data/src/main/java/org/embulk/parser/poi_excel/PoiExcelParserPlugin.java +34 -50
- data/src/main/java/org/embulk/parser/poi_excel/bean/PoiExcelColumnBean.java +300 -0
- data/src/main/java/org/embulk/parser/poi_excel/{visitor → bean}/PoiExcelColumnIndex.java +44 -27
- data/src/main/java/org/embulk/parser/poi_excel/bean/PoiExcelSheetBean.java +102 -0
- data/src/main/java/org/embulk/parser/poi_excel/visitor/AbstractPoiExcelCellAttributeVisitor.java +15 -13
- data/src/main/java/org/embulk/parser/poi_excel/visitor/PoiExcelCellCommentVisitor.java +2 -2
- data/src/main/java/org/embulk/parser/poi_excel/visitor/PoiExcelCellFontVisitor.java +2 -2
- data/src/main/java/org/embulk/parser/poi_excel/visitor/PoiExcelCellStyleVisitor.java +2 -2
- data/src/main/java/org/embulk/parser/poi_excel/visitor/PoiExcelCellValueVisitor.java +52 -31
- data/src/main/java/org/embulk/parser/poi_excel/visitor/PoiExcelClientAnchorVisitor.java +2 -2
- data/src/main/java/org/embulk/parser/poi_excel/visitor/PoiExcelColumnVisitor.java +30 -29
- data/src/main/java/org/embulk/parser/poi_excel/visitor/PoiExcelVisitorFactory.java +4 -0
- data/src/main/java/org/embulk/parser/poi_excel/visitor/PoiExcelVisitorValue.java +10 -21
- data/src/main/java/org/embulk/parser/poi_excel/visitor/embulk/BooleanCellVisitor.java +5 -0
- data/src/main/java/org/embulk/parser/poi_excel/visitor/embulk/CellVisitor.java +30 -0
- data/src/main/java/org/embulk/parser/poi_excel/visitor/embulk/DoubleCellVisitor.java +13 -1
- data/src/main/java/org/embulk/parser/poi_excel/visitor/embulk/LongCellVisitor.java +13 -1
- data/src/main/java/org/embulk/parser/poi_excel/visitor/embulk/StringCellVisitor.java +5 -0
- data/src/main/java/org/embulk/parser/poi_excel/visitor/embulk/TimestampCellVisitor.java +30 -8
- data/src/test/java/org/embulk/parser/poi_excel/TestPoiExcelParserPlugin.java +0 -1
- data/src/test/java/org/embulk/parser/poi_excel/TestPoiExcelParserPlugin_cellError.java +184 -0
- data/src/test/java/org/embulk/parser/poi_excel/TestPoiExcelParserPlugin_columnNumber.java +3 -5
- data/src/test/java/org/embulk/parser/poi_excel/TestPoiExcelParserPlugin_constant.java +54 -0
- data/src/test/java/org/embulk/parser/poi_excel/TestPoiExcelParserPlugin_convertError.java +113 -0
- data/src/test/resources/org/embulk/parser/poi_excel/test1.xls +0 -0
- metadata +9 -4
- data/classpath/embulk-parser-poi_excel-0.1.1.jar +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d1be437da5c3e86a63ef4c925d3ba11218c5344
|
4
|
+
data.tar.gz: eb1b92328a4ac0c9619165bf046289538223e2ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de797f9fd1895bb79987ae4564d0a4288a7a4c4115b217194462d9f5912912b0c814214c6319a363923953feeeb62f70cc2e4261b2a27695b1a26e6b60324c5c
|
7
|
+
data.tar.gz: 8db340bcd1e3a46f54bd62513620c3d067432db0b5c28f71d9235f2dd3ae1aa5d0c37753ae1f1488f868e1915129c814d61d306dd58e9d58a602dcadd2ef9795
|
data/README.md
CHANGED
@@ -21,6 +21,8 @@ This plugin uses Apache POI.
|
|
21
21
|
* **value**: value type. see below. (string, defualt: `cell_value`)
|
22
22
|
* **column_number**: Excel column number. see below. (string, default: next column)
|
23
23
|
* **attribute_name**: use with value `cell_style`, `cell_font`, etc. see below. (list of string)
|
24
|
+
* **on_cell_error**: processing method of Cell error. see below. (string, default: `constant`)
|
25
|
+
* **on_convert_error**: processing method of convert error. see below. (string, default: `exception`)
|
24
26
|
|
25
27
|
### value
|
26
28
|
|
@@ -32,6 +34,10 @@ This plugin uses Apache POI.
|
|
32
34
|
* `sheet_name`: sheet name.
|
33
35
|
* `row_number`: row number(1 origin).
|
34
36
|
* `column_number`: column number(1 origin).
|
37
|
+
* `constant`: constant value.
|
38
|
+
|
39
|
+
* `constant.`*value*: specified value.
|
40
|
+
* `constant`: null.
|
35
41
|
|
36
42
|
### column_number
|
37
43
|
|
@@ -80,6 +86,35 @@ attribute_nameを指定することで、指定された属性だけを取得し
|
|
80
86
|
(`cell_value`では、**column_number**を省略すると次の列に移る)
|
81
87
|
|
82
88
|
|
89
|
+
### on_cell_error
|
90
|
+
|
91
|
+
Processing method of Cell error (`#DIV/0!`, `#REF!`, etc).
|
92
|
+
|
93
|
+
```yaml
|
94
|
+
columns:
|
95
|
+
- {name: foo, type: string, column_number: A, value: cell_value, on_cell_error: error_code}
|
96
|
+
```
|
97
|
+
|
98
|
+
* `constant`: set null. (default)
|
99
|
+
* `constant.`*value*: set value.
|
100
|
+
* `error_code`: set error code.
|
101
|
+
* `exception`: throw exception.
|
102
|
+
|
103
|
+
|
104
|
+
### on_convert_error
|
105
|
+
|
106
|
+
Processing method of convert error. ex) Excel boolean to Embulk timestamp
|
107
|
+
|
108
|
+
```yaml
|
109
|
+
columns:
|
110
|
+
- {name: foo, type: timestamp, format: "%Y/%m/%d", column_number: A, value: cell_value, on_convert_error: constant.9999/12/31}
|
111
|
+
```
|
112
|
+
|
113
|
+
* `constant`: set null.
|
114
|
+
* `constant.`*value*: set value.
|
115
|
+
* `exception`: throw exception. (default)
|
116
|
+
|
117
|
+
|
83
118
|
## Example
|
84
119
|
|
85
120
|
```yaml
|
data/build.gradle
CHANGED
Binary file
|
@@ -17,9 +17,8 @@ public enum PoiExcelColumnValueType {
|
|
17
17
|
ROW_NUMBER(false, false),
|
18
18
|
/** column number (1 origin) */
|
19
19
|
COLUMN_NUMBER(true, false),
|
20
|
-
|
21
|
-
|
22
|
-
;
|
20
|
+
/** constant */
|
21
|
+
CONSTANT(false, false);
|
23
22
|
|
24
23
|
private final boolean useCell;
|
25
24
|
private final boolean nextIndex;
|
@@ -3,6 +3,7 @@ package org.embulk.parser.poi_excel;
|
|
3
3
|
import java.io.IOException;
|
4
4
|
import java.util.ArrayList;
|
5
5
|
import java.util.List;
|
6
|
+
import java.util.Map;
|
6
7
|
|
7
8
|
import org.apache.poi.EncryptedDocumentException;
|
8
9
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
@@ -38,7 +39,7 @@ public class PoiExcelParserPlugin implements ParserPlugin {
|
|
38
39
|
|
39
40
|
public static final String TYPE = "poi_excel";
|
40
41
|
|
41
|
-
public interface PluginTask extends Task, TimestampParser.Task {
|
42
|
+
public interface PluginTask extends Task, TimestampParser.Task, SheetOptionTask {
|
42
43
|
@Config("sheet")
|
43
44
|
@ConfigDefault("null")
|
44
45
|
public Optional<String> getSheet();
|
@@ -51,66 +52,49 @@ public class PoiExcelParserPlugin implements ParserPlugin {
|
|
51
52
|
@ConfigDefault("false")
|
52
53
|
public boolean getIgnoreSheetNotFound();
|
53
54
|
|
54
|
-
@Config("
|
55
|
-
@ConfigDefault("
|
56
|
-
public
|
57
|
-
|
58
|
-
// search merged cell if cellType=BLANK
|
59
|
-
@Config("search_merged_cell")
|
60
|
-
@ConfigDefault("true")
|
61
|
-
public boolean getSearchMergedCell();
|
62
|
-
|
63
|
-
@Config("formula_replace")
|
64
|
-
@ConfigDefault("null")
|
65
|
-
public Optional<List<FormulaReplaceTask>> getFormulaReplace();
|
66
|
-
|
67
|
-
// true: set null if formula error
|
68
|
-
// false: throw exception if formula error
|
69
|
-
@Config("formula_error_null")
|
70
|
-
@ConfigDefault("false")
|
71
|
-
public boolean getFormulaErrorNull();
|
72
|
-
|
73
|
-
// true: set null if cell value error
|
74
|
-
// false: set error code if cell value error
|
75
|
-
@Config("cell_error_null")
|
76
|
-
@ConfigDefault("true")
|
77
|
-
public boolean getCellErrorNull();
|
55
|
+
@Config("sheet_options")
|
56
|
+
@ConfigDefault("{}")
|
57
|
+
public Map<String, SheetOptionTask> getSheetOptions();
|
78
58
|
|
79
59
|
@Config("flush_count")
|
80
60
|
@ConfigDefault("100")
|
81
61
|
public int getFlushCount();
|
62
|
+
}
|
63
|
+
|
64
|
+
public interface SheetOptionTask extends Task, ColumnCommonOptionTask {
|
65
|
+
|
66
|
+
@Config("skip_header_lines")
|
67
|
+
@ConfigDefault("null")
|
68
|
+
public Optional<Integer> getSkipHeaderLines();
|
82
69
|
|
83
70
|
@Config("columns")
|
84
71
|
public SchemaConfig getColumns();
|
85
72
|
}
|
86
73
|
|
87
|
-
public interface ColumnOptionTask extends Task {
|
74
|
+
public interface ColumnOptionTask extends Task, ColumnCommonOptionTask {
|
88
75
|
|
89
76
|
/**
|
90
77
|
* @see PoiExcelColumnValueType
|
91
78
|
* @return value_type
|
92
79
|
*/
|
93
80
|
@Config("value")
|
94
|
-
@ConfigDefault("
|
95
|
-
public String getValueType();
|
96
|
-
|
97
|
-
public void setValueTypeEnum(PoiExcelColumnValueType valueType);
|
98
|
-
|
99
|
-
public PoiExcelColumnValueType getValueTypeEnum();
|
100
|
-
|
101
|
-
public void setValueTypeSuffix(String suffix);
|
102
|
-
|
103
|
-
public String getValueTypeSuffix();
|
81
|
+
@ConfigDefault("null")
|
82
|
+
public Optional<String> getValueType();
|
104
83
|
|
105
84
|
// A,B,... or number(1 origin)
|
106
85
|
@Config("column_number")
|
107
86
|
@ConfigDefault("null")
|
108
87
|
public Optional<String> getColumnNumber();
|
109
88
|
|
110
|
-
|
89
|
+
// use when value_type=cell_style, cell_font, ...
|
90
|
+
@Config("attribute_name")
|
91
|
+
@ConfigDefault("null")
|
92
|
+
public Optional<List<String>> getAttributeName();
|
93
|
+
}
|
111
94
|
|
112
|
-
|
95
|
+
public interface ColumnCommonOptionTask extends Task {
|
113
96
|
|
97
|
+
// search merged cell if cellType=BLANK
|
114
98
|
@Config("search_merged_cell")
|
115
99
|
@ConfigDefault("null")
|
116
100
|
public Optional<Boolean> getSearchMergedCell();
|
@@ -119,18 +103,17 @@ public class PoiExcelParserPlugin implements ParserPlugin {
|
|
119
103
|
@ConfigDefault("null")
|
120
104
|
public Optional<List<FormulaReplaceTask>> getFormulaReplace();
|
121
105
|
|
122
|
-
@Config("
|
106
|
+
@Config("on_evaluate_error")
|
123
107
|
@ConfigDefault("null")
|
124
|
-
public Optional<
|
108
|
+
public Optional<String> getOnEvaluateError();
|
125
109
|
|
126
|
-
@Config("
|
110
|
+
@Config("on_cell_error")
|
127
111
|
@ConfigDefault("null")
|
128
|
-
public Optional<
|
112
|
+
public Optional<String> getOnCellError();
|
129
113
|
|
130
|
-
|
131
|
-
@Config("attribute_name")
|
114
|
+
@Config("on_convert_error")
|
132
115
|
@ConfigDefault("null")
|
133
|
-
public Optional<
|
116
|
+
public Optional<String> getOnConvertError();
|
134
117
|
}
|
135
118
|
|
136
119
|
public interface FormulaReplaceTask extends Task {
|
@@ -139,7 +122,7 @@ public class PoiExcelParserPlugin implements ParserPlugin {
|
|
139
122
|
public String getRegex();
|
140
123
|
|
141
124
|
// replace string
|
142
|
-
// use variable: "${row}"
|
125
|
+
// can use variable: "${row}"
|
143
126
|
@Config("to")
|
144
127
|
public String getTo();
|
145
128
|
}
|
@@ -182,7 +165,6 @@ public class PoiExcelParserPlugin implements ParserPlugin {
|
|
182
165
|
}
|
183
166
|
|
184
167
|
protected void run(PluginTask task, Schema schema, Workbook workbook, List<String> sheetNames, PageOutput output) {
|
185
|
-
int skipHeaderLines = task.getSkipHeaderLines();
|
186
168
|
final int flushCount = task.getFlushCount();
|
187
169
|
|
188
170
|
try (PageBuilder pageBuilder = new PageBuilder(Exec.getBufferAllocator(), schema, output)) {
|
@@ -198,8 +180,9 @@ public class PoiExcelParserPlugin implements ParserPlugin {
|
|
198
180
|
}
|
199
181
|
|
200
182
|
log.info("sheet={}", sheetName);
|
201
|
-
PoiExcelVisitorFactory factory = newPoiExcelVisitorFactory(task, sheet, pageBuilder);
|
183
|
+
PoiExcelVisitorFactory factory = newPoiExcelVisitorFactory(task, schema, sheet, pageBuilder);
|
202
184
|
PoiExcelColumnVisitor visitor = factory.getPoiExcelColumnVisitor();
|
185
|
+
final int skipHeaderLines = factory.getVisitorValue().getSheetBean().getSkipHeaderLines();
|
203
186
|
|
204
187
|
int count = 0;
|
205
188
|
for (Row row : sheet) {
|
@@ -222,8 +205,9 @@ public class PoiExcelParserPlugin implements ParserPlugin {
|
|
222
205
|
}
|
223
206
|
}
|
224
207
|
|
225
|
-
protected PoiExcelVisitorFactory newPoiExcelVisitorFactory(PluginTask task, Sheet sheet,
|
226
|
-
|
208
|
+
protected PoiExcelVisitorFactory newPoiExcelVisitorFactory(PluginTask task, Schema schema, Sheet sheet,
|
209
|
+
PageBuilder pageBuilder) {
|
210
|
+
PoiExcelVisitorValue visitorValue = new PoiExcelVisitorValue(task, schema, sheet, pageBuilder);
|
227
211
|
return new PoiExcelVisitorFactory(visitorValue);
|
228
212
|
}
|
229
213
|
}
|
@@ -0,0 +1,300 @@
|
|
1
|
+
package org.embulk.parser.poi_excel.bean;
|
2
|
+
|
3
|
+
import java.text.MessageFormat;
|
4
|
+
import java.util.ArrayList;
|
5
|
+
import java.util.Collections;
|
6
|
+
import java.util.List;
|
7
|
+
|
8
|
+
import org.embulk.config.ConfigException;
|
9
|
+
import org.embulk.parser.poi_excel.PoiExcelColumnValueType;
|
10
|
+
import org.embulk.parser.poi_excel.PoiExcelParserPlugin.ColumnCommonOptionTask;
|
11
|
+
import org.embulk.parser.poi_excel.PoiExcelParserPlugin.ColumnOptionTask;
|
12
|
+
import org.embulk.parser.poi_excel.PoiExcelParserPlugin.FormulaReplaceTask;
|
13
|
+
import org.embulk.parser.poi_excel.bean.PoiExcelColumnBean.ErrorStrategy.Strategy;
|
14
|
+
import org.embulk.spi.Column;
|
15
|
+
|
16
|
+
import com.google.common.base.Optional;
|
17
|
+
|
18
|
+
public class PoiExcelColumnBean {
|
19
|
+
|
20
|
+
protected final PoiExcelSheetBean sheetBean;
|
21
|
+
protected final Column column;
|
22
|
+
protected final List<ColumnOptionTask> columnTaskList = new ArrayList<>();
|
23
|
+
protected final List<ColumnCommonOptionTask> allTaskList = new ArrayList<>();
|
24
|
+
|
25
|
+
private PoiExcelColumnValueType valueType;
|
26
|
+
private String valueTypeSuffix;
|
27
|
+
private int columnIndex;
|
28
|
+
|
29
|
+
public PoiExcelColumnBean(PoiExcelSheetBean sheetBean, Column column, ColumnOptionTask mainTask,
|
30
|
+
ColumnOptionTask optionTask) {
|
31
|
+
this.sheetBean = sheetBean;
|
32
|
+
this.column = column;
|
33
|
+
|
34
|
+
if (optionTask != null) {
|
35
|
+
columnTaskList.add(optionTask);
|
36
|
+
}
|
37
|
+
columnTaskList.add(mainTask);
|
38
|
+
|
39
|
+
allTaskList.addAll(columnTaskList);
|
40
|
+
allTaskList.addAll(sheetBean.getSheetOption());
|
41
|
+
|
42
|
+
initialize();
|
43
|
+
}
|
44
|
+
|
45
|
+
private void initialize() {
|
46
|
+
String type = null;
|
47
|
+
for (ColumnOptionTask task : columnTaskList) {
|
48
|
+
Optional<String> option = task.getValueType();
|
49
|
+
if (option.isPresent()) {
|
50
|
+
type = option.get();
|
51
|
+
break;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
if (type == null) {
|
55
|
+
this.valueType = PoiExcelColumnValueType.CELL_VALUE;
|
56
|
+
return;
|
57
|
+
}
|
58
|
+
|
59
|
+
String suffix = null;
|
60
|
+
{
|
61
|
+
int n = type.indexOf('.');
|
62
|
+
if (n >= 0) {
|
63
|
+
suffix = type.substring(n + 1); // not trim
|
64
|
+
this.valueTypeSuffix = suffix.trim();
|
65
|
+
type = type.substring(0, n).trim();
|
66
|
+
}
|
67
|
+
}
|
68
|
+
|
69
|
+
try {
|
70
|
+
this.valueType = PoiExcelColumnValueType.valueOf(type.toUpperCase());
|
71
|
+
} catch (Exception e) {
|
72
|
+
throw new ConfigException(MessageFormat.format("illegal value_type={0}", type), e);
|
73
|
+
}
|
74
|
+
|
75
|
+
if (valueType == PoiExcelColumnValueType.CONSTANT) {
|
76
|
+
this.valueTypeSuffix = suffix; // not trim
|
77
|
+
}
|
78
|
+
}
|
79
|
+
|
80
|
+
public Column getColumn() {
|
81
|
+
return column;
|
82
|
+
}
|
83
|
+
|
84
|
+
public PoiExcelColumnValueType getValueType() {
|
85
|
+
return valueType;
|
86
|
+
}
|
87
|
+
|
88
|
+
public String getValueTypeSuffix() {
|
89
|
+
return valueTypeSuffix;
|
90
|
+
}
|
91
|
+
|
92
|
+
public void setColumnIndex(int columnIndex) {
|
93
|
+
this.columnIndex = columnIndex;
|
94
|
+
}
|
95
|
+
|
96
|
+
public int getColumnIndex() {
|
97
|
+
return columnIndex;
|
98
|
+
}
|
99
|
+
|
100
|
+
public Optional<String> getColumnNumber() {
|
101
|
+
for (ColumnOptionTask task : columnTaskList) {
|
102
|
+
Optional<String> option = task.getColumnNumber();
|
103
|
+
if (option.isPresent()) {
|
104
|
+
return option;
|
105
|
+
}
|
106
|
+
}
|
107
|
+
return Optional.absent();
|
108
|
+
}
|
109
|
+
|
110
|
+
protected abstract class CacheValue<T> {
|
111
|
+
private T value;
|
112
|
+
|
113
|
+
public CacheValue() {
|
114
|
+
}
|
115
|
+
|
116
|
+
public T get() {
|
117
|
+
if (value == null) {
|
118
|
+
T v = null;
|
119
|
+
for (ColumnCommonOptionTask task : allTaskList) {
|
120
|
+
Optional<T> option = getTaskValue(task);
|
121
|
+
if (option.isPresent()) {
|
122
|
+
v = option.get();
|
123
|
+
break;
|
124
|
+
}
|
125
|
+
}
|
126
|
+
if (v == null) {
|
127
|
+
v = getDefaultValue();
|
128
|
+
}
|
129
|
+
this.value = v;
|
130
|
+
}
|
131
|
+
return value;
|
132
|
+
}
|
133
|
+
|
134
|
+
protected abstract Optional<T> getTaskValue(ColumnCommonOptionTask task);
|
135
|
+
|
136
|
+
protected abstract T getDefaultValue();
|
137
|
+
}
|
138
|
+
|
139
|
+
public static final class ErrorStrategy {
|
140
|
+
private final Strategy strategy;
|
141
|
+
private final String value;
|
142
|
+
|
143
|
+
public static enum Strategy {
|
144
|
+
DEFAULT, EXCEPTION, CONSTANT, ERROR_CODE
|
145
|
+
}
|
146
|
+
|
147
|
+
public ErrorStrategy(Strategy strategy) {
|
148
|
+
this.strategy = strategy;
|
149
|
+
this.value = null;
|
150
|
+
}
|
151
|
+
|
152
|
+
public ErrorStrategy(String value) {
|
153
|
+
this.strategy = Strategy.CONSTANT;
|
154
|
+
this.value = value;
|
155
|
+
}
|
156
|
+
|
157
|
+
public Strategy getStrategy() {
|
158
|
+
return strategy;
|
159
|
+
}
|
160
|
+
|
161
|
+
public String getValue() {
|
162
|
+
return value;
|
163
|
+
}
|
164
|
+
|
165
|
+
@Override
|
166
|
+
public String toString() {
|
167
|
+
return String.format("ErrorStrategy(%s, %s)", strategy, value);
|
168
|
+
}
|
169
|
+
}
|
170
|
+
|
171
|
+
protected abstract class CacheErrorStrategy extends CacheValue<ErrorStrategy> {
|
172
|
+
|
173
|
+
public CacheErrorStrategy() {
|
174
|
+
}
|
175
|
+
|
176
|
+
@Override
|
177
|
+
protected Optional<ErrorStrategy> getTaskValue(ColumnCommonOptionTask task) {
|
178
|
+
Optional<String> option = getStringValue(task);
|
179
|
+
if (!option.isPresent()) {
|
180
|
+
return Optional.absent();
|
181
|
+
}
|
182
|
+
String value = option.get();
|
183
|
+
if ("null".equalsIgnoreCase(value)) {
|
184
|
+
value = Strategy.CONSTANT.name();
|
185
|
+
}
|
186
|
+
|
187
|
+
String suffix = null;
|
188
|
+
int n = value.indexOf('.');
|
189
|
+
if (n >= 0) {
|
190
|
+
suffix = value.substring(n + 1);
|
191
|
+
value = value.substring(0, n).trim();
|
192
|
+
}
|
193
|
+
try {
|
194
|
+
Strategy strategy = Strategy.valueOf(value.toUpperCase());
|
195
|
+
switch (strategy) {
|
196
|
+
case CONSTANT:
|
197
|
+
return Optional.of(new ErrorStrategy(suffix));
|
198
|
+
default:
|
199
|
+
return Optional.of(new ErrorStrategy(strategy));
|
200
|
+
}
|
201
|
+
} catch (Exception e) {
|
202
|
+
throw new ConfigException(MessageFormat.format("illegal on-error type={0}", value), e);
|
203
|
+
}
|
204
|
+
}
|
205
|
+
|
206
|
+
protected abstract Optional<String> getStringValue(ColumnCommonOptionTask task);
|
207
|
+
|
208
|
+
@Override
|
209
|
+
protected ErrorStrategy getDefaultValue() {
|
210
|
+
return new ErrorStrategy(Strategy.DEFAULT);
|
211
|
+
}
|
212
|
+
}
|
213
|
+
|
214
|
+
private CacheValue<List<String>> attributeName = new CacheValue<List<String>>() {
|
215
|
+
|
216
|
+
@Override
|
217
|
+
protected Optional<List<String>> getTaskValue(ColumnCommonOptionTask task) {
|
218
|
+
if (task instanceof ColumnOptionTask) {
|
219
|
+
return ((ColumnOptionTask) task).getAttributeName();
|
220
|
+
}
|
221
|
+
return Optional.absent();
|
222
|
+
}
|
223
|
+
|
224
|
+
@Override
|
225
|
+
protected List<String> getDefaultValue() {
|
226
|
+
return Collections.emptyList();
|
227
|
+
}
|
228
|
+
};
|
229
|
+
|
230
|
+
public List<String> getAttributeName() {
|
231
|
+
return attributeName.get();
|
232
|
+
}
|
233
|
+
|
234
|
+
private CacheValue<Boolean> searchMergedCell = new CacheValue<Boolean>() {
|
235
|
+
|
236
|
+
@Override
|
237
|
+
protected Optional<Boolean> getTaskValue(ColumnCommonOptionTask task) {
|
238
|
+
return task.getSearchMergedCell();
|
239
|
+
}
|
240
|
+
|
241
|
+
@Override
|
242
|
+
protected Boolean getDefaultValue() {
|
243
|
+
return true;
|
244
|
+
}
|
245
|
+
};
|
246
|
+
|
247
|
+
public boolean getSearchMergedCell() {
|
248
|
+
return searchMergedCell.get();
|
249
|
+
}
|
250
|
+
|
251
|
+
private CacheValue<List<FormulaReplaceTask>> formulaReplace = new CacheValue<List<FormulaReplaceTask>>() {
|
252
|
+
|
253
|
+
@Override
|
254
|
+
protected Optional<List<FormulaReplaceTask>> getTaskValue(ColumnCommonOptionTask task) {
|
255
|
+
return task.getFormulaReplace();
|
256
|
+
}
|
257
|
+
|
258
|
+
@Override
|
259
|
+
protected List<FormulaReplaceTask> getDefaultValue() {
|
260
|
+
return Collections.emptyList();
|
261
|
+
}
|
262
|
+
};
|
263
|
+
|
264
|
+
public List<FormulaReplaceTask> getFormulaReplace() {
|
265
|
+
return formulaReplace.get();
|
266
|
+
}
|
267
|
+
|
268
|
+
private CacheErrorStrategy evaluateErrorStrategy = new CacheErrorStrategy() {
|
269
|
+
@Override
|
270
|
+
protected Optional<String> getStringValue(ColumnCommonOptionTask task) {
|
271
|
+
return task.getOnEvaluateError();
|
272
|
+
}
|
273
|
+
};
|
274
|
+
|
275
|
+
public ErrorStrategy getEvaluateErrorStrategy() {
|
276
|
+
return evaluateErrorStrategy.get();
|
277
|
+
}
|
278
|
+
|
279
|
+
private CacheErrorStrategy cellErrorStrategy = new CacheErrorStrategy() {
|
280
|
+
@Override
|
281
|
+
protected Optional<String> getStringValue(ColumnCommonOptionTask task) {
|
282
|
+
return task.getOnCellError();
|
283
|
+
}
|
284
|
+
};
|
285
|
+
|
286
|
+
public ErrorStrategy getCellErrorStrategy() {
|
287
|
+
return cellErrorStrategy.get();
|
288
|
+
}
|
289
|
+
|
290
|
+
private CacheErrorStrategy convertErrorStrategy = new CacheErrorStrategy() {
|
291
|
+
@Override
|
292
|
+
protected Optional<String> getStringValue(ColumnCommonOptionTask task) {
|
293
|
+
return task.getOnConvertError();
|
294
|
+
}
|
295
|
+
};
|
296
|
+
|
297
|
+
public ErrorStrategy getConvertErrorStrategy() {
|
298
|
+
return convertErrorStrategy.get();
|
299
|
+
}
|
300
|
+
}
|