public class CAFS extends java.lang.Object implements java.io.Closeable, java.lang.Iterable<SHA1>
Modifier and Type | Field and Description |
---|---|
(package private) static java.lang.String |
ALGORITHM |
(package private) static byte[] |
CAFE |
(package private) static byte[] |
CAFS |
(package private) java.nio.channels.FileChannel |
channel |
(package private) static int |
HEADERLENGTH |
(package private) java.io.File |
home |
(package private) Index |
index |
(package private) static java.lang.String |
INDEXFILE |
(package private) static int |
KEYLENGTH |
(package private) java.io.RandomAccessFile |
store |
(package private) static java.lang.String |
STOREFILE |
Constructor and Description |
---|
CAFS(java.io.File home,
boolean create)
Constructor for a Content Addressable File Store
|
Modifier and Type | Method and Description |
---|---|
(package private) short |
checksum(int flags,
int compressedLength,
int totalLength,
byte[] sha1) |
void |
close() |
boolean |
exists(byte[] sha1) |
private java.io.InputStream |
getSha1Stream(SHA1 sha1,
byte[] buffer,
int total) |
boolean |
isEmpty() |
java.util.Iterator<SHA1> |
iterator() |
java.io.InputStream |
read(SHA1 sha1)
Read the contents of a sha 1 key.
|
void |
reindex() |
private void |
update(byte[] sha1,
byte[] compressed,
int totalLength)
Update a record in the store, assuming the store is at the right
position.
|
private SHA1 |
verifyEntry(java.io.RandomAccessFile in) |
private boolean |
verifySignature(java.io.DataInput din,
byte[] org) |
SHA1 |
write(java.io.InputStream in)
Store an input stream in the CAFS while calculating and returning the
SHA-1 code.
|
static final byte[] CAFS
static final byte[] CAFE
static final java.lang.String INDEXFILE
static final java.lang.String STOREFILE
static final java.lang.String ALGORITHM
static final int KEYLENGTH
static final int HEADERLENGTH
final java.io.File home
Index index
java.io.RandomAccessFile store
java.nio.channels.FileChannel channel
public CAFS(java.io.File home, boolean create) throws java.lang.Exception
home
- create
- java.lang.Exception
public SHA1 write(java.io.InputStream in) throws java.lang.Exception
in
- The input stream to store.java.lang.Exception
- if anything goes wrongpublic java.io.InputStream read(SHA1 sha1) throws java.lang.Exception
sha1
- The keyjava.lang.Exception
public boolean exists(byte[] sha1) throws java.lang.Exception
java.lang.Exception
public void reindex() throws java.lang.Exception
java.lang.Exception
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException
private SHA1 verifyEntry(java.io.RandomAccessFile in) throws java.io.IOException, java.security.NoSuchAlgorithmException
java.io.IOException
java.security.NoSuchAlgorithmException
private boolean verifySignature(java.io.DataInput din, byte[] org) throws java.io.IOException
java.io.IOException
private java.io.InputStream getSha1Stream(SHA1 sha1, byte[] buffer, int total) throws java.security.NoSuchAlgorithmException
java.security.NoSuchAlgorithmException
private void update(byte[] sha1, byte[] compressed, int totalLength) throws java.io.IOException
sha1
- The checksumcompressed
- The compressed lengthtotalLength
- The uncompressed lengthjava.io.IOException
- The exceptionshort checksum(int flags, int compressedLength, int totalLength, byte[] sha1)
public java.util.Iterator<SHA1> iterator()
iterator
in interface java.lang.Iterable<SHA1>
public boolean isEmpty() throws java.io.IOException
java.io.IOException