@Immutable public abstract class AbstractBinary extends Object implements BinaryValue
BinaryValue
that provides some common capabilities for other implementations.Modifier and Type | Field and Description |
---|---|
protected static byte[] |
EMPTY_CONTENT |
Modifier | Constructor and Description |
---|---|
protected |
AbstractBinary(BinaryKey key) |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(BinaryValue o) |
void |
dispose() |
boolean |
equals(Object obj) |
byte[] |
getHash()
Get the SHA-1 hash of the contents.
|
String |
getHexHash()
Get the hexadecimal form of the SHA-1 hash of the contents.
|
BinaryKey |
getKey()
Get the key for the binary value.
|
String |
getReadableSize() |
InputStream |
getStream() |
int |
hashCode() |
protected abstract InputStream |
internalStream() |
static BinaryKey |
keyFor(byte[] sha1) |
int |
read(byte[] b,
long position) |
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getSize
getMimeType, getMimeType
protected AbstractBinary(BinaryKey key)
public static BinaryKey keyFor(byte[] sha1)
public int read(byte[] b, long position) throws IOException, RepositoryException
read
in interface Binary
IOException
RepositoryException
public BinaryKey getKey()
BinaryValue
getKey
in interface BinaryValue
public byte[] getHash()
Binary
Repeatedly calling this method should generally be efficient, as it most implementations will compute the hash only once.
MessageDigest.digest(byte[])
,
MessageDigest.getInstance(String)
,
Binary.getHexHash()
public String getHexHash()
Binary
Repeatedly calling this method should generally be efficient, as it most implementations will compute the hash only once.
Binary.getHash()
, or a null string if the hash could not be computed or is not knownMessageDigest.digest(byte[])
,
MessageDigest.getInstance(String)
,
Binary.getHash()
public int compareTo(BinaryValue o)
compareTo
in interface Comparable<BinaryValue>
public String getReadableSize()
public InputStream getStream() throws RepositoryException
getStream
in interface Binary
RepositoryException
protected abstract InputStream internalStream() throws Exception
Exception
Copyright © 2008–2016 JBoss, a division of Red Hat. All rights reserved.