Class RangeParser
java.lang.Object
com.hybris.backoffice.excel.importing.parser.RangeParser
- All Implemented Interfaces:
ImportParameterParser,org.springframework.core.Ordered
Implementation of
ImportParameterParser which allows to parse default values for classification' ranges-
Field Summary
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ParsedValuesgetLeftParsedValues(String cellValue, DefaultValues defaultValues) intgetOrder()protected ParsedValuesgetRightParsedValues(String cellValue, DefaultValues defaultValues) booleanChecks whether given input matches toRangeParserUtils.RANGE_PATTERN.protected DefaultValuesmergeDefaultValues(DefaultValues from, DefaultValues to) parseDefaultValues(String referenceFormat, String defaultValues) Parses referencePattern cell (which is located in the second row) and default values cell (which is located in the third row) and creates map where key equals to reference key and value equals to value provided in the third row.parseValue(String cellValue, DefaultValues defaultValues) Parses referencePattern cell (which is located in the second row) and cell with data (which is located in the data row) and creates map where key equals to reference key and value equals to value provided in the data row.parseValue(String referenceFormat, String defaultValues, String values) Parses given values and default values basing on referenceFormatvoidsetOrder(int order) voidsetParserRegistry(ParserRegistry parserRegistry)
-
Constructor Details
-
RangeParser
public RangeParser()
-
-
Method Details
-
matches
Checks whether given input matches toRangeParserUtils.RANGE_PATTERN.- Specified by:
matchesin interfaceImportParameterParser- Parameters:
referenceFormat- value to check- Returns:
- true if given input matches to pattern, false otherwise
-
parseValue
public ParsedValues parseValue(@Nonnull String referenceFormat, String defaultValues, String values) Parses given values and default values basing on referenceFormat- Specified by:
parseValuein interfaceImportParameterParser- Parameters:
referenceFormat- format of cell value should fit. It is placed in 1 row of excel file.defaultValues- default value of cell. It is placed in 2 row of excel file.values- value of cell- Returns:
- parsed values
-
parseDefaultValues
Parses referencePattern cell (which is located in the second row) and default values cell (which is located in the third row) and creates map where key equals to reference key and value equals to value provided in the third row.
For example, for the following reference cell's value: "RANGE["value1";"value2"]" and default value cell: "RANGE["default1";"default2"]" the following map will be returned: {{key: "from$"value1, value: default1}, {key: "to$"value2, value: default2}}- Specified by:
parseDefaultValuesin interfaceImportParameterParser- Parameters:
referenceFormat- cell's value from second row of excel sheet. Should matches theRangeParserUtils.RANGE_PATTERNpattern.defaultValues- cell's value from third row of excel sheet. Should matches theRangeParserUtils.RANGE_PATTERNpattern.- Returns:
- DefaultValues object.
-
mergeDefaultValues
-
parseValue
Parses referencePattern cell (which is located in the second row) and cell with data (which is located in the data row) and creates map where key equals to reference key and value equals to value provided in the data row. If value is null then default value is taken into account. For example, for the following reference cell's value: "RANGE["value1";"value2"]" and cell's value: "RANGE["default1";"default2"]" the following map will be returned: {{key: "from$"value1, value: default1}, {key: "to$"value2, value: default2}}. Parameters map always contains keys: "from$""rawValue" which represents not parsed value, but merged with default values for the beginning of the range and "to$""rawValue" for the ending of the range.- Specified by:
parseValuein interfaceImportParameterParser- Parameters:
cellValue- value of cell's datadefaultValues- parsed default values- Returns:
- ParsedValues object. If default values are not provided then only keys will be returned.
-
getLeftParsedValues
-
getRightParsedValues
-
setParserRegistry
-
getOrder
public int getOrder()- Specified by:
getOrderin interfaceorg.springframework.core.Ordered
-
setOrder
public void setOrder(int order)
-