|
ModeShape Distribution 3.0.0.Beta4 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.modeshape.jcr.value.binary.AbstractBinaryStore
@ThreadSafe public abstract class AbstractBinaryStore
An abstract class for a BinaryStore
, with common functionality needed by implementation classes.
Field Summary | |
---|---|
protected Logger |
logger
|
protected static int |
MEDIUM_BUFFER_SIZE
|
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. |
abstract String |
getExtractedText(BinaryValue source)
Returns the extracted text of a binary value, or null if such text hasn't been stored previously (but the binary
value can be found in the store) |
String |
getMimeType(BinaryValue binary,
String name)
Get the MIME type for this binary value, never null . |
long |
getMinimumBinarySizeInBytes()
Get the minimum number of bytes that a binary value must contain before it can be stored in the binary store. |
protected abstract 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. |
abstract void |
storeExtractedText(BinaryValue source,
String extractedText)
Stores the extracted text of a binary value into this store. |
protected abstract 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, getInputStream, markAsUnused, removeValuesUnusedLongerThan, storeValue |
Field Detail |
---|
protected static final int MEDIUM_BUFFER_SIZE
protected Logger logger
Constructor Detail |
---|
public AbstractBinaryStore()
Method Detail |
---|
public static int bestBufferSize(long fileSize)
public long getMinimumBinarySizeInBytes()
BinaryStore
getMinimumBinarySizeInBytes
in interface BinaryStore
public void setMinimumBinarySizeInBytes(long minSizeInBytes)
BinaryStore
setMinimumBinarySizeInBytes
in interface BinaryStore
minSizeInBytes
- the minimum number of bytes for a stored binary value; may not be negativepublic void setTextExtractors(TextExtractors textExtractors)
BinaryStore
setTextExtractors
in interface BinaryStore
textExtractors
- a non-null TextExtractors
instancepublic void setMimeTypeDetector(MimeTypeDetector mimeTypeDetector)
BinaryStore
setMimeTypeDetector
in interface BinaryStore
mimeTypeDetector
- the detectorpublic final String getText(BinaryValue binary) throws BinaryStoreException
BinaryStore
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
AbstractBinaryStore
should be enough and any custom BinaryStore
implementations aren't expected to implement this.
getText
in interface BinaryStore
binary
- the binary content; may not be null
BinaryStoreException
- if the binary content could not be accessed or if the given binary value cannot be found within
the store.public String getMimeType(BinaryValue binary, String name) throws IOException, BinaryStoreException, RepositoryException
BinaryStore
null
.
If the store has never determined the mime-type of the given binary and the binary can be located in the store,
it will attempt to determine it via the configured detectors
and store it.
getMimeType
in interface BinaryStore
binary
- the binary content; may not be nullname
- the name of the content, useful for determining the MIME type; may be null if not known
null
if none of the detectors
can determine it.
IOException
- if there is a problem reading the binary content
BinaryStoreException
- if the binary value cannot be found in the store
RepositoryException
- if any other error occurs.protected abstract String getStoredMimeType(BinaryValue binaryValue) throws BinaryStoreException
binaryValue
- a non-null
BinaryValue
String
if a stored mimetype exists, or null
if such a value doesn't exist yet.
BinaryStoreException
- if there's a problem accessing the binary store or if the binary value cannot be found in the storeprotected abstract void storeMimeType(BinaryValue binaryValue, String mimeType) throws BinaryStoreException
binaryValue
- a non-null
BinaryValue
mimeType
- a non-empty String
BinaryStoreException
- if there's a problem accessing the binary storepublic abstract void storeExtractedText(BinaryValue source, String extractedText) throws BinaryStoreException
source
- a non-null
BinaryValue
instance from which the text was extractedextractedText
- a non-null
and non-blank
string representing the extracted text
BinaryStoreException
- if the operation fails or if the extracted text cannot be stored for the given binary value
(regardless of the reason)public abstract String getExtractedText(BinaryValue source) throws BinaryStoreException
null
if such text hasn't been stored previously (but the binary
value can be found in the store)
source
- a non-null
BinaryValue
instance from which the text was extracted
String
representing the extracted text, or null
if such text hasn't been stored in this store
previously.
BinaryStoreException
- if the binary value cannot be found in the store.protected final TextExtractors extractors()
protected final MimeTypeDetector detector()
public void start()
public void shutdown()
|
ModeShape Distribution 3.0.0.Beta4 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |