Commit e4360f47 authored by Matija Obreza's avatar Matija Obreza
Browse files

Support split and regexp for all types using toString()

parent 77d32386
...@@ -131,23 +131,27 @@ public class RowConverter { ...@@ -131,23 +131,27 @@ public class RowConverter {
private static Object convertCellValue(Object value, boolean splitString, String separator, String pattern, String groupPattern) { private static Object convertCellValue(Object value, boolean splitString, String separator, String pattern, String groupPattern) {
if (value != null) { if (value != null) {
if (value instanceof String) { if (splitString) {
String stringValue = ((String) value); String stringValue = value.toString();
if (StringUtils.isBlank(stringValue)) { if (StringUtils.isBlank(stringValue)) {
return null; return null;
} }
if (splitString) { String[] split = stringValue.split(separator);
String[] split = stringValue.split(separator); for (int i = split.length - 1; i >= 0; i--) {
for (int i = split.length - 1; i >= 0; i--) { if (pattern != null) {
if (pattern != null) { split[i] = valueFromPattern(split[i].trim(), pattern, groupPattern);
split[i] = valueFromPattern(split[i].trim(), pattern, groupPattern); } else {
} else { split[i] = split[i].trim();
split[i] = split[i].trim();
}
} }
return split;
} }
return split;
}
if (StringUtils.isNotBlank(pattern)) {
String stringValue = value.toString();
if (StringUtils.isBlank(stringValue)) {
return null;
}
String patVal = valueFromPattern(stringValue.trim(), pattern, groupPattern); String patVal = valueFromPattern(stringValue.trim(), pattern, groupPattern);
if (StringUtils.isBlank(patVal)) { if (StringUtils.isBlank(patVal)) {
return null; return null;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment