public class AtomicObjectOutputStream
extends java.io.OutputStream
LockFile
which is committed on
close(). The stream checks if the hash of the stream content matches the id.Modifier and Type | Field and Description |
---|---|
private boolean |
aborted |
private AnyLongObjectId |
id |
private LockFile |
locked |
private java.security.DigestOutputStream |
out |
Constructor and Description |
---|
AtomicObjectOutputStream(java.nio.file.Path path)
Constructor for AtomicObjectOutputStream.
|
AtomicObjectOutputStream(java.nio.file.Path path,
AnyLongObjectId id)
Constructor for AtomicObjectOutputStream.
|
Modifier and Type | Method and Description |
---|---|
void |
abort()
Aborts the stream.
|
void |
close() |
AnyLongObjectId |
getId()
Get the
id . |
private void |
verifyHash() |
void |
write(byte[] b) |
void |
write(byte[] b,
int off,
int len) |
void |
write(int b) |
private LockFile locked
private java.security.DigestOutputStream out
private boolean aborted
private AnyLongObjectId id
public AtomicObjectOutputStream(java.nio.file.Path path, AnyLongObjectId id) throws java.io.IOException
path
- a Path
object.id
- a AnyLongObjectId
object.java.io.IOException
public AtomicObjectOutputStream(java.nio.file.Path path) throws java.io.IOException
path
- a Path
object.java.io.IOException
@Nullable public AnyLongObjectId getId()
id
.null
if called before closing this
stream.public void write(int b) throws java.io.IOException
write
in class java.io.OutputStream
java.io.IOException
public void write(byte[] b) throws java.io.IOException
write
in class java.io.OutputStream
java.io.IOException
public void write(byte[] b, int off, int len) throws java.io.IOException
write
in class java.io.OutputStream
java.io.IOException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.OutputStream
java.io.IOException
private void verifyHash()
public void abort()