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 Object
A class that encapsulates the storage and retrieval of string-keyed data. Usage:
  1. Instantiate and insert data with add(String, Object)
  2. Call done() when done adding data (required!)
  3. Retrieve data with lookUp(String)
  • Constructor Details

    • DictionaryData

      public DictionaryData(Language language)
      Parameters:
      language - The dictionary's index language
  • Method Details

    • add

      public void add(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 key
      value - The value
    • done

      public void done()
      Finalize the data store. This is required to be called before any lookups can be performed.
    • lookUp

      public List<Map.Entry<String,T>> lookUp(String word) throws IllegalStateException
      Look up the given word.
      Parameters:
      word - The word to look up
      Returns:
      A list of stored objects matching the given word
      Throws:
      IllegalStateException - If done() has not yet been called
    • lookUpPredictive

      public List<Map.Entry<String,T>> lookUpPredictive(String word) throws 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:
      IllegalStateException - If done() has not yet been called
    • size

      public int size()
      Get the number of stored keys. Returns -1 if done() has not yet been called.
      Returns:
      The number of stored keys