Class BulkDataAccessorBase<T>
java.lang.Object
org.tquadrat.foundation.config.spi.prefs.PreferenceAccessor<T>
org.tquadrat.foundation.config.spi.prefs.BulkDataAccessorBase<T>
- Type Parameters:
T- The type of the property.
- Direct Known Subclasses:
ImageAccessor,SimpleBulkDataAccessor
@ClassVersion(sourceVersion="$Id: BulkDataAccessorBase.java 942 2021-12-20 02:04:04Z tquadrat $")
@API(status=STABLE,
since="0.0.1")
public abstract class BulkDataAccessorBase<T>
extends PreferenceAccessor<T>
The abstract base class for an implementation of
PreferenceAccessor
for bulk data.
The method
Preferences.put()
limits the length for a value String to
8192. If more data should be stored, the
method
Preferences.putByteArray()
can be used.
- Author:
- Thomas Thrien (thomas.thrien@tquadrat.org)
- Version:
- $Id: BulkDataAccessorBase.java 942 2021-12-20 02:04:04Z tquadrat $
- Since:
- 0.0.1
- UML Diagram
-
UML Diagram for "org.tquadrat.foundation.config.spi.prefs.BulkDataAccessorBase"
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract TfromByteArray(Preferences node, byte[] source) Converts the givenbytearray to an instance of the property type.voidreadPreference(Preferences node) Reads the preference value from the given node and writes it to the property.protected abstract byte[]toByteArray(Preferences node, T source) Converts the given instance of the property type into abytearray.voidwritePreference(Preferences node) Writes the preference value from the property and writes it to the given node.Methods inherited from class org.tquadrat.foundation.config.spi.prefs.PreferenceAccessor
getPropertyName, getter, hasKey, setter
-
Constructor Details
-
BulkDataAccessorBase
Creates a newBulkDataAccessorBaseinstance.- Parameters:
propertyName- The name of the property.getter- The property getter.setter- The property setter.
-
-
Method Details
-
fromByteArray
protected abstract T fromByteArray(Preferences node, byte[] source) throws InvalidPreferenceValueException Converts the givenbytearray to an instance of the property type.- Parameters:
node- The reference to thePreferencesnode that provides the value.source- The byte array; can benull.- Returns:
- The instance, or
nullif the source was alreadynull. - Throws:
InvalidPreferenceValueException- The preferences value cannot be translated to the property type.
-
readPreference
public void readPreference(Preferences node) throws BackingStoreException, InvalidPreferenceValueException Reads the preference value from the given node and writes it to the property.- Specified by:
readPreferencein classPreferenceAccessor<T>- Parameters:
node- The preference node.- Throws:
BackingStoreException- There are problems on reading the given node.InvalidPreferenceValueException- The preferences value cannot be translated to the property type.
-
toByteArray
protected abstract byte[] toByteArray(Preferences node, T source) throws InvalidPreferenceValueException Converts the given instance of the property type into abytearray.- Parameters:
node- The reference to thePreferencesnode that is used to store the preferences value.source- The instance; can benull.- Returns:
- The
bytearray, ornullif the source was alreadynull. - Throws:
InvalidPreferenceValueException- The conversion failed to abytearray failed.
-
writePreference
Writes the preference value from the property and writes it to the given node.- Specified by:
writePreferencein classPreferenceAccessor<T>- Parameters:
node- The preference node.- Throws:
BackingStoreException- There are problems on writing the given node.
-
