Package org.moeaframework.analysis.store
Class TransactionalWriter
java.lang.Object
java.io.Writer
java.io.FilterWriter
org.moeaframework.analysis.store.TransactionalWriter
- All Implemented Interfaces:
Closeable
,Flushable
,Appendable
,AutoCloseable
Writer with a transaction mechanism requiring one to call
commit()
before the content is stored. The
typical use is:
try (TransactionalWriter writer = blob.openWriter()) {
writer.write(...);
writer.commit();
}
-
Field Summary
Fields inherited from class java.io.FilterWriter
out
-
Constructor Summary
-
Method Summary
Methods inherited from class java.io.FilterWriter
flush, write, write, write
-
Constructor Details
-
TransactionalWriter
Constructs a transactional writer.- Parameters:
out
- the temporary writer, where content is written before it is committed
-
-
Method Details
-
commit
Indicates the content was successfully written. This method must be called beforeclose()
to take effect.- Throws:
IOException
- if an I/O error occurred
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classFilterWriter
- Throws:
IOException
-
doCommit
Called duringclose()
to commit or complete the transaction.- Throws:
IOException
- if an I/O error occurred
-
doRollback
Called duringclose()
to rollback the transaction.- Throws:
IOException
- if an I/O error occurred
-