Class DoubleEncoding
- All Implemented Interfaces:
Encoding<Double>
,NaturalSortAware
,Serializable
,Comparator<Double>
Double
type.- 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 Double
convertNumber
(Number value) Get the fixed width of this encoding, if any.boolean
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.Verify the given object is a valid instance of thisEncoding
's Java type and cast it to that type.void
write
(ByteWriter writer, Double value) Write a value to the given output.Methods inherited from class io.permazen.encoding.PrimitiveEncoding
compare, convert, equals, fromString, hashCode, sortsNaturally, supportsNull, toString
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, validateAndWrite
-
Constructor Details
-
DoubleEncoding
-
-
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 outputvalue
- 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
-
validate
Description copied from interface:Encoding
Verify the given object is a valid instance of thisEncoding
's Java type and cast it to that type.Note that this method must throw
IllegalArgumentException
, notClassCastException
orNullPointerException
, ifobj
does not have the correct type, or is an unsupported value - including null if null is not supported.This method is allowed to perform widening conversions of the object that lose no information, e.g., from
Integer
toLong
.The implementation in
Encoding
first verifies the value is not null if this instance does not allow null values, and then attempts to cast the value using this instance's raw Java type. Subclasses should override this method to implement any other restrictions. -
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
-
getFixedWidth
Description copied from interface:Encoding
Get the fixed width of this encoding, if any.Some encodings encode every value into the same number of bytes. For such encodings, this method returns that number. For variable width encodings, this method must return empty.
- Returns:
- the number of bytes of every encoded value, or empty if the encoding length varies
-
convertNumber
- Specified by:
convertNumber
in classPrimitiveEncoding<Double>
-