java.lang.Object
com.hybris.backoffice.excel.importing.parser.RangeParser
All Implemented Interfaces:
ImportParameterParser, org.springframework.core.Ordered

public class RangeParser extends Object implements ImportParameterParser
Implementation of ImportParameterParser which allows to parse default values for classification' ranges
  • Constructor Details

    • RangeParser

      public RangeParser()
  • Method Details

    • matches

      public boolean matches(@Nonnull String referenceFormat)
      Checks whether given input matches to RangeParserUtils.RANGE_PATTERN.
      Specified by:
      matches in interface ImportParameterParser
      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:
      parseValue in interface ImportParameterParser
      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

      public DefaultValues 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.
      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:
      parseDefaultValues in interface ImportParameterParser
      Parameters:
      referenceFormat - cell's value from second row of excel sheet. Should matches the RangeParserUtils.RANGE_PATTERN pattern.
      defaultValues - cell's value from third row of excel sheet. Should matches the RangeParserUtils.RANGE_PATTERN pattern.
      Returns:
      DefaultValues object.
    • mergeDefaultValues

      protected DefaultValues mergeDefaultValues(DefaultValues from, DefaultValues to)
    • parseValue

      public ParsedValues 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. 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:
      parseValue in interface ImportParameterParser
      Parameters:
      cellValue - value of cell's data
      defaultValues - parsed default values
      Returns:
      ParsedValues object. If default values are not provided then only keys will be returned.
    • getLeftParsedValues

      protected ParsedValues getLeftParsedValues(String cellValue, DefaultValues defaultValues)
    • getRightParsedValues

      protected ParsedValues getRightParsedValues(String cellValue, DefaultValues defaultValues)
    • setParserRegistry

      public void setParserRegistry(ParserRegistry parserRegistry)
    • getOrder

      public int getOrder()
      Specified by:
      getOrder in interface org.springframework.core.Ordered
    • setOrder

      public void setOrder(int order)