Class StemmerOverrideFile.StemmerOverrideUpdater

java.lang.Object
org.codelibs.fess.dict.stemmeroverride.StemmerOverrideFile.StemmerOverrideUpdater
All Implemented Interfaces:
Closeable, AutoCloseable
Enclosing class:
StemmerOverrideFile

protected class StemmerOverrideFile.StemmerOverrideUpdater extends Object implements Closeable
An inner class for updating the stemmer override file. This class handles the process of writing changes to a temporary file and then replacing the original file upon successful commit.
  • Field Details

    • isCommit

      protected boolean isCommit
      A flag indicating whether the changes have been committed.
    • newFile

      protected File newFile
      The temporary file to write changes to.
    • writer

      protected Writer writer
      The writer for the temporary file.
    • item

      protected StemmerOverrideItem item
      The stemmer override item being added or updated.
  • Constructor Details

    • StemmerOverrideUpdater

      protected StemmerOverrideUpdater(StemmerOverrideItem newItem)
      Constructs a new updater for a stemmer override item.
      Parameters:
      newItem - The item to be added or updated.
      Throws:
      DictionaryException - if the temporary file cannot be created.
  • Method Details

    • write

      public StemmerOverrideItem write(StemmerOverrideItem oldItem)
      Writes a stemmer override item to the temporary file. If the item is being updated, it writes the new version.
      Parameters:
      oldItem - The original item from the dictionary.
      Returns:
      The written item, or null if the item was deleted.
      Throws:
      DictionaryException - if the file was updated concurrently.
    • write

      public void write(String line)
      Writes a raw line to the temporary file.
      Parameters:
      line - The line to write.
      Throws:
      DictionaryException - if an I/O error occurs.
    • commit

      public StemmerOverrideItem commit()
      Commits the changes to the dictionary file. If there is a pending new item, it is written to the file.
      Returns:
      The committed item, or null if no item was committed.
      Throws:
      DictionaryException - if an I/O error occurs.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable