Class IntegralArrayEncoding<T,E extends Number>
- All Implemented Interfaces:
Encoding<T>
,NaturalSortAware
,Serializable
,Comparator<T>
- Direct Known Subclasses:
ByteArrayEncoding
,IntegerArrayEncoding
,LongArrayEncoding
,ShortArrayEncoding
Null values are not supported by this class and there is no default value.
Arrays are encoded as a sequence of numerical values followed by 0x00
, where each value is encoded via
LongEncoder
. Note, we take advantage of the fact that LongEncoder
does not emit values starting
with 0x00
.
- 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
IntegralArrayEncoding
(IntegralEncoding<E> elementEncoding, Class<T> arrayClass) -
Method Summary
Modifier and TypeMethodDescriptionboolean
Determine whether any of this encoding's encoded values start with a0x00
byte.boolean
Determine whether any of this encoding's encoded values start with a0xff
byte.read
(ByteReader reader) Read a value from the given input.void
skip
(ByteReader reader) Read and discard abyte[]
encoded value from the given input.void
write
(ByteWriter writer, T array) Write a value to the given output.Methods inherited from class io.permazen.encoding.Base64ArrayEncoding
checkDecodeLength, decode, encode, fromString, toString, toString, useBase64Encoding
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, validate, validateAndWrite
-
Constructor Details
-
IntegralArrayEncoding
-
-
Method Details
-
read
Description copied from interface:Encoding
Read a value from the given input.- Parameters:
reader
- byte input- Returns:
- decoded 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.If the value skipped over is invalid, this method may, but is not required to, throw
IllegalArgumentException
.If the value skipped over is truncated, this method must throw
IndexOutOfBoundsException
.- Parameters:
reader
- byte input
-
hasPrefix0x00
public boolean hasPrefix0x00()Description copied from interface:Encoding
Determine whether any of this encoding's encoded values start with a0x00
byte. Certain optimizations are possible when this is not the case. It is safe for this method to always return true.Note: changing the result of this method may result in an incompatible encoding if this encoding is wrapped in another class.
- Returns:
- true if an encoded value starting with
0x00
exists
-
hasPrefix0xff
public boolean hasPrefix0xff()Description copied from interface:Encoding
Determine whether any of this encoding's encoded values start with a0xff
byte. Certain optimizations are possible when this is not the case. It is safe for this method to always return true.Note: changing the result of this method may result in an incompatible encoding if this encoding is wrapped in another class.
- Returns:
- true if an encoded value starting with
0xff
exists
-