Package org.codelibs.fess.dict.mapping
Class CharMappingFile.MappingUpdater
java.lang.Object
org.codelibs.fess.dict.mapping.CharMappingFile.MappingUpdater
- All Implemented Interfaces:
Closeable,AutoCloseable
- Enclosing class:
CharMappingFile
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
FieldsModifier and TypeFieldDescriptionprotected booleanFlag indicating whether changes should be committed to the file.protected CharMappingItemThe mapping item being updated, or null for read-only operations.protected FileTemporary file used for writing updates before committing.protected WriterWriter for outputting content to the temporary file. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedMappingUpdater(CharMappingItem newItem) Constructs a new MappingUpdater for handling file updates. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the updater and finalizes the file update operation.commit()Commits any pending changes and marks the updater for final write.voidWrites a raw line of text to the temporary file.write(CharMappingItem oldItem) Writes a character mapping item to the temporary file.
-
Field Details
-
isCommit
protected boolean isCommitFlag indicating whether changes should be committed to the file. -
newFile
Temporary file used for writing updates before committing. -
writer
Writer for outputting content to the temporary file. -
item
The mapping item being updated, or null for read-only operations.
-
-
Constructor Details
-
MappingUpdater
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
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
Writes a raw line of text to the temporary file.- Parameters:
line- the line of text to write
-
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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-