Interface Dictionary


public interface Dictionary
Provides functionality for working with a spell check dictionary.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    add(String word)
    Adds the given word to the dictionary and schedules a write to disk.
    add(Set<String> words)
    Adds the given words to the dictionary and schedules a write to disk.
    boolean
    has(String word)
    Returns true if the dictionary contains the given word.
    boolean
    remove(String word)
    Removes the given word from the dictionary and schedules a write to disk.
    remove(Set<String> words)
    Removes the given words from the dictionary and schedules a write to disk.
    Returns the words in the current dictionary or an empty collection if the dictionary does not have any word.
  • Method Details

    • words

      Collection<String> words()
      Returns the words in the current dictionary or an empty collection if the dictionary does not have any word.
      Throws:
      ObjectClosedException - when the engine is closed
    • add

      boolean add(String word)
      Adds the given word to the dictionary and schedules a write to disk.
      Parameters:
      word - a word to add to the dictionary. It must be UTF8, between 1 and 99 bytes long, and without leading or trailing ASCII whitespace
      Returns:
      true if the given word is valid and not a duplicate
      Throws:
      IllegalArgumentException - when word is empty or blank
      ObjectClosedException - when the engine is closed
    • add

      Adds the given words to the dictionary and schedules a write to disk.
      Parameters:
      words - a set of words to add to the dictionary. Each word must be UTF8, between 1 and 99 bytes long, and without leading or trailing ASCII whitespace
      Returns:
      a list of sanitation errors if words contains duplicates or invalid words, or an empty list if all words were added successfully
      Throws:
      IllegalArgumentException - when words is empty
      ObjectClosedException - when the engine is closed
      Since:
      8.14.0
    • remove

      boolean remove(String word)
      Removes the given word from the dictionary and schedules a write to disk.
      Parameters:
      word - a word to remove from the dictionary. It must be UTF8, between 1 and 99 bytes long, and without leading or trailing ASCII whitespace
      Returns:
      true if the given word was found and removed successfully
      Throws:
      IllegalArgumentException - when word is empty or blank
      ObjectClosedException - when the engine is closed
    • remove

      List<SanitationError> remove(Set<String> words)
      Removes the given words from the dictionary and schedules a write to disk.
      Parameters:
      words - a set of words to remove from the dictionary. Each word must be UTF8, between 1 and 99 bytes long, and without leading or trailing ASCII whitespace
      Returns:
      a list of sanitation errors if words contains words that do not exist in the dictionary, or an empty list if all words were removed successfully
      Throws:
      IllegalArgumentException - when words is empty
      ObjectClosedException - when the engine is closed
      Since:
      8.14.0
    • has

      boolean has(String word)
      Returns true if the dictionary contains the given word.
      Parameters:
      word - a word to check. It must be UTF8, between 1 and 99 bytes long, and without leading or trailing ASCII whitespace
      Throws:
      IllegalArgumentException - when word is empty or blank
      ObjectClosedException - when the engine is closed