Skip to content

Commit 65a9395

Browse files
authored
Merge pull request #232 from ozlerhakan/3.1.7
fix code smells and bump new version 3.1.7
2 parents 48cc836 + d94daae commit 65a9395

16 files changed

+55
-74
lines changed

README.adoc

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
:toclevels: 2
33

44
= Poiji
5-
:version: v3.1.6
6-
:branch: 3.1.6
5+
:version: v3.1.7
6+
:branch: 3.1.7
77

8-
image:https://github.com/ozlerhakan/poiji/actions/workflows/maven.yml/badge.svg["Build Status"] image:https://app.codacy.com/project/badge/Grade/64f7e2cb9e604807b62334a4cfc3952d["Codacy code quality", link="https://www.codacy.com/gh/ozlerhakan/poiji/dashboard?utm_source=github.com&utm_medium=referral&utm_content=ozlerhakan/poiji&utm_campaign=Badge_Grade"]
9-
image:https://codecov.io/gh/ozlerhakan/poiji/branch/{branch}/graph/badge.svg?token=MN6V6xOWBq["Codecov", link="https://codecov.io/gh/ozlerhakan/poiji"] image:https://img.shields.io/badge/apache.poi-5.2.1-brightgreen.svg[] image:https://app.fossa.com/api/projects/git%2Bgithub.com%2Fozlerhakan%2Fpoiji.svg?type=shield["FOSSA Status", link="https://app.fossa.com/projects/git%2Bgithub.com%2Fozlerhakan%2Fpoiji?ref=badge_shield"]
8+
image:https://github.com/ozlerhakan/poiji/actions/workflows/maven.yml/badge.svg["Build Status"] image:https://app.codacy.com/project/badge/Grade/64f7e2cb9e604807b62334a4cfc3952d["Codacy code quality",link="https://www.codacy.com/gh/ozlerhakan/poiji/dashboard?utm_source=github.com&utm_medium=referral&utm_content=ozlerhakan/poiji&utm_campaign=Badge_Grade"]
9+
image:https://codecov.io/gh/ozlerhakan/poiji/branch/{branch}/graph/badge.svg?token=MN6V6xOWBq["Codecov",link="https://codecov.io/gh/ozlerhakan/poiji"] image:https://img.shields.io/badge/apache.poi-5.2.1-brightgreen.svg[] image:https://app.fossa.com/api/projects/git%2Bgithub.com%2Fozlerhakan%2Fpoiji.svg?type=shield["FOSSA Status",link="https://app.fossa.com/projects/git%2Bgithub.com%2Fozlerhakan%2Fpoiji?ref=badge_shield"]
1010

11-
Poiji is a tiny thread-safe Java library that provides one way mapping from Excel sheets to Java classes. In a way it lets us convert each row of the specified excel data into Java objects. Poiji uses https://poi.apache.org/[Apache Poi] (the Java API for Microsoft Documents) under the hood to fulfill the mapping process.
11+
Poiji is a tiny thread-safe Java library that provides one way mapping from Excel sheets to Java classes.
12+
In a way it lets us convert each row of the specified excel data into Java objects.
13+
Poiji uses https://poi.apache.org/[Apache Poi] (the Java API for Microsoft Documents) under the hood to fulfill the mapping process.
1214

1315
[%collapsible]
1416
toc::[]
@@ -23,15 +25,15 @@ In your Maven/Gradle project, first add the corresponding dependency:
2325
<dependency>
2426
<groupId>com.github.ozlerhakan</groupId>
2527
<artifactId>poiji</artifactId>
26-
<version>3.1.6</version>
28+
<version>3.1.7</version>
2729
</dependency>
2830
----
2931

3032
.gradle
3133
[source,groovy]
3234
----
3335
dependencies {
34-
compile 'com.github.ozlerhakan:poiji:3.1.6'
36+
compile 'com.github.ozlerhakan:poiji:3.1.7'
3537
}
3638
----
3739

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.github.ozlerhakan</groupId>
88
<artifactId>poiji</artifactId>
9-
<version>3.1.6</version>
9+
<version>3.1.7</version>
1010
<packaging>jar</packaging>
1111

1212
<name>poiji</name>

src/main/java/com/poiji/bind/Poiji.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ public static <T> void fromExcel(final Sheet sheet,
366366
final PoijiOptions options,
367367
final Consumer<? super T> consumer) {
368368
Objects.requireNonNull(sheet);
369-
final Unmarshaller unmarshaller = UnmarshallerHelper.SheetInstance(sheet, options);
369+
final Unmarshaller unmarshaller = UnmarshallerHelper.sheetInstance(sheet, options);
370370
unmarshaller.unmarshal(type, consumer);
371371
}
372372

