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.value.binary
Class AbstractBinaryStore

    java.lang.Object
      org.modeshape.jcr.value.binary.AbstractBinaryStore

All Implemented Interfaces:
  BinaryStore

Direct Known Subclasses:
  DatabaseBinaryStore, FileSystemBinaryStore, InfinispanBinaryStore, MongodbBinaryStore

    @ThreadSafe
    public abstract class AbstractBinaryStore

extends Object
implements BinaryStore

An abstract class for a `BinaryStore`, with common functionality needed by implementation classes.

Field Summary
`protected Logger` | `logger`
`protected static int` | `MEDIUM_BUFFER_SIZE`

Fields inherited from interface org.modeshape.jcr.value.binary.BinaryStore
`DEFAULT_MINIMUM_BINARY_SIZE_IN_BYTES`

Constructor Summary
`AbstractBinaryStore()`

Method Summary
`static int` | `bestBufferSize(long fileSize)`
`protected MimeTypeDetector` | `detector()` Get the MIME type detector that can be used to find the MIME type for binary content
`protected TextExtractors` | `extractors()` Get the text extractor that can be used to extract text by this store.
`String` | `getMimeType(BinaryValue binary, String name)` Get the MIME type for this binary value or `null` if the mime-type cannot be determined.
`long` | `getMinimumBinarySizeInBytes()` Get the minimum number of bytes that a binary value must contain before it can be stored in the binary store.
`protected String` | `getStoredMimeType(BinaryValue binaryValue)` Returns the stored mime-type of a binary value.
`String` | `getText(BinaryValue binary)` Get the text that can be extracted from this binary content.
`void` | `setMimeTypeDetector(MimeTypeDetector mimeTypeDetector)` Set the MIME type detector that can be used for determining the MIME type for binary content.
`void` | `setMinimumBinarySizeInBytes(long minSizeInBytes)` Set the minimum number of bytes that a binary value must contain before it can be stored in the binary store.
`void` | `setTextExtractors(TextExtractors textExtractors)` Set the text extractor that can be used for extracting text from binary content.
`void` | `shutdown()`
`void` | `start()` Initialize the store and get ready for use.
`protected void` | `storeMimeType(BinaryValue binaryValue, String mimeType)` Stores the given mime-type for a binary value.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface org.modeshape.jcr.value.binary.BinaryStore
`getAllBinaryKeys, getExtractedText, getInputStream, markAsUnused, removeValuesUnusedLongerThan, storeExtractedText, storeValue`

Field Detail

### MEDIUM_BUFFER_SIZE

    protected static final int MEDIUM_BUFFER_SIZE

See Also:
  Constant Field Values

### logger

    protected Logger logger

Constructor Detail

### AbstractBinaryStore

    public AbstractBinaryStore()

Method Detail

### bestBufferSize

    public static int bestBufferSize(long fileSize)

### getMinimumBinarySizeInBytes

    public long getMinimumBinarySizeInBytes()

  Description copied from interface: `BinaryStore`
  Get the minimum number of bytes that a binary value must contain before it can be stored in the binary store.

  Specified by:
    `getMinimumBinarySizeInBytes` in interface `BinaryStore`
  Returns:
    the minimum number of bytes for a stored binary value; never negative

### setMinimumBinarySizeInBytes

    public void setMinimumBinarySizeInBytes(long minSizeInBytes)

  Description copied from interface: `BinaryStore`
  Set the minimum number of bytes that a binary value must contain before it can be stored in the binary store.

  Specified by:
    `setMinimumBinarySizeInBytes` in interface `BinaryStore`
  Parameters:
    `minSizeInBytes` - the minimum number of bytes for a stored binary value; may not be negative

### setTextExtractors

    public void setTextExtractors(TextExtractors textExtractors)

  Description copied from interface: `BinaryStore`
  Set the text extractor that can be used for extracting text from binary content.

  Specified by:
    `setTextExtractors` in interface `BinaryStore`
  Parameters:
    `textExtractors` - a non-null `TextExtractors` instance

### setMimeTypeDetector

    public void setMimeTypeDetector(MimeTypeDetector mimeTypeDetector)

  Description copied from interface: `BinaryStore`
  Set the MIME type detector that can be used for determining the MIME type for binary content.

  Specified by:
    `setMimeTypeDetector` in interface `BinaryStore`
  Parameters:
    `mimeTypeDetector` - the detector

### getText

    public final String getText(BinaryValue binary)
                         throws BinaryStoreException

  Description copied from interface: `BinaryStore`
  Get the text that can be extracted from this binary content. If text extraction isn't enabled (either full text search is not enabled or there aren't any configured extractors), this returns `null`

  If extraction is enabled, this method may block until a text extractor has finished extracting the text.

  If there are any problems either with the binary value or during the extraction process, the exception will be logged and `null` is returned

  In general, the implementation from `AbstractBinaryStore` should be enough and any custom `BinaryStore` implementations aren't expected to implement this.

  Specified by:
    `getText` in interface `BinaryStore`
  Parameters:
    `binary` - the binary content; may not be null
  Returns:
    the extracted text, or null if none could be extracted
  Throws:
    `BinaryStoreException` - if the binary content could not be accessed

### getMimeType

    public String getMimeType(BinaryValue binary,
                              String name)
                       throws IOException,
                              RepositoryException

  Description copied from interface: `BinaryStore`
  Get the MIME type for this binary value or `null` if the mime-type cannot be determined.

  Specified by:
    `getMimeType` in interface `BinaryStore`
  Parameters:
    `binary` - the binary content; may not be null
    `name` - the name of the content, useful for determining the MIME type; may be null if not known
  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 any other error occurs.

### getStoredMimeType

    protected String getStoredMimeType(BinaryValue binaryValue)
                                throws BinaryStoreException

  Returns the stored mime-type of a binary value.

  Parameters:
    `binaryValue` - a `non-null` `BinaryValue`
  Returns:
    either a non-empty `String` if a stored mimetype exists, or `null` if such a value doesn't exist yet.
  Throws:
    `BinaryStoreException` - if there's a problem accessing the binary store

### storeMimeType

    protected void storeMimeType(BinaryValue binaryValue,
                                 String mimeType)
                          throws BinaryStoreException

  Stores the given mime-type for a binary value.

  Parameters:
    `binaryValue` - a `non-null` `BinaryValue`
    `mimeType` - a non-empty `String`
  Throws:
    `BinaryStoreException` - if there's a problem accessing the binary store

### extractors

    protected final TextExtractors extractors()

  Get the text extractor that can be used to extract text by this store.

  Returns:
    the text extractor; never null

### detector

    protected final MimeTypeDetector detector()

  Get the MIME type detector that can be used to find the MIME type for binary content

  Returns:
    the detector; never null

### start

    public void start()

  Initialize the store and get ready for use.

### shutdown

    public void shutdown()

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.