Class PatternUtils


  • public final class PatternUtils
    extends java.lang.Object
    A class that caches compiled patterns.
    Since:
    18475
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static org.apache.commons.jcs3.access.CacheAccess<java.lang.String,​java.util.regex.Pattern> cache
      A cache for Java Patterns (no flags)
      private static java.lang.String MAGIC_STRING
      A string that is highly unlikely to appear in regexes to split a regex from its flags
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private PatternUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.regex.Pattern compile​(java.lang.String regex)
      Compile a regex into a pattern.
      static java.util.regex.Pattern compile​(java.lang.String regex, int flags)
      Compile a regex into a pattern.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • MAGIC_STRING

        private static final java.lang.String MAGIC_STRING
        A string that is highly unlikely to appear in regexes to split a regex from its flags
        See Also:
        Constant Field Values
      • cache

        private static final org.apache.commons.jcs3.access.CacheAccess<java.lang.String,​java.util.regex.Pattern> cache
        A cache for Java Patterns (no flags)
    • Method Detail

      • compile

        public static java.util.regex.Pattern compile​(java.lang.String regex)
        Compile a regex into a pattern. This may return a Pattern used elsewhere. This is safe.
        Parameters:
        regex - The regex to compile
        Returns:
        The immutable Pattern.
        See Also:
        Pattern.compile(String)
      • compile

        public static java.util.regex.Pattern compile​(java.lang.String regex,
                                                      int flags)
        Compile a regex into a pattern. This may return a Pattern used elsewhere. This is safe.
        Parameters:
        regex - The regex to compile
        flags - The flags from Pattern to apply
        Returns:
        The immutable Pattern.
        See Also:
        Pattern.compile(String, int)