Class StemmerOverrideFile.StemmerOverrideUpdater
java.lang.Object
org.codelibs.fess.dict.stemmeroverride.StemmerOverrideFile.StemmerOverrideUpdater
- All Implemented Interfaces:
Closeable,AutoCloseable
- Enclosing class:
StemmerOverrideFile
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 Summary
FieldsModifier and TypeFieldDescriptionprotected booleanA flag indicating whether the changes have been committed.protected StemmerOverrideItemThe stemmer override item being added or updated.protected FileThe temporary file to write changes to.protected WriterThe writer for the temporary file. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructs a new updater for a stemmer override item. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()commit()Commits the changes to the dictionary file.voidWrites a raw line to the temporary file.write(StemmerOverrideItem oldItem) Writes a stemmer override item to the temporary file.
-
Field Details
-
isCommit
protected boolean isCommitA flag indicating whether the changes have been committed. -
newFile
The temporary file to write changes to. -
writer
The writer for the temporary file. -
item
The stemmer override item being added or updated.
-
-
Constructor Details
-
StemmerOverrideUpdater
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
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
Writes a raw line to the temporary file.- Parameters:
line- The line to write.- Throws:
DictionaryException- if an I/O error occurs.
-
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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-