Class AbstractDataStore

    • Field Detail

      • DIGEST

        protected String DIGEST
        The digest algorithm used to uniquely identify records.
    • Constructor Detail

      • AbstractDataStore

        public AbstractDataStore()
    • 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 interface DataStore
        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. Returns null if the reference is invalid, for example if it points to a record that does not exist.
        Specified by:
        getRecordFromReference in interface DataStore
        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