@API(value=EXPERIMENTAL) public class TextTokenizerRegistryImpl extends Object implements TextTokenizerRegistry
TextTokenizerRegistry
. It uses the class
loader to determine which TextTokenizerFactory
implementation exist,
and it populates the registry with those tokenizers. An instance of this registry
is used by the TextIndexMaintainer
in order to choose the tokenizer for a block of text. One can therefore register
additional tokenizers for that index by calling the register
method on the singleton instance of this class and supplying the additional tokenizer.Modifier and Type | Method and Description |
---|---|
Map<String,TextTokenizerFactory> |
getRegistry()
Returns all registered tokenizers.
|
TextTokenizer |
getTokenizer(String name)
Gets the tokenizer of the given name.
|
static TextTokenizerRegistry |
instance() |
void |
register(TextTokenizerFactory tokenizerFactory)
Registers a new tokenizer in this registry.
|
void |
reset()
Clears the registry and reloads tokenizers from the classpath.
|
@Nonnull public static TextTokenizerRegistry instance()
@Nonnull public Map<String,TextTokenizerFactory> getRegistry()
TextTokenizerRegistry
getRegistry
in interface TextTokenizerRegistry
TextTokenizerFactory
@Nonnull public TextTokenizer getTokenizer(@Nullable String name)
TextTokenizerRegistry
name
is null
,
it returns an instance of the DefaultTextTokenizer
.getTokenizer
in interface TextTokenizerRegistry
name
- the name of the tokenizer to retrievepublic void register(@Nonnull TextTokenizerFactory tokenizerFactory)
TextTokenizerRegistry
tokenizerFactory
parameter given.register
in interface TextTokenizerRegistry
tokenizerFactory
- new tokenizer to registerpublic void reset()
TextTokenizerRegistry
reset
in interface TextTokenizerRegistry