org.modeshape.jcr
Class JcrBinary

java.lang.Object
  extended by org.modeshape.jcr.JcrBinary
All Implemented Interfaces:
Binary

public class JcrBinary
extends Object
implements Binary, Binary

An implementation of JCR 2.0 Binary that wraps a graph Binary value object.


Method Summary
 Binary binary()
           
 void dispose()
          
 byte[] getHash()
          Get the SHA-1 hash of the contents.
 String getHexHash()
          Get the hexadecimal form of the SHA-1 hash of the contents.
 long getSize()
          
 InputStream getStream()
          
 int read(byte[] b, long position)
          
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

binary

public Binary binary()

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
See Also:
Binary.dispose()

getSize

public long getSize()

Specified by:
getSize in interface Binary
See Also:
Binary.getSize()

getStream

public InputStream getStream()

Specified by:
getStream in interface Binary
See Also:
Binary.getStream()

read

public int read(byte[] b,
                long position)
         throws IOException

Specified by:
read in interface Binary
Throws:
IOException
See Also:
Binary.read(byte[], long)

toString

public String toString()

Overrides:
toString in class Object
See Also:
Object.toString()


Copyright © 2008-2012 JBoss, a division of Red Hat. All Rights Reserved.