org.modeshape.jcr.value.binary
Class AbstractBinary
java.lang.Object
org.modeshape.jcr.value.binary.AbstractBinary
- All Implemented Interfaces:
- Serializable, Comparable<BinaryValue>, Binary, BinaryValue
- Direct Known Subclasses:
- EmptyBinaryValue, InMemoryBinaryValue, StoredBinaryValue
@Immutable
public abstract class AbstractBinary
- extends Object
- implements BinaryValue
An abstract implementation of BinaryValue
that provides some common capabilities for other implementations.
- See Also:
- Serialized Form
EMPTY_CONTENT
protected static final byte[] EMPTY_CONTENT
AbstractBinary
protected AbstractBinary(BinaryKey key)
keyFor
public static BinaryKey keyFor(byte[] sha1)
read
public int read(byte[] b,
long position)
throws IOException,
RepositoryException
- Specified by:
read
in interface Binary
- Throws:
IOException
RepositoryException
getKey
public BinaryKey getKey()
- Description copied from interface:
BinaryValue
- Get the key for the binary value.
- Specified by:
getKey
in interface BinaryValue
- Returns:
- the key; never null
getHash
public byte[] getHash()
- Description copied from interface:
Binary
- Get the SHA-1 hash of the contents. This hash can be used to determine whether two Binary instances contain the same
content.
Repeatedly calling this method should generally be efficient, as it most implementations will compute the hash only once.
- Returns:
- the hash of the contents as a byte array, or an empty array if the hash could not be computed.
- See Also:
MessageDigest.digest(byte[])
,
MessageDigest.getInstance(String)
,
Binary.getHexHash()
getHexHash
public String getHexHash()
- Description copied from interface:
Binary
- Get the hexadecimal form of the SHA-1 hash of the contents. This hash can be used to determine whether two Binary instances
contain the same content.
Repeatedly calling this method should generally be efficient, as it most implementations will compute the hash only once.
- Returns:
- the hexadecimal form of the
Binary.getHash()
, or a null string if the hash could not be computed or is not known - See Also:
MessageDigest.digest(byte[])
,
MessageDigest.getInstance(String)
,
Binary.getHash()
dispose
public void dispose()
- Specified by:
dispose
in interface Binary
compareTo
public int compareTo(BinaryValue o)
- Specified by:
compareTo
in interface Comparable<BinaryValue>
hashCode
public int hashCode()
- Overrides:
hashCode
in class Object
equals
public boolean equals(Object obj)
-
- Overrides:
equals
in class Object
toString
public String toString()
-
- Overrides:
toString
in class Object
getReadableSize
public String getReadableSize()
Copyright © 2008-2012 JBoss, a division of Red Hat. All Rights Reserved.