Package org.omegat.core.dictionaries
Class DictionaryData<T>
- java.lang.Object
-
- org.omegat.core.dictionaries.DictionaryData<T>
-
- Type Parameters:
T
- The type of data stored
public class DictionaryData<T> extends java.lang.Object
A class that encapsulates the storage and retrieval of string-keyed data. Usage:- Instantiate and insert data with
add(String, Object)
- Call
done()
when done adding data (required!) - Retrieve data with
lookUp(String)
-
-
Constructor Summary
Constructors Constructor Description DictionaryData(Language language)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(java.lang.String key, T value)
Insert a key=value pair into the data store.void
done()
Finalize the data store.java.util.List<java.util.Map.Entry<java.lang.String,T>>
lookUp(java.lang.String word)
Look up the given word.java.util.List<java.util.Map.Entry<java.lang.String,T>>
lookUpPredictive(java.lang.String word)
Look up the given word using predictive completion; e.g.int
size()
Get the number of stored keys.
-
-
-
Constructor Detail
-
DictionaryData
public DictionaryData(Language language)
- Parameters:
language
- The dictionary's index language
-
-
Method Detail
-
add
public void add(java.lang.String key, T value)
Insert a key=value pair into the data store. Unicode normalization is performed on the key. The value is stored both for the key and its lowercase version, if the latter differs.- Parameters:
key
- The keyvalue
- The value
-
done
public void done()
Finalize the data store. This is required to be called before any lookups can be performed.
-
lookUp
public java.util.List<java.util.Map.Entry<java.lang.String,T>> lookUp(java.lang.String word) throws java.lang.IllegalStateException
Look up the given word.- Parameters:
word
- The word to look up- Returns:
- A list of stored objects matching the given word
- Throws:
java.lang.IllegalStateException
- Ifdone()
has not yet been called
-
lookUpPredictive
public java.util.List<java.util.Map.Entry<java.lang.String,T>> lookUpPredictive(java.lang.String word) throws java.lang.IllegalStateException
Look up the given word using predictive completion; e.g. "term" will match "terminology" (and "terminal", etc.).- Parameters:
word
- The word to look up- Returns:
- A list of stored objects matching the given word
- Throws:
java.lang.IllegalStateException
- Ifdone()
has not yet been called
-
size
public int size()
Get the number of stored keys. Returns-1
ifdone()
has not yet been called.- Returns:
- The number of stored keys
-
-