Module com.cryptoalgo.oursql.oursql
Class PreferencesEncoder<T extends Enum<T>>
java.lang.Object
com.cryptoalgo.codable.preferencesCoder.PreferencesEncoder<T>
- Type Parameters:
T- Type of enum of codingKeys to be used during encoding
- All Implemented Interfaces:
Encoder<T>,KeyedEncodingContainer<T>
public final class PreferencesEncoder<T extends Enum<T>>
extends Object
implements Encoder<T>, KeyedEncodingContainer<T>
Built-in encoder implementation which writes data to non-volatile
storage through Java's Preferences module.
Implications: Limitations to Java's Preferences module also apply here, most notably that large amounts of data shouldn't be written to nodes. Doing so leads to significant performance penalties and might cause OOM errors when attempting to retrieve those keys.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PreferencesRoot preference node for use byPreferenceCoder. -
Constructor Summary
ConstructorsConstructorDescriptionPreferencesEncoder(String node) Creates an instance of an encoder which can be used to serializeEncodableclasses to Java'sPreferences -
Method Summary
Modifier and TypeMethodDescriptionRetrieve an instance of aKeyedEncodingContainerto be used to encode keyed datavoidEncode aBooleanvalue into a specified keyvoidEncode anIntegervalue into a specified keyvoidEncode aStringvalue into a specified keyencode(E encoding) Encode the provided instance of anEncodableclass.
-
Field Details
-
rootNode
Root preference node for use byPreferenceCoder.
-
-
Constructor Details
-
PreferencesEncoder
Creates an instance of an encoder which can be used to serializeEncodableclasses to Java'sPreferences- Parameters:
node- Path ofPreferencesnode to write values to
-
-
Method Details
-
encode
Encode the provided instance of anEncodableclass.- Type Parameters:
E- Type of theEncodableclass- Parameters:
encoding- Instance of anEncodableclass- Throws:
EncodingException- If encoding failed for whatever reason
-
container
Description copied from interface:EncoderRetrieve an instance of aKeyedEncodingContainerto be used to encode keyed data -
encode
Description copied from interface:KeyedEncodingContainerEncode anIntegervalue into a specified key- Specified by:
encodein interfaceKeyedEncodingContainer<T extends Enum<T>>- Parameters:
value- Value to encodeforKey- Key to encode value into
-
encode
Description copied from interface:KeyedEncodingContainerEncode aBooleanvalue into a specified key- Specified by:
encodein interfaceKeyedEncodingContainer<T extends Enum<T>>- Parameters:
value- Value to encodeforKey- Key to encode value into
-
encode
Description copied from interface:KeyedEncodingContainerEncode aStringvalue into a specified key- Specified by:
encodein interfaceKeyedEncodingContainer<T extends Enum<T>>- Parameters:
value- Value to encodeforKey- Key to encode value into
-