Package io.mats3.util

Class SanitizeMqNames

java.lang.Object
io.mats3.util.SanitizeMqNames

public class SanitizeMqNames extends Object
Utility class for replacing dodgy characters from queue/topic names, and names in general, in the Message Broker world - it is quite restrictive, replacing any character not in [a-z,A-Z,0-9,.,_,-] (lower alpha, upper alpha, digits, dot, underscore, minus/dash) with '_'.

The code is literally:
    Pattern.compile("[^a-zA-Z0-9._\\-]").matcher(input).replaceAll("_")
.. but the compiled pattern is statically cached.

Its functionality may very well be copied to where its logic is needed if not desired to depend on 'mats-util'.

  • Field Details

    • MQ_NAME_REPLACE_PATTERN

      public static final Pattern MQ_NAME_REPLACE_PATTERN
  • Constructor Details

    • SanitizeMqNames

      public SanitizeMqNames()
  • Method Details

    • sanitizeName

      public static String sanitizeName(String input)
      Sanitizes the input, only allowing [a-z,A-Z,0-9,.,-,_] (last being dot, minus, underscore)
      Parameters:
      input - the name to sanitize
      Returns:
      the name after being run through the code 'Pattern.compile("[^a-zA-Z0-9._\\-]").matcher(input).replaceAll("_")'.