Class RegExCache

All Implemented Interfaces:
ICache<RegExPattern,Pattern>, IMutableCache<RegExPattern,Pattern>, IHasSize, IHasName

@ThreadSafe @Singleton public final class RegExCache extends Cache<RegExPattern,Pattern>
This class provides a cached for compiled regular expressions. It caches up to a limited number of compiled Pattern objects.
Author:
Philip Helger
  • Field Details

    • MAX_CACHE_SIZE

      public static final int MAX_CACHE_SIZE
      The default number of items to keep in the cache
      See Also:
  • Method Details

    • isInstantiated

      public static boolean isInstantiated()
    • getInstance

      @Nonnull public static RegExCache getInstance()
    • getPattern

      @Nonnull public static Pattern getPattern(@Nonnull @Nonempty @RegEx String sRegEx)
      Get the cached regular expression pattern.
      Parameters:
      sRegEx - The regular expression to retrieve. May neither be null nor empty.
      Returns:
      The compiled regular expression pattern and never null .
      Throws:
      IllegalArgumentException - If the passed regular expression has an illegal syntax
    • getPattern

      @Nonnull public static Pattern getPattern(@Nonnull @Nonempty @RegEx String sRegEx, @Nonnegative int nOptions)
      Get the cached regular expression pattern.
      Parameters:
      sRegEx - The regular expression to retrieve. May neither be null nor empty.
      nOptions - The options used for Pattern.compile
      Returns:
      The compiled regular expression pattern and never null .
      Throws:
      IllegalArgumentException - If the passed regular expression has an illegal syntax
      See Also: