Package com.helger.commons.regex
Class RegExCache
- All Implemented Interfaces:
ICache<RegExPattern,,Pattern> IMutableCache<RegExPattern,,Pattern> IHasSize,IHasName
This class provides a cached for compiled regular expressions. It caches up
to a limited number of compiled
Pattern objects.- Author:
- Philip Helger
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe default number of items to keep in the cacheFields inherited from class com.helger.commons.cache.Cache
DEFAULT_ALLOW_NULL_VALUESFields inherited from class com.helger.commons.cache.MappedCache
m_aRWLock, NO_MAX_SIZE, STATISTICS_PREFIX -
Method Summary
Modifier and TypeMethodDescriptionstatic RegExCachestatic PatterngetPattern(String sRegEx) Get the cached regular expression pattern.static PatterngetPattern(String sRegEx, int nOptions) Get the cached regular expression pattern.static booleanMethods inherited from class com.helger.commons.cache.MappedCache
clearCache, createCache, getCacheKeyProvider, getFromCache, getFromCacheNoStats, getFromCacheNoStatsNotLocked, getMaxSize, getName, getValueProvider, hasMaxSize, isAllowNullValues, isEmpty, isInCache, isNotEmpty, putInCache, putInCacheNotLocked, removeFromCache, size, toString
-
Field Details
-
MAX_CACHE_SIZE
public static final int MAX_CACHE_SIZEThe default number of items to keep in the cache- See Also:
-
-
Method Details
-
isInstantiated
public static boolean isInstantiated() -
getInstance
-
getPattern
Get the cached regular expression pattern.- Parameters:
sRegEx- The regular expression to retrieve. May neither benullnor 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 benullnor 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:
-