Class RangeParserUtils


  • public class RangeParserUtils
    extends java.lang.Object
    • Field Detail

      • RANGE_FROM_PREFIX

        public static final java.lang.String RANGE_FROM_PREFIX
        See Also:
        Constant Field Values
      • COMPLEX_TYPE_RANGE_FORMAT

        public static final java.lang.String COMPLEX_TYPE_RANGE_FORMAT
        See Also:
        Constant Field Values
      • SIMPLE_TYPE_RANGE_FORMAT

        public static final java.lang.String SIMPLE_TYPE_RANGE_FORMAT
        See Also:
        Constant Field Values
      • RANGE_PATTERN

        public static final java.util.regex.Pattern RANGE_PATTERN
        e.g. RANGE[from;to]
    • Method Detail

      • parseRangePattern

        public static org.apache.commons.lang3.tuple.Pair<java.lang.String,​java.lang.String> parseRangePattern​(@Nonnull
                                                                                                                     java.lang.String input)
                                                                                                              throws ExcelParserException
        Parses input to pair of values - beginning of the range and end of the range. The input should be in format "RANGE["from";"to"]".
        .e.g input "RANGE["from";"to"]" returns Pair which contains "from" and "to".
        Parameters:
        input - range raw value
        Returns:
        pair which contains beginning and ending of the range. The Pair.getLeft() returns "from" of the range and Pair.getRight() returns "to" of the range.
        Throws:
        ExcelParserException - when input doesn't match to RANGE_PATTERN
      • splitByRangeSeparator

        public static org.apache.commons.lang3.tuple.Pair<java.lang.String,​java.lang.String> splitByRangeSeparator​(@Nonnull
                                                                                                                         java.lang.String input)
                                                                                                                  throws ExcelParserException
        Splits given input by ";".
        e.g. from";" returns Pair which contains "from" and "to".
        Parameters:
        input - value to split
        Returns:
        pair which contains beginning and ending of the range. The Pair.getLeft() returns "from" of the range and Pair.getRight() returns "to" of the range.
        Throws:
        ExcelParserException
      • prependFromPrefix

        public static java.lang.String prependFromPrefix​(@Nonnull
                                                         java.lang.String input)
        Prepends "from$" to given input.
        e.g. "input" -> ""from$"input"
        Parameters:
        input - value which will be prepended to "from$"
        Returns:
        input with "from$"
      • prependToPrefix

        public static java.lang.String prependToPrefix​(@Nonnull
                                                       java.lang.String input)
        Prepends "to$" to given input.
        e.g. "input" -> ""to$"input"
        Parameters:
        input - value which will be prepended to "from$"
        Returns:
        input with "from$"
      • deleteFromPrefix

        public static java.lang.String deleteFromPrefix​(@Nonnull
                                                        java.lang.String input)
        Deletes "from$" from given input
        Parameters:
        input - to modify
        Returns:
        value without "from$"
      • deleteToPrefix

        public static java.lang.String deleteToPrefix​(@Nonnull
                                                      java.lang.String input)
        Deletes "to$" from given input
        Parameters:
        input - to modify
        Returns:
        value without "to$"
      • deletePrefix

        public static java.lang.String deletePrefix​(java.lang.String input,
                                                    java.lang.String prefix)
        Deletes given prefix from given input
        Parameters:
        input - to modify
        prefix - to remove
        Returns:
        value without given prefix
      • convert

        public static java.lang.String convert​(java.lang.String input,
                                               java.util.function.UnaryOperator<java.lang.String> converter)
        Allows to convert given input with given converter. If input contains SelectedAttribute.REFERENCE_PATTERN_SEPARATOR then it is split using this separator and all of the subelements are converted and then merged.
        E.g. input "a:b:c" and converter which appends "from$" then ""to$"a:"to$"b:"to$"c" will be returned
        Parameters:
        input - to modify
        converter - to use for conversion
        Returns:
        converted input