Class BooleanNormalizer
java.lang.Object
com.broadleafcommerce.dataimport.service.normalizer.BooleanNormalizer
- All Implemented Interfaces:
ImportDataNormalizer
There are situations where MS Excel converts the word "true" to "TRUE" and "false" to "FALSE".
This can interfere with JSON serialization. To avoid this, we simply look for all fields that
have "true" or "false" in any type case, and convert to lowercase, which is what the JSON
serializer (and Java) expects for Boolean values. So this essentially converts the word "TRUE",
in any type case, to "true". Similarly, it converts the word "FALSE", in any type case, to
"false".
- Author:
- Kelly Tisdell (ktisdell)
-
Constructor Summary
ConstructorDescriptionUse this constructor when ALL boolean values should be normalized, regardless of the header.BooleanNormalizer
(List<String> headerNamesToNormalize) Use this constructor to normalize only certain headers. -
Method Summary
Modifier and TypeMethodDescriptionThe list of header names to normalize.void
Normalizes data under certain headers fromImportDataNormalizer.getHeaderNamesToNormalize()
.
-
Constructor Details
-
BooleanNormalizer
public BooleanNormalizer()Use this constructor when ALL boolean values should be normalized, regardless of the header.getHeaderNamesToNormalize()
will just contain a single element withWILDCARD
. -
BooleanNormalizer
Use this constructor to normalize only certain headers.- Parameters:
headerNamesToNormalize
- the header names that this normalizer should apply to. This list cannot contain the wildcard '*', as that would mean the normalizer needs to apply to all headers. For that behavior, usethe default constructor
.
-
-
Method Details
-
normalize
Description copied from interface:ImportDataNormalizer
Normalizes data under certain headers fromImportDataNormalizer.getHeaderNamesToNormalize()
.- Specified by:
normalize
in interfaceImportDataNormalizer
- Parameters:
row
- the row of data parsed out from the file
-
getHeaderNamesToNormalize
Description copied from interface:ImportDataNormalizer
The list of header names to normalize. This list is used to retrieve the value from the row map.- Specified by:
getHeaderNamesToNormalize
in interfaceImportDataNormalizer
- Returns:
- the list of header names to normalize
-