Package io.mats3.util

Class 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:
.. 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


      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)
      input - the name to sanitize
      the name after being run through the code 'Pattern.compile("[^a-zA-Z0-9._\\-]").matcher(input).replaceAll("_")'.