Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| ModeShape Distribution 3.0.0.Beta3
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.modeshape.jcr.api
Interface Binary

All Superinterfaces:
  Binary

All Known Subinterfaces:
  BinaryValue

All Known Implementing Classes:
  AbstractBinary, EmptyBinaryValue, InMemoryBinaryValue, StoredBinaryValue

    public interface Binary

extends Binary

An extension of the standard `Binary` interface, with methods to obtain the SHA-1 hash of the binary value.

Method Summary
`byte[]` | `getHash()` Get the SHA-1 hash of the contents.
`String` | `getHexHash()` Get the hexadecimal form of the SHA-1 hash of the contents.
`String` | `getMimeType()` Get the MIME type for this binary value.
`String` | `getMimeType(String name)` Get the MIME type for this binary value.

Methods inherited from interface javax.jcr.Binary
`dispose, getSize, getStream, read`

Method Detail

### getHash

    byte[] getHash()

  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)`, `getHexHash()`

### getHexHash

    String getHexHash()

  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 `getHash()`, or a null string if the hash could not be computed or is not known
  See Also:
    `MessageDigest.digest(byte[])`, `MessageDigest.getInstance(String)`, `getHash()`

### getMimeType

    String getMimeType()
                       throws IOException,
                              RepositoryException

  Get the MIME type for this binary value.

  Returns:
    the MIME type, or null if it cannot be determined (e.g., the Binary is empty)
  Throws:
    `IOException` - if there is a problem reading the binary content
    `RepositoryException` - if an error occurs.

### getMimeType

    String getMimeType(String name)
                       throws IOException,
                              RepositoryException

  Get the MIME type for this binary value.

  Parameters:
    `name` - the name of the binary value, useful in helping to determine the MIME type
  Returns:
    the MIME type, or null if it cannot be determined (e.g., the Binary is empty)
  Throws:
    `IOException` - if there is a problem reading the binary content
    `RepositoryException` - if an error occurs.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| ModeShape Distribution 3.0.0.Beta3
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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