ModeShape Distribution 3.0.0.Beta2

org.modeshape.jcr.value.binary
Interface BinaryStore

All Known Implementing Classes:
AbstractBinaryStore, DatabaseBinaryStore, FileSystemBinaryStore, InfinispanBinaryStore, TransientBinaryStore

@ThreadSafe
public interface BinaryStore

The basic interface for a store for Binary value objects. All binary values that are of a minimum threshold size are stored in the store; smaller binary values are kept in-memory and are stored within the nodes.


Field Summary
static long DEFAULT_MINIMUM_BINARY_SIZE_IN_BYTES
          The default minimum size (in bytes) of binary values that are persisted in the binary store is 4096 bytes, or 4KB.
 
Method Summary
 String getExtractedText(BinaryValue source)
          Retrieves the extracted text of a binary value, which may or may not have been stored previously.
 InputStream getInputStream(BinaryKey key)
          Get an InputStream to the binary content with the supplied key.
 String getMimeType(BinaryValue binary, String name)
          Get the MIME type for this binary value.
 long getMinimumBinarySizeInBytes()
          Get the minimum number of bytes that a binary value must contain before it can be stored in the binary store.
 String getText(BinaryValue binary)
          Get the text that can be extracted from this binary content.
 void markAsUnused(Iterable<BinaryKey> keys)
          Mark the supplied binary keys as unused, but key them in quarantine until needed again (at which point they're removed from quarantine) or until removeValuesUnusedLongerThan(long, TimeUnit) is called.
 void removeValuesUnusedLongerThan(long minimumAge, TimeUnit unit)
          Remove binary values that have been unused for at least the specified amount of time.
 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 storeExtractedText(BinaryValue source, String extractedText)
          Stores the extracted text of a binary value into this store.
 BinaryValue storeValue(InputStream stream)
          Store the binary value and return the JCR representation.
 

Field Detail

DEFAULT_MINIMUM_BINARY_SIZE_IN_BYTES

static final long DEFAULT_MINIMUM_BINARY_SIZE_IN_BYTES
The default minimum size (in bytes) of binary values that are persisted in the binary store is 4096 bytes, or 4KB.

See Also:
Constant Field Values
Method Detail

getMinimumBinarySizeInBytes

long getMinimumBinarySizeInBytes()
Get the minimum number of bytes that a binary value must contain before it can be stored in the binary store.

Returns:
the minimum number of bytes for a stored binary value; never negative

setMinimumBinarySizeInBytes

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.

Parameters:
minSizeInBytes - the minimum number of bytes for a stored binary value; may not be negative

setTextExtractors

void setTextExtractors(TextExtractors textExtractors)
Set the text extractor that can be used for extracting text from binary content.

Parameters:
textExtractors - a non-null TextExtractors instance

setMimeTypeDetector

void setMimeTypeDetector(MimeTypeDetector mimeTypeDetector)
Set the MIME type detector that can be used for determining the MIME type for binary content.

Parameters:
mimeTypeDetector - the detector

storeValue

BinaryValue storeValue(InputStream stream)
                       throws BinaryStoreException
Store the binary value and return the JCR representation. Note that if the binary content in the supplied stream is already persisted in the store, the store may simply return the binary value referencing the existing content.

Parameters:
stream - the stream containing the binary content to be stored; may not be null
Returns:
the binary value representing the stored binary value; never null
Throws:
BinaryStoreException

getInputStream

InputStream getInputStream(BinaryKey key)
                           throws BinaryStoreException
Get an InputStream to the binary content with the supplied key.

Parameters:
key - the key to the binary content; never null
Returns:
the input stream through which the content can be read
Throws:
BinaryStoreException - if there is a problem reading the content from the store

markAsUnused

void markAsUnused(Iterable<BinaryKey> keys)
                  throws BinaryStoreException
Mark the supplied binary keys as unused, but key them in quarantine until needed again (at which point they're removed from quarantine) or until removeValuesUnusedLongerThan(long, TimeUnit) is called. This method ignores any keys for values not stored within this store.

Parameters:
keys - the keys for the binary values that are no longer needed
Throws:
BinaryStoreException - if there is a problem marking any of the supplied binary values as unused

removeValuesUnusedLongerThan

void removeValuesUnusedLongerThan(long minimumAge,
                                  TimeUnit unit)
                                  throws BinaryStoreException
Remove binary values that have been unused for at least the specified amount of time.

Parameters:
minimumAge - the minimum time that a binary value has been unused before it can be removed; must be non-negative
unit - the time unit for the minimum age; may not be null
Throws:
BinaryStoreException - if there is a problem removing the unused values

getText

String getText(BinaryValue binary)
               throws BinaryStoreException
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.

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

String getMimeType(BinaryValue binary,
                   String name)
                   throws IOException,
                          RepositoryException
Get the MIME type for this binary value.

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 an error occurs.

storeExtractedText

void storeExtractedText(BinaryValue source,
                        String extractedText)
                        throws BinaryStoreException
Stores the extracted text of a binary value into this store.

Parameters:
source - a non-null BinaryValue instance from which the text was extracted
extractedText - a non-null and non-blank string representing the extracted text
Throws:
BinaryStoreException - if the operation fails for whatever reason

getExtractedText

String getExtractedText(BinaryValue source)
                        throws BinaryStoreException
Retrieves the extracted text of a binary value, which may or may not have been stored previously.

Parameters:
source - a non-null BinaryValue instance from which the text was extracted
Returns:
a String representing the extracted text, or null if such text hasn't been stored in this store previously.
Throws:
BinaryStoreException - if the operation fails

ModeShape Distribution 3.0.0.Beta2

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