Package io.permazen.encoding
Class ObjectArrayEncoding<E>
java.lang.Object
io.permazen.encoding.AbstractEncoding<T>
io.permazen.encoding.ArrayEncoding<E[],E>
io.permazen.encoding.ObjectArrayEncoding<E>
- Type Parameters:
E
- array element type
- All Implemented Interfaces:
Encoding<E[]>
,NaturalSortAware
,Serializable
,Comparator<E[]>
Array type for object arrays having non-primitive element types. Does not support null arrays.
In the binary encoding, array elements are simply concatenated, with each element preceded by a 0x01
byte.
After the last element, a final 0x00
byte follows. This encoding ensures lexicographic ordering.
- 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
-
Method Summary
Modifier and TypeMethodDescriptionprotected E[]
createArray
(List<E> elements) Create a new array instance containing the given elements.protected E
getArrayElement
(E[] array, int index) Get an element from the given array.protected int
getArrayLength
(E[] array) Get the length of the given array.E[]
read
(ByteReader reader) Read a value from the given input.void
skip
(ByteReader reader) Read and discard abyte[]
encoded value from the given input.withEncodingId
(EncodingId encodingId) Build an encoding that has the givenEncodingId
but is otherwise equivalent to this encoding.void
write
(ByteWriter writer, E[] array) Write a value to the given output.Methods inherited from class io.permazen.encoding.ArrayEncoding
compare, convert, equals, fromArrayString, fromString, getElementEncoding, hashCode, toArrayString, toString
Methods inherited from class io.permazen.encoding.AbstractEncoding
getDefaultValueObject, 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, getDefaultValue, getKeyRange, hasPrefix0x00, hasPrefix0xff, sortsNaturally, supportsNull, validate, validateAndWrite
-
Constructor Details
-
ObjectArrayEncoding
-
-
Method Details
-
withEncodingId
Description copied from interface:Encoding
Build an encoding that has the givenEncodingId
but is otherwise equivalent to this encoding.If this encoding already has
encodingId
, then this method may (but is not required to) return this same instance.- Parameters:
encodingId
- new encoding'sEncodingId
, or null for an anonymized encoding- Returns:
- a version of this encoding with the given
EncodingId
-
read
Description copied from interface:Encoding
Read a value from the given input.- Parameters:
reader
- byte input- Returns:
- field value (possibly null)
-
write
Description copied from interface:Encoding
Write a value to the given output.- Parameters:
writer
- byte outputarray
- value to write (possibly null)
-
skip
Description copied from interface:Encoding
Read and discard abyte[]
encoded value from the given input.- Parameters:
reader
- byte input
-
getArrayLength
Description copied from class:ArrayEncoding
Get the length of the given array.- Specified by:
getArrayLength
in classArrayEncoding<E[],
E> - Parameters:
array
- non-null array- Returns:
- array length
-
getArrayElement
Description copied from class:ArrayEncoding
Get an element from the given array.- Specified by:
getArrayElement
in classArrayEncoding<E[],
E> - Parameters:
array
- non-null arrayindex
- index of target element inarray
- Returns:
- array element at index
index
-
createArray
Description copied from class:ArrayEncoding
Create a new array instance containing the given elements.- Specified by:
createArray
in classArrayEncoding<E[],
E> - Parameters:
elements
- content for the new array- Returns:
- newly created array
-