Class RangeParserUtils

java.lang.Object
com.hybris.backoffice.excel.importing.parser.RangeParserUtils

public class RangeParserUtils extends Object
  • Field Details

  • Method Details

    • parseRangePattern

      public static org.apache.commons.lang3.tuple.Pair<String,String> parseRangePattern(@Nonnull 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<String,String> splitByRangeSeparator(@Nonnull 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 String prependFromPrefix(@Nonnull 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 String prependToPrefix(@Nonnull 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 String deleteFromPrefix(@Nonnull String input)
      Deletes "from$" from given input
      Parameters:
      input - to modify
      Returns:
      value without "from$"
    • deleteToPrefix

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

      public static String deletePrefix(String input, String prefix)
      Deletes given prefix from given input
      Parameters:
      input - to modify
      prefix - to remove
      Returns:
      value without given prefix
    • deletePrefixFromImportParameters

      public static ImportParameters deletePrefixFromImportParameters(ImportParameters importParameters, RangeParserUtils.RangeBounds rangeBounds)
      Deletes "from$" or "to$" from ImportParameters.
      Parameters:
      importParameters - to modify
      rangeBounds - allows to decide which prefix should be handled
      Returns:
      value without given prefix
    • getSingleImportParameters

      public static ImportParameters getSingleImportParameters(ExcelClassificationAttribute excelClassificationAttribute, ImportParameters importParameters, Map<String,String> params, RangeParserUtils.RangeBounds rangeBounds)
      Every range contains of FROM and TO values. This method allows to retrieve ImportParameters from one of given bounds.
      Parameters:
      excelClassificationAttribute - it is necessary, because this method must check whether the type is complex or simple. If it's simple then ImportParameters.cellValue will be completed with "rawValue".
      importParameters - to work on
      params - to be put in ImportParameters.parameters
      rangeBounds - allows to decide whether retrieve FROM or TO bound
      Returns:
      importParameters of given bound
    • appendPrefixToParsedValues

      public static ParsedValues appendPrefixToParsedValues(ParsedValues parsedValues, RangeParserUtils.RangeBounds range)
      Appends "from$" or "to$" to ParsedValues.
      Parameters:
      parsedValues - to modify
      range - allows to decide which prefix should be handled
      Returns:
      value with given prefix
    • deletePrefixFromParsedValues

      public static ParsedValues deletePrefixFromParsedValues(ParsedValues parsedValues, RangeParserUtils.RangeBounds range)
      Deletes "from$" or "to$" from ParsedValues.
      Parameters:
      parsedValues - to modify
      range - allows to decide which prefix should be handled
      Returns:
      value without given prefix
    • appendPrefixToDefaultValues

      public static DefaultValues appendPrefixToDefaultValues(DefaultValues defaultValues, RangeParserUtils.RangeBounds range)
      Appends "from$" or "to$" to DefaultValues.
      Parameters:
      defaultValues - to modify
      range - allows to decide which prefix should be handled
      Returns:
      value with given prefix
    • deletePrefixFromDefaultValues

      public static DefaultValues deletePrefixFromDefaultValues(DefaultValues defaultValues, RangeParserUtils.RangeBounds range)
      Deletes "from$" or "to$" from DefaultValues.
      Parameters:
      defaultValues - to modify
      range - allows to decide which prefix should be handled
      Returns:
      value without given prefix
    • convert

      public static String convert(String input, UnaryOperator<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