Class AbstractClassPathModelFinder
java.lang.Object
opennlp.tools.models.AbstractClassPathModelFinder
- All Implemented Interfaces:
ClassPathModelFinder
- Direct Known Subclasses:
ClassgraphModelFinder, DirectoryModelFinder, SimpleClassPathModelFinder
@ThreadSafe
public abstract class AbstractClassPathModelFinder
extends Object
implements ClassPathModelFinder
A base implementation of a
ClassPathModelFinder for the detection of
OpenNLP models in the classpath. By default, AbstractClassPathModelFinder will scan for
JAR files starting with "opennlp-models-*".
This search mask can be adjusted by using the one argument
constructor.
Wildcard search is supported by using asterisk symbol.
findModels(boolean) may be called from several threads. Concurrent first calls scan
the classpath once, and every caller receives the complete, unmodifiable set of models.
Subclasses must keep getContext() and getMatchingURIs(String, Object) free
of shared mutable state.
- See Also:
-
Field Summary
Fields inherited from interface ClassPathModelFinder
OPENNLP_MODEL_JAR_PREFIX -
Constructor Summary
ConstructorsConstructorDescriptionBy default, it scans forClassPathModelFinder.OPENNLP_MODEL_JAR_PREFIX.AbstractClassPathModelFinder(String jarModelPrefix) -
Method Summary
Modifier and TypeMethodDescriptionfindModels(boolean reloadCache) Finds OpenNLP models available within an applications's classpath.
-
Constructor Details
-
AbstractClassPathModelFinder
public AbstractClassPathModelFinder()By default, it scans forClassPathModelFinder.OPENNLP_MODEL_JAR_PREFIX. -
AbstractClassPathModelFinder
- Parameters:
jarModelPrefix- The leafnames of the jars that should be canned (e.g. "opennlp.jar"). May contain a wildcard glob ("opennlp-*.jar"). It must not benull.
-
-
Method Details
-
findModels
Finds OpenNLP models available within an applications's classpath.The result is cached; concurrent first calls scan the classpath once. The returned set is unmodifiable and does not change when the cache is reloaded.
- Specified by:
findModelsin interfaceClassPathModelFinder- Parameters:
reloadCache-true, if the internal cache should explicitly be reloaded,falseotherwise.- Returns:
- A
Setofmodel entries. It might be empty, if none were found.
-