Package io.permazen.encoding
Class DoubleArrayEncoding
java.lang.Object
io.permazen.encoding.AbstractEncoding<T>
io.permazen.encoding.ArrayEncoding<T,E>
io.permazen.encoding.Base64ArrayEncoding<double[],Double>
io.permazen.encoding.DoubleArrayEncoding
- All Implemented Interfaces:
Encoding<double[]>,NaturalSortAware,Serializable,Comparator<double[]>
Non-null
double[] array type.
Null values are not supported by this class and there is no default value.
Array elements are encoded using DoubleEncoding, and the array is terminated by 0x0000000000000000L,
which is an encoded value that can never be emitted by DoubleEncoding.
- See Also:
-
Field Summary
Fields inherited from class io.permazen.encoding.AbstractEncoding
encodingId, typeTokenFields inherited from interface io.permazen.encoding.Encoding
MAX_ARRAY_DIMENSIONS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected double[]createArray(List<Double> elements) Create a new array instance containing the given elements.protected double[]decode(DataInputStream input, int numBytes) protected voidencode(double[] array, DataOutputStream output) protected DoublegetArrayElement(double[] array, int index) Get an element from the given array.protected intgetArrayLength(double[] array) Get the length of the given array.booleanDetermine whether any of this encoding's encoded values start with a0x00byte.booleanDetermine whether any of this encoding's encoded values start with a0xffbyte.double[]read(ByteData.Reader reader) Read a value from the given input.voidskip(ByteData.Reader reader) Read and discard an encoded value from the given input.voidwrite(ByteData.Writer writer, double[] array) Write a value to the given output.Methods inherited from class io.permazen.encoding.Base64ArrayEncoding
checkDecodeLength, fromString, toString, toString, useBase64EncodingMethods inherited from class io.permazen.encoding.ArrayEncoding
compare, convert, equals, fromArrayString, getElementEncoding, getFixedWidth, hashCode, sortsNaturally, supportsNull, toArrayStringMethods inherited from class io.permazen.encoding.AbstractEncoding
getDefaultValue, getDefaultValueBytes, getEncodingId, getTypeToken, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLongMethods inherited from interface io.permazen.encoding.Encoding
decode, encode, validate, validateAndWrite
-
Constructor Details
-
DoubleArrayEncoding
public DoubleArrayEncoding()
-
-
Method Details
-
read
Description copied from interface:EncodingRead a value from the given input.- Parameters:
reader- byte input- Returns:
- decoded value (possibly null)
-
write
Description copied from interface:EncodingWrite a value to the given output.- Parameters:
writer- byte outputarray- value to write (possibly null)
-
skip
Description copied from interface:EncodingRead and discard an 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:EncodingDetermine whether any of this encoding's encoded values start with a0x00byte. 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
0x00exists
-
hasPrefix0xff
public boolean hasPrefix0xff()Description copied from interface:EncodingDetermine whether any of this encoding's encoded values start with a0xffbyte. 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
0xffexists
-
getArrayLength
protected int getArrayLength(double[] array) Description copied from class:ArrayEncodingGet the length of the given array.- Specified by:
getArrayLengthin classArrayEncoding<double[],Double> - Parameters:
array- non-null array- Returns:
- array length
-
getArrayElement
Description copied from class:ArrayEncodingGet an element from the given array.- Specified by:
getArrayElementin classArrayEncoding<double[],Double> - Parameters:
array- non-null arrayindex- index of target element inarray- Returns:
- array element at index
index
-
createArray
Description copied from class:ArrayEncodingCreate a new array instance containing the given elements.- Specified by:
createArrayin classArrayEncoding<double[],Double> - Parameters:
elements- content for the new array- Returns:
- newly created array
-
encode
- Specified by:
encodein classBase64ArrayEncoding<double[],Double> - Throws:
IOException
-
decode
- Specified by:
decodein classBase64ArrayEncoding<double[],Double> - Throws:
IOException
-