Class CharMappingFile.MappingUpdater

java.lang.Object
org.codelibs.fess.dict.mapping.CharMappingFile.MappingUpdater
All Implemented Interfaces:
Closeable, AutoCloseable
Enclosing class:
CharMappingFile

protected class CharMappingFile.MappingUpdater extends Object implements Closeable
Inner class for handling updates to the character mapping file. This class manages the temporary file creation, writing operations, and atomic updates to ensure data consistency during modifications.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
    Flag indicating whether changes should be committed to the file.
    protected CharMappingItem
    The mapping item being updated, or null for read-only operations.
    protected File
    Temporary file used for writing updates before committing.
    protected Writer
    Writer for outputting content to the temporary file.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Constructs a new MappingUpdater for handling file updates.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Closes the updater and finalizes the file update operation.
    Commits any pending changes and marks the updater for final write.
    void
    write(String line)
    Writes a raw line of text to the temporary file.
    Writes a character mapping item to the temporary file.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • isCommit

      protected boolean isCommit
      Flag indicating whether changes should be committed to the file.
    • newFile

      protected File newFile
      Temporary file used for writing updates before committing.
    • writer

      protected Writer writer
      Writer for outputting content to the temporary file.
    • item

      protected CharMappingItem item
      The mapping item being updated, or null for read-only operations.
  • Constructor Details

    • MappingUpdater

      protected MappingUpdater(CharMappingItem newItem)
      Constructs a new MappingUpdater for handling file updates.
      Parameters:
      newItem - the character mapping item to update, or null for read-only operations
  • Method Details

    • write

      public CharMappingItem write(CharMappingItem oldItem)
      Writes a character mapping item to the temporary file.
      Parameters:
      oldItem - the existing mapping item to process
      Returns:
      the mapping item that was written, or null if the item was deleted
    • write

      public void write(String line)
      Writes a raw line of text to the temporary file.
      Parameters:
      line - the line of text to write
    • commit

      public CharMappingItem commit()
      Commits any pending changes and marks the updater for final write.
      Returns:
      the committed mapping item, or null if no item was pending
    • close

      public void close()
      Closes the updater and finalizes the file update operation. If changes were committed, the temporary file replaces the original. Otherwise, the temporary file is deleted.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable