![]()
|
Jakarta-ORO 2.0.6 API: Class GenericPatternCache
org.apache.oro.text
|
Field Summary | |
static int |
DEFAULT_CAPACITY
The default capacity to be used by the GenericPatternCache subclasses provided with this package. |
Method Summary | |
Pattern |
addPattern(java.lang.String expression)
Same as calling |
Pattern |
addPattern(java.lang.String expression,
int options)
Adds a pattern to the cache and returns the compiled pattern. |
int |
capacity()
Returns the maximum number of patterns that can be cached at one time. |
Pattern |
getPattern(java.lang.String expression)
Same as calling |
Pattern |
getPattern(java.lang.String expression,
int options)
This method fetches a pattern from the cache. |
int |
size()
Returns the number of elements in the cache, not to be confused with the capacity() which returns the number
of elements that can be held in the cache at one time. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int DEFAULT_CAPACITY
Method Detail |
public final Pattern addPattern(java.lang.String expression, int options) throws MalformedPatternException
getPattern()
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
in interface PatternCache
expression
- The regular expression to add to the cache.options
- The compilation options to use when compiling the
expression.MalformedPatternException
- If there is an error in compiling
the regular expression.public final Pattern addPattern(java.lang.String expression) throws MalformedPatternException
addPattern(expression, 0);
addPattern
in interface PatternCache
MalformedPatternException
- If there is an error in compiling
the regular expression.public final Pattern getPattern(java.lang.String expression, int options) throws MalformedCachePatternException
addPattern()
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 to
MalformedCachePatternException
for a discussion of
when you should and shouldn't catch this exception.
getPattern
in interface PatternCache
expression
- The regular expression to fetch from the cache in
compiled form.options
- The compilation options to use when compiling the
expression.MalformedCachePatternException
- If there is an error in
compiling the regular expression.public final Pattern getPattern(java.lang.String expression) throws MalformedCachePatternException
getPattern(expression, 0)
getPattern
in interface PatternCache
org.apache.oro.text.PatternCache
expression
- The regular expression to fetch from the cache in
compiled form.MalformedCachePatternException
- If there is an error in
compiling the regular expression.public final int size()
capacity()
which returns the number
of elements that can be held in the cache at one time.
size
in interface PatternCache
public final int capacity()
capacity
in interface PatternCache
|
![]() |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |