Class RangeParser

    • Constructor Detail

      • RangeParser

        public RangeParser()
    • Method Detail

      • matches

        public boolean matches​(@Nonnull
                               java.lang.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
                                       java.lang.String referenceFormat,
                                       java.lang.String defaultValues,
                                       java.lang.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​(java.lang.String referenceFormat,
                                                java.lang.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.
      • parseValue

        public ParsedValues parseValue​(java.lang.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​(java.lang.String cellValue,
                                                   DefaultValues defaultValues)
      • getRightParsedValues

        protected ParsedValues getRightParsedValues​(java.lang.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)