Class SynonymFile.SynonymUpdater

java.lang.Object
org.codelibs.fess.dict.synonym.SynonymFile.SynonymUpdater
All Implemented Interfaces:
Closeable, AutoCloseable
Enclosing class:
SynonymFile

protected class SynonymFile.SynonymUpdater extends Object implements Closeable
An inner class for updating the synonym 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 SynonymItem item
      The synonym item being added or updated.
  • Constructor Details

    • SynonymUpdater

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

    • write

      public SynonymItem write(SynonymItem oldItem)
      Writes a synonym 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 SynonymItem 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