Package org.apache.jackrabbit.core.data
Class AbstractDataStore
- java.lang.Object
-
- org.apache.jackrabbit.core.data.AbstractDataStore
-
- All Implemented Interfaces:
DataStore
- Direct Known Subclasses:
CachingDataStore
,DbDataStore
,FileDataStore
public abstract class AbstractDataStore extends Object implements DataStore
-
-
Constructor Summary
Constructors Constructor Description AbstractDataStore()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static String
encodeHexString(byte[] value)
Returns the hex encoding of the given bytes.protected byte[]
getOrCreateReferenceKey()
Returns the reference key of this data store.DataRecord
getRecord(DataIdentifier identifier)
Returns the identified data record.DataRecord
getRecordFromReference(String reference)
Returns the record that matches the given binary reference.protected String
getReferenceFromIdentifier(DataIdentifier identifier)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.jackrabbit.core.data.DataStore
addRecord, clearInUse, close, deleteAllOlderThan, getAllIdentifiers, getMinRecordLength, getRecordIfStored, init, updateModifiedDateOnAccess
-
-
-
-
Field Detail
-
DIGEST
protected String DIGEST
The digest algorithm used to uniquely identify records.
-
-
Method Detail
-
getRecord
public DataRecord getRecord(DataIdentifier identifier) throws DataStoreException
Description copied from interface:DataStore
Returns the identified data record. The given identifier should be the identifier of a previously saved data record. Since records are never removed, there should never be cases where the identified record is not found. Abnormal cases like that are treated as errors and handled by throwing an exception.- Specified by:
getRecord
in interfaceDataStore
- Parameters:
identifier
- data identifier- Returns:
- identified data record
- Throws:
DataStoreException
- if the data store could not be accessed, or if the given identifier is invalid
-
getRecordFromReference
public DataRecord getRecordFromReference(String reference) throws DataStoreException
Description copied from interface:DataStore
Returns the record that matches the given binary reference. Returnsnull
if the reference is invalid, for example if it points to a record that does not exist.- Specified by:
getRecordFromReference
in interfaceDataStore
- Parameters:
reference
- binary reference- Returns:
- matching record, or
null
- Throws:
DataStoreException
- if the data store could not be accessed
-
encodeHexString
protected static String encodeHexString(byte[] value)
Returns the hex encoding of the given bytes.- Parameters:
value
- value to be encoded- Returns:
- encoded value
-
getReferenceFromIdentifier
protected String getReferenceFromIdentifier(DataIdentifier identifier)
-
getOrCreateReferenceKey
protected byte[] getOrCreateReferenceKey() throws DataStoreException
Returns the reference key of this data store. If one does not already exist, it is automatically created in an implementation-specific way. The default implementation simply creates a temporary random key that's valid only until the data store gets restarted. Subclasses can override and/or decorate this method to support a more persistent reference key.This method is called only once during the lifetime of a data store instance and the return value is cached in memory, so it's no problem if the implementation is slow.
- Returns:
- reference key
- Throws:
DataStoreException
- if the key is not available
-
-