public final class ContentAddressableStoreFileImpl extends ContentAddressableStoreImpl
Modifier and Type | Field and Description |
---|---|
int |
hashPrefixLength
The number of characters from the hash to use for the name of the top level
subdirectories.
|
static String |
rootPathPropertyName |
Constructor and Description |
---|
ContentAddressableStoreFileImpl(Properties properties)
Initialises the store.
|
Modifier and Type | Method and Description |
---|---|
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.
|
Path |
getContentPath(String hashString) |
List<Hash> |
getHashes()
Get a list of all hashes in the store.
|
Path |
getRootPath() |
Path |
getSubPath(String hashString) |
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.
|
Hash |
write(InputStream inputStream)
Write content to the store, returning its hash.
|
Hash |
write(InputStream inputStream,
List<ContentEncoding> encodings)
Write content to the store in raw format and also formats specified in
the ContentEncodings.
|
addListener, notifyListenersContentAdded, notifyListenersContentRemoved, removeListener
public final int hashPrefixLength
public static final String rootPathPropertyName
public ContentAddressableStoreFileImpl(Properties properties) throws IOException
properties
- Properties controlling construction. Currently supported
properties are:
ContentAddressableStoreFileImpl.class.getName() + ".rootPath"
which specifies the path to the root directory of the
storage.IOException
public Path getRootPath()
public Hash write(InputStream inputStream) throws IOException
ContentAddressableStore
inputStream
- Content to be writtenIOException
public Hash write(InputStream inputStream, List<ContentEncoding> encodings) throws IOException
ContentAddressableStore
inputStream
- Content to be writtenIOException
public boolean contains(Hash hash)
ContentAddressableStore
hash
- Hash of content to checktrue
if content exists in the store with specified
hashpublic boolean contains(Hash hash, ContentEncoding contentEncoding)
ContentAddressableStore
hash
- Hash of content to checkcontentEncoding
- Type of encoding to use.true
if content exists in the store with specified
hash and specified encoding.public InputStream read(Hash hash, ContentEncoding contentEncoding) throws IOException
ContentAddressableStore
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
public InputStream read(Hash hash) throws IOException
ContentAddressableStore
hash
- The hash of the content to read.InputStream
of content if content exists; otherwise
null
.IOException
public long getContentLength(Hash hash) throws IOException
ContentAddressableStore
hash
- The hash of the contentIOException
public long getContentLength(Hash hash, ContentEncoding contentEncoding) throws IOException
ContentAddressableStore
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
public List<Hash> getHashes() throws IOException
ContentAddressableStore
IOException
public boolean delete(Hash hash) throws IOException
ContentAddressableStore
hash
- Hash of content to deletetrue
if the content existed and was deleted;
otherwise false.IOException
public void close()
Copyright © 2019. All rights reserved.