Package opennlp.tools.models.classgraph
Class ClassgraphModelFinder
java.lang.Object
opennlp.tools.models.AbstractClassPathModelFinder
opennlp.tools.models.classgraph.ClassgraphModelFinder
- All Implemented Interfaces:
ClassPathModelFinder
public class ClassgraphModelFinder
extends AbstractClassPathModelFinder
implements ClassPathModelFinder
Enables the detection of OpenNLP models in the classpath via
Classgraph.
By default, this implementation will search 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. Masks follow the wildcard rules of ClassGraph, not the rules of
AbstractClassPathModelFinder.matchesWildcard(java.net.URL, String).
- See Also:
-
Field Summary
Fields inherited from class opennlp.tools.models.AbstractClassPathModelFinder
JARFields inherited from interface opennlp.tools.models.ClassPathModelFinder
OPENNLP_MODEL_JAR_PREFIX -
Constructor Summary
ConstructorsConstructorDescriptionBy default, it scans for "opennlp-models-*.jar".ClassgraphModelFinder(String modelJarPrefix) -
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectgetMatchingURIs(String wildcardPattern, Object context) Methods inherited from class opennlp.tools.models.AbstractClassPathModelFinder
findModels, getJarModelPrefix, getMatchingJarEntryURIs, getURIsFromJar, isWindows, jarPathsMatch, matchesWildcard, parseJarURI, toURLMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface opennlp.tools.models.ClassPathModelFinder
findModels
-
Constructor Details
-
ClassgraphModelFinder
public ClassgraphModelFinder()By default, it scans for "opennlp-models-*.jar". -
ClassgraphModelFinder
- Parameters:
modelJarPrefix- The leafnames of the jars that should be scanned (e.g. "opennlp.jar"). May contain a wildcard glob ("opennlp-*.jar"). It must not benull.- Throws:
IllegalArgumentException- Thrown ifmodelJarPrefixisnull.
-
-
Method Details
-
getContext
- Specified by:
getContextin classAbstractClassPathModelFinder- Returns:
- A
ScanResultready for consumption.
-
getMatchingURIs
- Specified by:
getMatchingURIsin classAbstractClassPathModelFinder- Parameters:
wildcardPattern- The pattern to use for scanning. Must not benull.context- An object holding context information. It might benull.- Returns:
- A list of matching classpath
URIswhich may be empty if nothing is found.
-