类 GenericPatternCache
java.lang.Object
org.apache.oro.text.GenericPatternCache
- 所有已实现的接口:
PatternCache
This is the base class for all cache implementations provided in the
org.apache.oro.text package.
Although 4 subclasses of GenericPatternCache are provided with this
package, users may not derive subclasses from this class.
Rather, users should create their own implmentations of the
PatternCache interface.- 从以下版本开始:
- 1.0
- 版本:
- @version@
- 另请参阅:
-
字段概要
字段修饰符和类型字段说明static final intThe default capacity to be used by the GenericPatternCache subclasses provided with this package. -
方法概要
修饰符和类型方法说明final PatternaddPattern(String expression) Same as callingfinal PatternaddPattern(String expression, int options) Adds a pattern to the cache and returns the compiled pattern.final intcapacity()Returns the maximum number of patterns that can be cached at one time.final PatterngetPattern(String expression) Same as callingfinal PatterngetPattern(String expression, int options) This method fetches a pattern from the cache.final intsize()Returns the number of elements in the cache, not to be confused with thecapacity()which returns the number of elements that can be held in the cache at one time.
-
字段详细资料
-
DEFAULT_CAPACITY
public static final int DEFAULT_CAPACITYThe default capacity to be used by the GenericPatternCache subclasses provided with this package. Its value is 20.- 另请参阅:
-
-
方法详细资料
-
addPattern
Adds a pattern to the cache and returns the compiled pattern. This method is in principle almost identical togetPattern()except for the fact that it throws a MalformedPatternException if an expression cannot be compiled.addPattern() is meant to be used when you expressly intend to add an expression to the cache and is useful for front-loading a cache with expressions before use. If the expression added does not already exist in the cache, it is compiled, added to the cache, and returned. If the compiled expression is already in the cache, it is simply returned.
The expected behavior of this method should be to start replacing patterns in the cache only after the cache has been filled to capacity.
- 指定者:
addPattern在接口中PatternCache- 参数:
expression- The regular expression to add to the cache.options- The compilation options to use when compiling the expression.- 返回:
- The Pattern corresponding to the String representation of the regular expression.
- 抛出:
MalformedPatternException- If there is an error in compiling the regular expression.
-
addPattern
Same as callingaddPattern(expression, 0);
- 指定者:
addPattern在接口中PatternCache- 参数:
expression- The regular expression to add to the cache.- 返回:
- The Pattern corresponding to the String representation of the regular expression.
- 抛出:
MalformedPatternException- If there is an error in compiling the regular expression.
-
getPattern
public final Pattern getPattern(String expression, int options) throws MalformedCachePatternException This method fetches a pattern from the cache. It is nearly identical toaddPattern()except that it doesn't throw a MalformedPatternException. If the pattern is not in the cache, it is compiled, placed in the cache, and returned. If the pattern cannot be compiled successfully, it throws a MalformedCachePatternException. Note that this exception is derived from RuntimeException, which means you are NOT forced to catch it by the compiler. Please refer toMalformedCachePatternExceptionfor a discussion of when you should and shouldn't catch this exception.- 指定者:
getPattern在接口中PatternCache- 参数:
expression- The regular expression to fetch from the cache in compiled form.options- The compilation options to use when compiling the expression.- 返回:
- The Pattern corresponding to the String representation of the regular expression.
- 抛出:
MalformedCachePatternException- If there is an error in compiling the regular expression.
-
getPattern
Same as callinggetPattern(expression, 0)
- 指定者:
getPattern在接口中PatternCache- 参数:
expression- The regular expression to fetch from the cache in compiled form.- 返回:
- The Pattern corresponding to the String representation of the regular expression.
- 抛出:
MalformedCachePatternException- If there is an error in compiling the regular expression.
-
size
public final int size()Returns the number of elements in the cache, not to be confused with thecapacity()which returns the number of elements that can be held in the cache at one time.- 指定者:
size在接口中PatternCache- 返回:
- The current size of the cache (i.e., the number of elements currently cached).
-
capacity
public final int capacity()Returns the maximum number of patterns that can be cached at one time.- 指定者:
capacity在接口中PatternCache- 返回:
- The maximum number of patterns that can be cached at one time.
-