Class 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:
    1. Instantiate and insert data with add(String, Object)
    2. Call done() when done adding data (required!)
    3. Retrieve data with lookUp(String)
    • 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.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 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 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 - If done() 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 - 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