@@ -35,7 +35,7 @@ public DefaultCasting(boolean errorLoggingEnabled) {
3535 this .errorLoggingEnabled = errorLoggingEnabled ;
3636 }
3737
38- private <T > T onError (String value , String sheetName , int row , int col , Exception exception , T defaultValue ) {
38+ protected <T > T onError (String value , String sheetName , int row , int col , Exception exception , T defaultValue ) {
3939 logError (value , defaultValue , sheetName , row , col , exception );
4040 return defaultValue ;
4141 }
@@ -46,87 +46,87 @@ private void logError(String value, Object defaultValue, String sheetName, int r
4646 }
4747 }
4848
49- private Boolean primitiveBooleanValue (String value , String sheetName , int row , int col ) {
49+ protected Boolean primitiveBooleanValue (String value , String sheetName , int row , int col ) {
5050 try {
5151 return Parsers .booleans ().parse (value );
5252 } catch (BooleanParser .BooleanParseException bpe ) {
5353 return onError (value , sheetName , row , col , bpe , false );
5454 }
5555 }
5656
57- private Boolean booleanValue (String value , String sheetName , int row , int col , PoijiOptions options ) {
57+ protected Boolean booleanValue (String value , String sheetName , int row , int col , PoijiOptions options ) {
5858 try {
5959 return Parsers .booleans ().parse (value );
6060 } catch (BooleanParser .BooleanParseException bpe ) {
6161 return onError (value , sheetName , row , col , bpe , options .preferNullOverDefault () ? null : false );
6262 }
6363 }
6464
65- private int primitiveIntegerValue (String value , String sheetName , int row , int col ) {
65+ protected int primitiveIntegerValue (String value , String sheetName , int row , int col ) {
6666 try {
6767 return Parsers .integers ().parse (value ).intValue ();
6868 } catch (NumberFormatException nfe ) {
6969 return onError (value , sheetName , row , col , nfe , 0 );
7070 }
7171 }
7272
73- private Integer integerValue (String value , String sheetName , int row , int col , PoijiOptions options ) {
73+ protected Integer integerValue (String value , String sheetName , int row , int col , PoijiOptions options ) {
7474 try {
7575 return Parsers .integers ().parse (value ).intValue ();
7676 } catch (NumberFormatException nfe ) {
7777 return onError (value , sheetName , row , col , nfe , options .preferNullOverDefault () ? null : 0 );
7878 }
7979 }
8080
81- private long primitiveLongValue (String value , String sheetName , int row , int col ) {
81+ protected long primitiveLongValue (String value , String sheetName , int row , int col ) {
8282 try {
8383 return Parsers .longs ().parse (value ).longValue ();
8484 } catch (NumberFormatException nfe ) {
8585 return onError (value , sheetName , row , col , nfe , 0L );
8686 }
8787 }
8888
89- private Long longValue (String value , String sheetName , int row , int col , PoijiOptions options ) {
89+ protected Long longValue (String value , String sheetName , int row , int col , PoijiOptions options ) {
9090 try {
9191 return Parsers .longs ().parse (value ).longValue ();
9292 } catch (NumberFormatException nfe ) {
9393 return onError (value , sheetName , row , col , nfe , options .preferNullOverDefault () ? null : 0L );
9494 }
9595 }
9696
97- private double primitiveDoubleValue (String value , String sheetName , int row , int col , PoijiOptions options ) {
97+ protected double primitiveDoubleValue (String value , String sheetName , int row , int col , PoijiOptions options ) {
9898 try {
9999 return Parsers .numbers (options .getLocale ()).parse (value ).doubleValue ();
100100 } catch (NumberFormatException nfe ) {
101101 return onError (value , sheetName , row , col , nfe , 0d );
102102 }
103103 }
104104
105- private Double doubleValue (String value , String sheetName , int row , int col , PoijiOptions options ) {
105+ protected Double doubleValue (String value , String sheetName , int row , int col , PoijiOptions options ) {
106106 try {
107107 return Parsers .numbers (options .getLocale ()).parse (value ).doubleValue ();
108108 } catch (NumberFormatException nfe ) {
109109 return onError (value , sheetName , row , col , nfe , options .preferNullOverDefault () ? null : 0d );
110110 }
111111 }
112112
113- private float primitiveFloatValue (String value , String sheetName , int row , int col , PoijiOptions options ) {
113+ protected float primitiveFloatValue (String value , String sheetName , int row , int col , PoijiOptions options ) {
114114 try {
115115 return Parsers .numbers (options .getLocale ()).parse (value ).floatValue ();
116116 } catch (NumberFormatException nfe ) {
117117 return onError (value , sheetName , row , col , nfe , 0f );
118118 }
119119 }
120120
121- private Float floatValue (String value , String sheetName , int row , int col , PoijiOptions options ) {
121+ protected Float floatValue (String value , String sheetName , int row , int col , PoijiOptions options ) {
122122 try {
123123 return Parsers .numbers (options .getLocale ()).parse (value ).floatValue ();
124124 } catch (NumberFormatException nfe ) {
125125 return onError (value , sheetName , row , col , nfe , options .preferNullOverDefault () ? null : 0f );
126126 }
127127 }
128128
129- private BigDecimal bigDecimalValue (String value , String sheetName , int row , int col , PoijiOptions options ) {
129+ protected BigDecimal bigDecimalValue (String value , String sheetName , int row , int col , PoijiOptions options ) {
130130 try {
131131 return Parsers .bigDecimals (options .getLocale ()).parse (value );
132132 } catch (NumberFormatException | IllegalStateException e ) {
@@ -146,7 +146,7 @@ private BigDecimal bigDecimalValue(String value, String sheetName, int row, int
146146 * date object without any exceptions but since the string was not an exact
147147 * match you get a very strange date
148148 */
149- private Date dateValue (String value , String sheetName , int row , int col , PoijiOptions options ) {
149+ protected Date dateValue (String value , String sheetName , int row , int col , PoijiOptions options ) {
150150
151151 if (options .getDateRegex () != null && !value .matches (options .getDateRegex ())) {
152152 return options .preferNullOverDefault () ? null : Calendar .getInstance ().getTime ();
@@ -174,7 +174,7 @@ private Date dateValue(String value, String sheetName, int row, int col, PoijiOp
174174 * match you get a very strange date
175175 *
176176 */
177- private LocalDate localDateValue (String value , String sheetName , int row , int col , PoijiOptions options ) {
177+ protected LocalDate localDateValue (String value , String sheetName , int row , int col , PoijiOptions options ) {
178178 if (options .getDateRegex () != null && !value .matches (options .getDateRegex ())) {
179179 return options .preferNullOverDefault () ? null : LocalDate .now ();
180180 } else {
@@ -186,7 +186,7 @@ private LocalDate localDateValue(String value, String sheetName, int row, int co
186186 }
187187 }
188188
189- private LocalDateTime localDateTimeValue (String value , String sheetName , int row , int col , PoijiOptions options ) {
189+ protected LocalDateTime localDateTimeValue (String value , String sheetName , int row , int col , PoijiOptions options ) {
190190 if (options .getDateTimeRegex () != null && !value .matches (options .getDateTimeRegex ())) {
191191 return options .preferNullOverDefault () ? null : LocalDateTime .now ();
192192 } else {
@@ -199,7 +199,7 @@ private LocalDateTime localDateTimeValue(String value, String sheetName, int row
199199 }
200200 }
201201
202- private Object enumValue (String value , String sheetName , int row , int col , Class <?> type ) {
202+ protected Object enumValue (String value , String sheetName , int row , int col , Class <?> type ) {
203203 return Arrays .stream (type .getEnumConstants ())
204204 .filter (o -> ((Enum <?>) o ).name ().equals (value ))
205205 .findFirst ()
@@ -210,7 +210,7 @@ private Object enumValue(String value, String sheetName, int row, int col, Class
210210 });
211211 }
212212
213- private Object castListValue (String value , String sheetName , int row , int col , Field field , PoijiOptions options ) {
213+ protected Object castListValue (String value , String sheetName , int row , int col , Field field , PoijiOptions options ) {
214214 final ParameterizedType genericType = (ParameterizedType ) field .getGenericType ();
215215 final Type fieldType = genericType .getActualTypeArguments ()[0 ];
216216 String [] valueList = value .split (options .getListDelimiter ());
0 commit comments