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
Modifier and TypeFieldDescriptionstatic final Preferences
Root preference node for use byPreferenceCoder
. -
Constructor Summary
ConstructorDescriptionPreferencesEncoder
(String node) Creates an instance of an encoder which can be used to serializeEncodable
classes to Java'sPreferences
-
Method Summary
Modifier and TypeMethodDescriptionRetrieve an instance of aKeyedEncodingContainer
to be used to encode keyed datavoid
Encode aBoolean
value into a specified keyvoid
Encode anInteger
value into a specified keyvoid
Encode aString
value into a specified keyencode
(E encoding) Encode the provided instance of anEncodable
class.
-
Field Details
-
rootNode
Root preference node for use byPreferenceCoder
.
-
-
Constructor Details
-
PreferencesEncoder
Creates an instance of an encoder which can be used to serializeEncodable
classes to Java'sPreferences
- Parameters:
node
- Path ofPreferences
node to write values to
-
-
Method Details
-
encode
Encode the provided instance of anEncodable
class.- Type Parameters:
E
- Type of theEncodable
class- Parameters:
encoding
- Instance of anEncodable
class- Throws:
EncodingException
- If encoding failed for whatever reason
-
container
Description copied from interface:Encoder
Retrieve an instance of aKeyedEncodingContainer
to be used to encode keyed data -
encode
Description copied from interface:KeyedEncodingContainer
Encode anInteger
value into a specified key- Specified by:
encode
in interfaceKeyedEncodingContainer<T extends Enum<T>>
- Parameters:
value
- Value to encodeforKey
- Key to encode value into
-
encode
Description copied from interface:KeyedEncodingContainer
Encode aBoolean
value into a specified key- Specified by:
encode
in interfaceKeyedEncodingContainer<T extends Enum<T>>
- Parameters:
value
- Value to encodeforKey
- Key to encode value into
-
encode
Description copied from interface:KeyedEncodingContainer
Encode aString
value into a specified key- Specified by:
encode
in interfaceKeyedEncodingContainer<T extends Enum<T>>
- Parameters:
value
- Value to encodeforKey
- Key to encode value into
-