@@ -376,9 +376,9 @@ private static Unmarshaller deserializer(final File file, final PoijiOptions opt
376376
String extension = files.getExtension(file.getName());
377377

378378
if (XLS_EXTENSION.equals(extension)) {
379-
return UnmarshallerHelper.HSSFInstance(poijiFile, options);
379+
return UnmarshallerHelper.hssfInstance(poijiFile, options);
380380
} else if (XLSX_EXTENSION.equals(extension)) {
381-
return UnmarshallerHelper.XSSFInstance(poijiFile, options);
381+
return UnmarshallerHelper.xssfInstance(poijiFile, options);
382382
} else {
383383
throw new InvalidExcelFileExtension("Invalid file extension (" + extension + "), expected .xls or .xlsx");
384384
}
@@ -388,9 +388,9 @@ private static Unmarshaller deserializer(final InputStream inputStream, PoijiExc
388388
final PoijiInputStream<?> poijiInputStream = new PoijiInputStream<>(inputStream);
389389

390390
if (excelType == PoijiExcelType.XLS) {
391-
return UnmarshallerHelper.HSSFInstance(poijiInputStream, options);
391+
return UnmarshallerHelper.hssfInstance(poijiInputStream, options);
392392
} else if (excelType == PoijiExcelType.XLSX) {
393-
return UnmarshallerHelper.XSSFInstance(poijiInputStream, options);
393+
return UnmarshallerHelper.xssfInstance(poijiInputStream, options);
394394
} else {
395395
throw new InvalidExcelFileExtension("Invalid file extension (" + excelType + "), expected .xls or .xlsx");
396396
}

src/main/java/com/poiji/bind/mapping/PoijiNumberFormat.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ public final class PoijiNumberFormat {
1212

1313
private final SortedMap<Short, String> numberFormats = new TreeMap<>();
1414

15-
public PoijiNumberFormat() {
16-
}
17-
1815
public void putNumberFormat(short index, String fmt) {
1916
numberFormats.put(index, fmt);
2017
}

src/main/java/com/poiji/bind/mapping/PropertyHandler.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77
import java.lang.reflect.Field;
88
import java.util.stream.Stream;
99

10-
import static com.poiji.util.DefaultExcelProperties.CATEGORY;
11-
import static com.poiji.util.DefaultExcelProperties.CONTENT_STATUS;
12-
import static com.poiji.util.DefaultExcelProperties.CREATED;
13-
import static com.poiji.util.DefaultExcelProperties.CREATOR;
14-
import static com.poiji.util.DefaultExcelProperties.DESCRIPTION;
15-
import static com.poiji.util.DefaultExcelProperties.KEYWORDS;
16-
import static com.poiji.util.DefaultExcelProperties.LAST_PRINTED;
17-
import static com.poiji.util.DefaultExcelProperties.MODIFIED;
18-
import static com.poiji.util.DefaultExcelProperties.REVISION;
19-
import static com.poiji.util.DefaultExcelProperties.SUBJECT;
20-
import static com.poiji.util.DefaultExcelProperties.TITLE;
10+
import static com.poiji.util.DefaultExcelPropertiesHelper.CATEGORY;
11+
import static com.poiji.util.DefaultExcelPropertiesHelper.CONTENT_STATUS;
12+
import static com.poiji.util.DefaultExcelPropertiesHelper.CREATED;
13+
import static com.poiji.util.DefaultExcelPropertiesHelper.CREATOR;
14+
import static com.poiji.util.DefaultExcelPropertiesHelper.DESCRIPTION;
15+
import static com.poiji.util.DefaultExcelPropertiesHelper.KEYWORDS;
16+
import static com.poiji.util.DefaultExcelPropertiesHelper.LAST_PRINTED;
17+
import static com.poiji.util.DefaultExcelPropertiesHelper.MODIFIED;
18+
import static com.poiji.util.DefaultExcelPropertiesHelper.REVISION;
19+
import static com.poiji.util.DefaultExcelPropertiesHelper.SUBJECT;
20+
import static com.poiji.util.DefaultExcelPropertiesHelper.TITLE;
2121

2222
public final class PropertyHandler {
2323

src/main/java/com/poiji/bind/mapping/UnmarshallerHelper.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,23 @@
1111
*/
1212
public final class UnmarshallerHelper {
1313

14-
public static Unmarshaller HSSFInstance(PoijiFile<?> poijiFile, PoijiOptions options) {
14+
public static Unmarshaller hssfInstance(PoijiFile<?> poijiFile, PoijiOptions options) {
1515
return new HSSFUnmarshallerFile(poijiFile, options);
1616
}
1717

18-
public static Unmarshaller HSSFInstance(PoijiInputStream<?> poijiInputStream, PoijiOptions options) {
18+
public static Unmarshaller hssfInstance(PoijiInputStream<?> poijiInputStream, PoijiOptions options) {
1919
return new HSSFUnmarshallerStream(poijiInputStream, options);
2020
}
2121

22-
public static Unmarshaller XSSFInstance(PoijiFile<?> poijiFile, PoijiOptions options) {
22+
public static Unmarshaller xssfInstance(PoijiFile<?> poijiFile, PoijiOptions options) {
2323
return new XSSFUnmarshallerFile(poijiFile, options);
2424
}
2525

26-
public static Unmarshaller XSSFInstance(PoijiInputStream<?> poijiInputStream, PoijiOptions options) {
26+
public static Unmarshaller xssfInstance(PoijiInputStream<?> poijiInputStream, PoijiOptions options) {
2727
return new XSSFUnmarshallerStream(poijiInputStream, options);
2828
}
2929

30-
public static Unmarshaller SheetInstance(Sheet sheet, PoijiOptions options) {
30+
public static Unmarshaller sheetInstance(Sheet sheet, PoijiOptions options) {
3131
return new SheetUnmarshaller(sheet, options);
3232
}
3333
}

src/main/java/com/poiji/bind/mapping/XSSFUnmarshaller.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,9 @@ protected <T> void unmarshal0(Class<T> type, Consumer<? super T> consumer, OPCPa
8282
while (iter.hasNext()) {
8383
try (InputStream stream = iter.next()) {
8484
WorkBookSheet wbs = sheets.get(sheetCounter);
85-
if (wbs.getState().equals("visible")) {
86-
if (iter.getSheetName().equalsIgnoreCase(sheetName)) {
87-
processSheet(styles, reader, readOnlySharedStringsTable, type, stream, consumer);
88-
return;
89-
}
85+
if (wbs.getState().equals("visible") && iter.getSheetName().equalsIgnoreCase(sheetName)) {
86+
processSheet(styles, reader, readOnlySharedStringsTable, type, stream, consumer);
87+
return;
9088
}
9189
}
9290
sheetCounter++;

src/main/java/com/poiji/config/DefaultCasting.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,6 @@ private BigDecimal bigDecimalValue(String value, String sheetName, int row, int
133133
}
134134
}
135135

136-
private String[] parseArrayList(String value, PoijiOptions options, String sheetName, int row, int col) {
137-
try {
138-
return value.split(options.getListDelimiter());
139-
} catch (Exception e) {
140-
return onError(value, sheetName, row, col, e, options.preferNullOverDefault() ? null : new String[]{});
141-
}
142-
}
143-
144136
private Date dateValue(String value, String sheetName, int row, int col, PoijiOptions options) {
145137

146138
//ISSUE #57

src/main/java/com/poiji/config/DefaultFormatting.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,16 @@
44

55
public class DefaultFormatting implements Formatting {
66

7-
public DefaultFormatting() {
8-
}
9-
107
@Override
118
public String transform(PoijiOptions options, String value) {
9+
String valueNorm = value;
1210
if (options.getCaseInsensitive()) {
13-
value = value.toLowerCase();
11+
valueNorm = valueNorm.toLowerCase();
1412
}
1513
if (options.getIgnoreWhitespaces()) {
16-
value = value.trim();
14+
valueNorm = valueNorm.trim();
1715
}
18-
return value;
16+
return valueNorm;
1917
}
2018

2119
}

src/main/java/com/poiji/util/DefaultExcelProperties.java renamed to src/main/java/com/poiji/util/DefaultExcelPropertiesHelper.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
This file contains the built-in excel properties, which can be read with Poiji
55
Each of these properties has corresponds to a certain type.
66
*/
7-
public final class DefaultExcelProperties {
8-
private DefaultExcelProperties() {
9-
}
7+
public final class DefaultExcelPropertiesHelper {
108

119
public static final String CATEGORY = "category"; //java.util.String
1210
public static final String CONTENT_STATUS = "contentStatus"; //java.util.String
@@ -19,4 +17,7 @@ private DefaultExcelProperties() {
1917
public static final String SUBJECT = "subject"; //java.util.String
2018
public static final String TITLE = "title"; //java.util.String
2119
public static final String REVISION = "revision"; //java.util.String
20+
21+
private DefaultExcelPropertiesHelper() {
22+
}
2223
}

0 commit comments

Comments
 (0)