public interface ContentAddressableStore extends AutoCloseable
Modifier and Type | Method and Description |
---|---|
void |
addListener(ContentAddressableStoreListener contentAddressableStoreListener)
Add a listener to this store.
|
void |
close() |
boolean |
contains(Hash hash)
Check whether content exists in the store with the specified hash
|
boolean |
contains(Hash hash,
ContentEncoding contentEncoding)
Check whether content exists in the store with the specified hash with the specified encoding
|
boolean |
delete(Hash hash)
Delete content from the store.
|
long |
getContentLength(Hash hash)
Get the length of the content with the specified hash
|
long |
getContentLength(Hash hash,
ContentEncoding contentEncoding)
Get the length of the encoded content with the specified hash.
|
List<Hash> |
getHashes()
Get a list of all hashes in the store.
|
InputStream |
read(Hash hash)
Read content from the store.
|
InputStream |
read(Hash hash,
ContentEncoding contentEncoding)
Read content from the store, returning using the given encoding.
|
void |
removeListener(ContentAddressableStoreListener contentAddressableStoreListener)
Remove a listener to this store.
|
Hash |
write(InputStream stream)
Write content to the store, returning its hash.
|
Hash |
write(InputStream stream,
List<ContentEncoding> encodings)
Write content to the store in raw format and also formats specified in
the ContentEncodings.
|
Hash write(InputStream stream) throws IOException
stream
- Content to be writtenIOException
Hash write(InputStream stream, List<ContentEncoding> encodings) throws IOException
stream
- Content to be writtenIOException
boolean contains(Hash hash)
hash
- Hash of content to checktrue
if content exists in the store with specified
hashboolean contains(Hash hash, ContentEncoding contentEncoding)
hash
- Hash of content to checkcontentEncoding
- Type of encoding to use.true
if content exists in the store with specified
hash and specified encoding.InputStream read(Hash hash) throws IOException
hash
- The hash of the content to read.InputStream
of content if content exists; otherwise
null
.IOException
InputStream read(Hash hash, ContentEncoding contentEncoding) throws IOException
hash
- The hash of the (raw) content to read.contentEncoding
- Type of encoding to use to return the stream. If null then no
encoding is used.InputStream
of content if content exists; otherwise
null
.IOException
long getContentLength(Hash hash) throws IOException
hash
- The hash of the contentIOException
long getContentLength(Hash hash, ContentEncoding contentEncoding) throws IOException
hash
- The hash of the contentcontentEncoding
- The encoding type to use. If null then no encoding is used and
the raw content is assumed.IOException
List<Hash> getHashes() throws IOException
IOException
boolean delete(Hash hash) throws IOException
hash
- Hash of content to deletetrue
if the content existed and was deleted;
otherwise false.IOException
void addListener(ContentAddressableStoreListener contentAddressableStoreListener)
contentAddressableStoreListener
- void removeListener(ContentAddressableStoreListener contentAddressableStoreListener)
contentAddressableStoreListener
- void close()
close
in interface AutoCloseable
Copyright © 2019. All rights reserved.