Package org.codelibs.fess.dict.stopwords
Class StopwordsFile.StopwordsUpdater
java.lang.Object
org.codelibs.fess.dict.stopwords.StopwordsFile.StopwordsUpdater
- All Implemented Interfaces:
Closeable,AutoCloseable
- Enclosing class:
StopwordsFile
An inner class for updating the stopwords 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 StopwordsItemThe stopword item being added or updated.protected FileThe temporary file to write changes to.protected WriterThe writer for the temporary file. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedStopwordsUpdater(StopwordsItem newItem) Constructs a new updater for a stopword item. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()commit()Commits the changes to the dictionary file.voidWrites a raw line to the temporary file.write(StopwordsItem oldItem) Writes a stopword 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 stopword item being added or updated.
-
-
Constructor Details
-
StopwordsUpdater
Constructs a new updater for a stopword item.- Parameters:
newItem- The item to be added or updated.- Throws:
DictionaryException- if the temporary file cannot be created.
-
-
Method Details
-
write
Writes a stopword 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
-