Skip to content

Commit

Permalink
change the option signature and name
Browse files Browse the repository at this point in the history
Signed-off-by: Hakan Ozler <ozler.hakan@gmail.com>
  • Loading branch information
ozlerhakan committed May 30, 2021
1 parent b837d68 commit 45f9364
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 38 deletions.
52 changes: 27 additions & 25 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -59,31 +59,33 @@ com.poiji.bind.Poiji#fromExcelProperties(java.io.InputStream, com.poiji.exceptio

.`PoijiOptions.PoijiOptionsBuilder` Structure
----
com.poiji.option.PoijiOptions.PoijiOptionsBuilder#settings()
com.poiji.option.PoijiOptions.PoijiOptionsBuilder#build()
com.poiji.option.PoijiOptions.PoijiOptionsBuilder#dateLenient(boolean)
com.poiji.option.PoijiOptions.PoijiOptionsBuilder#dateRegex(String)
com.poiji.option.PoijiOptions.PoijiOptionsBuilder#datePattern(String)
com.poiji.option.PoijiOptions.PoijiOptionsBuilder#dateTimeFormatter(java.time.format.DateTimeFormatter)
com.poiji.option.PoijiOptions.PoijiOptionsBuilder#ignoreHiddenSheets(boolean)
com.poiji.option.PoijiOptions.PoijiOptionsBuilder#password(String)
com.poiji.option.PoijiOptions.PoijiOptionsBuilder#preferNullOverDefault(boolean)
com.poiji.option.PoijiOptions.PoijiOptionsBuilder#settings(int)
com.poiji.option.PoijiOptions.PoijiOptionsBuilder#sheetIndex(int)
com.poiji.option.PoijiOptions.PoijiOptionsBuilder#skip(int)
com.poiji.option.PoijiOptions.PoijiOptionsBuilder#limit(int)
com.poiji.option.PoijiOptions.PoijiOptionsBuilder#trimCellValue(boolean)
com.poiji.option.PoijiOptions.PoijiOptionsBuilder#headerStart(int)
com.poiji.option.PoijiOptions.PoijiOptionsBuilder#withCasting(Casting)
com.poiji.option.PoijiOptions.PoijiOptionsBuilder#withFormatting(Formatting)
com.poiji.option.PoijiOptions.PoijiOptionsBuilder#caseInsensitive(boolean)
com.poiji.option.PoijiOptions.PoijiOptionsBuilder#ignoreWhitespaces(boolean)
com.poiji.option.PoijiOptions.PoijiOptionsBuilder#namedHeaderMandatory(boolean)
com.poiji.option.PoijiOptions.PoijiOptionsBuilder#poijiNumberFormat(PoijiNumberFormat)
com.poiji.option.PoijiOptions.PoijiOptionsBuilder#poijiLogCellFormat(PoijiLogCellFormat)
com.poiji.option.PoijiOptions.PoijiOptionsBuilder#disableXLSXNumberCellFormat()
com.poiji.option.PoijiOptions.PoijiOptionsBuilder#addListDelimiter(String)
com.poiji.option.PoijiOptions.PoijiOptionsBuilder#setLocale(java.util.Locale)
com.poiji.option.PoijiOptions.PoijiOptionsBuilder
#settings()
#build()
#dateLenient(boolean)
#dateRegex(String)
#datePattern(String)
#dateTimeFormatter(java.time.format.DateTimeFormatter)
#ignoreHiddenSheets(boolean)
#password(String)
#preferNullOverDefault(boolean)
#settings(int)
#sheetIndex(int)
#skip(int)
#limit(int)
#trimCellValue(boolean)
#headerStart(int)
#withCasting(Casting)
#withFormatting(Formatting)
#caseInsensitive(boolean)
#ignoreWhitespaces(boolean)
#namedHeaderMandatory(boolean)
#poijiNumberFormat(PoijiNumberFormat)
#poijiLogCellFormat(PoijiLogCellFormat)
#disableXLSXNumberCellFormat()
#addListDelimiter(String)
#setLocale(java.util.Locale)
#rawData(boolean)
----

=== Feature 1
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/poiji/bind/mapping/HSSFUnmarshaller.java
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ private <T> void constructTypeValue(Row currentRow, T instance, Field field, Fie
cell.setCellStyle(null);
}
String value;
if (options.isReturnRawValues() && cell.getCellType() == CellType.NUMERIC) {
if (options.isRawData() && cell.getCellType() == CellType.NUMERIC) {
value = NumberToTextConverter.toText(cell.getNumericCellValue());
} else {
value = dataFormatter.formatCellValue(cell, baseFormulaEvaluator);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public PoijiDataFormatter(PoijiOptions options) {

@Override
public String formatRawCellContents(double value, int formatIndex, String formatString, boolean use1904Windowing) {
if (!DateUtil.isADateFormat(formatIndex, formatString) && options.isReturnRawValues()) {
if (!DateUtil.isADateFormat(formatIndex, formatString) && options.isRawData()) {
return NumberToTextConverter.toText(value);
} else {
return super.formatRawCellContents(value, formatIndex, formatString, use1904Windowing);
Expand Down
21 changes: 11 additions & 10 deletions src/main/java/com/poiji/option/PoijiOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public final class PoijiOptions {
private String listDelimiter;
private Formatting formatting;
private Locale locale;
private boolean returnRawValues;
private boolean rawData;

public PoijiNumberFormat getPoijiNumberFormat() {
return numberFormat;
Expand Down Expand Up @@ -295,12 +295,12 @@ private PoijiOptions setLocale(Locale locale) {
return this;
}

public boolean isReturnRawValues() {
return returnRawValues;
public boolean isRawData() {
return rawData;
}

private PoijiOptions setReturnRawValues(boolean returnRawValues) {
this.returnRawValues = returnRawValues;
private PoijiOptions setRawData(boolean rawData) {
this.rawData = rawData;
return this;
}

Expand Down Expand Up @@ -332,7 +332,7 @@ public static class PoijiOptionsBuilder {
private boolean disabledXLSXNumberCellFormat;
private String listDelimiter = ",";
private Locale locale = Locale.US;
private boolean returnRawValues;
private boolean rawData;

private PoijiOptionsBuilder() {
}
Expand Down Expand Up @@ -446,7 +446,7 @@ public PoijiOptions build() {
.setListDelimiter(listDelimiter)
.setFormatting(formatting)
.setLocale(locale)
.setReturnRawValues(returnRawValues);
.setRawData(rawData);

}

Expand Down Expand Up @@ -710,12 +710,13 @@ public PoijiOptionsBuilder withFormatting(Formatting formatting) {
}

/**
* Use this option to get the underlying/original/non-visible cell value. The cell must be a numeric type.
* Use this option to get the underlying/original/non-visible/raw cell value. The cell must be a numeric type.
*
* @param status set true to retrieve the underlying data in the excel file.
* @return this
*/
public PoijiOptionsBuilder returnNumericRawValues() {
this.returnRawValues = true;
public PoijiOptionsBuilder rawData(boolean status) {
this.rawData = status;
return this;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/poiji/deserialize/RawValueTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static Iterable<Object[]> queries() {
@Test
public void shouldMapCalculations() {

PoijiOptions options = PoijiOptions.PoijiOptionsBuilder.settings().headerCount(0).returnNumericRawValues().build();
PoijiOptions options = PoijiOptions.PoijiOptionsBuilder.settings().headerCount(0).rawData(true).build();
List<RowModel> models = Poiji.fromExcel(new File(path), RowModel.class, options);

for (RowModel model : models) {
Expand Down

0 comments on commit 45f9364

Please sign in to comment.