Package io.permazen.encoding
Class Base64ArrayEncoding<T,E>
java.lang.Object
io.permazen.encoding.AbstractEncoding<T>
io.permazen.encoding.ArrayEncoding<T,E>
io.permazen.encoding.Base64ArrayEncoding<T,E>
- Type Parameters:
T
- array typeE
- array element type
- All Implemented Interfaces:
Encoding<T>
,NaturalSortAware
,Serializable
,Comparator<T>
- Direct Known Subclasses:
DoubleArrayEncoding
,FloatArrayEncoding
,IntegralArrayEncoding
Adds support for an alternate Base-64
String
encoding for non-null primitive array types.
Null values are not supported by this class and there is no default value.
- See Also:
-
Field Summary
Fields inherited from class io.permazen.encoding.AbstractEncoding
encodingId, typeToken
Fields inherited from interface io.permazen.encoding.Encoding
MAX_ARRAY_DIMENSIONS
-
Constructor Summary
ModifierConstructorDescriptionprotected
Base64ArrayEncoding
(PrimitiveEncoding<E> elementEncoding, TypeToken<T> typeToken) -
Method Summary
Modifier and TypeMethodDescriptionprotected T
checkDecodeLength
(int numBytes) protected abstract T
decode
(DataInputStream input, int numBytes) protected abstract void
encode
(T array, DataOutputStream output) fromString
(String string) Parse a non-null value previously encoded bytoString(T)
.Encode a non-null value as aString
for later decoding byfromString()
.Encode a non-null value as aString
for later decoding byfromString()
.protected boolean
useBase64Encoding
(T array) Invoked bytoString(T)
to determine whether to encode using base 64 or not.Methods inherited from class io.permazen.encoding.ArrayEncoding
compare, convert, createArray, equals, fromArrayString, getArrayElement, getArrayLength, getElementEncoding, getFixedWidth, hashCode, sortsNaturally, supportsNull, toArrayString
Methods inherited from class io.permazen.encoding.AbstractEncoding
getDefaultValue, getDefaultValueBytes, getEncodingId, getTypeToken, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
Methods inherited from interface io.permazen.encoding.Encoding
decode, encode, getKeyRange, hasPrefix0x00, hasPrefix0xff, read, skip, validate, validateAndWrite, write
-
Constructor Details
-
Base64ArrayEncoding
-
-
Method Details
-
fromString
Description copied from interface:Encoding
Parse a non-null value previously encoded bytoString(T)
.- Specified by:
fromString
in interfaceEncoding<T>
- Overrides:
fromString
in classArrayEncoding<T,
E> - Parameters:
string
- non-null value previously encoded as aString
bytoString(T)
- Returns:
- actual value
-
toString
Description copied from interface:Encoding
Encode a non-null value as aString
for later decoding byfromString()
.Each of the characters in the returned
String
, when decoded as 32-bit Unicode codepoints, must contain only valid XML characters (seeXMLUtil.isValidChar(int)
).- Specified by:
toString
in interfaceEncoding<T>
- Overrides:
toString
in classArrayEncoding<T,
E> - Parameters:
array
- actual value, never null- Returns:
- string encoding of
value
acceptable tofromString()
- See Also:
-
toString
Encode a non-null value as aString
for later decoding byfromString()
.- Parameters:
array
- array to encodebase64
- true for base 64 synax, false for standard syntax- Returns:
- string encoding of
value
acceptable tofromString()
- Throws:
IllegalArgumentException
- ifvalue
is null
-
useBase64Encoding
Invoked bytoString(T)
to determine whether to encode using base 64 or not.The implementation in
Base64ArrayEncoding
rerturns true for arrays longer than 16 elements.- Parameters:
array
- array to be encoded, never null- Returns:
- true for base 64 encoding, otherwise false
-
encode
- Throws:
IOException
-
decode
- Throws:
IOException
-
checkDecodeLength
-