Class StreamFactoryRegistry
java.lang.Object
opennlp.tools.cmdline.StreamFactoryRegistry
Registry for
object stream factories.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T,P> Map <String, ObjectStreamFactory<T, P>> getFactories(Class<T> sampleClass) Returns all factories which produce objects ofsampleClassclass.static <T,P> ObjectStreamFactory <T, P> getFactory(Class<T> sampleClass, String formatName) Returns a factory which reads format namedformatNameand instantiates streams producing objects ofsampleClassclass.static <T,P> boolean registerFactory(Class<T> sampleClass, String formatName, ObjectStreamFactory<T, P> factory) Registersfactorywhich reads format namedformatNameand instantiates streams producing objects ofsampleClassclass.static <T> voidunregisterFactory(Class<T> sampleClass, String formatName) Unregisters a factory which reads format namedformatNameand instantiates streams producing objects ofsampleClassclass.
-
Field Details
-
registry
-
DEFAULT_FORMAT
- See Also:
-
-
Constructor Details
-
StreamFactoryRegistry
private StreamFactoryRegistry()
-
-
Method Details
-
registerFactory
public static <T,P> boolean registerFactory(Class<T> sampleClass, String formatName, ObjectStreamFactory<T, P> factory) Registersfactorywhich reads format namedformatNameand instantiates streams producing objects ofsampleClassclass.- Parameters:
sampleClass- class of the objects, produced by the streams instantiated by the factoryformatName- name of the formatfactory- instance of the factory- Returns:
- true if the factory was successfully registered
-
unregisterFactory
Unregisters a factory which reads format namedformatNameand instantiates streams producing objects ofsampleClassclass.- Parameters:
sampleClass- class of the objects, produced by the streams instantiated by the factoryformatName- name of the format
-
getFactories
Returns all factories which produce objects ofsampleClassclass.- Parameters:
sampleClass- class of the objects, produced by the streams instantiated by the factory- Returns:
- formats mapped to factories
-
getFactory
Returns a factory which reads format namedformatNameand instantiates streams producing objects ofsampleClassclass.If no factory is registered for
formatName, an attempt is made to interpretformatNameas the fully qualified class name of anObjectStreamFactoryimplementation and load it via theExtensionLoader. Such a class must reside in an allowed package, seeExtensionLoader.registerAllowedPackage(String).- Parameters:
sampleClass- class of the objects, produced by the streams instantiated by the factoryformatName- name of the format, if null, assumes OpenNLP format- Returns:
- factory instance, or
nullif no factory could be found or loaded
-