Package io.permazen.encoding
Class FloatEncoding
- All Implemented Interfaces:
Encoding<Float>
,NaturalSortAware
,Serializable
,Comparator<Float>
Float
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 Float
convertNumber
(Number value) 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.withEncodingId
(EncodingId encodingId) Build an encoding that has the givenEncodingId
but is otherwise equivalent to this encoding.void
write
(ByteWriter writer, Float value) Write a value to the given output.Methods inherited from class io.permazen.encoding.PrimitiveEncoding
compare, convert, equals, fromString, hashCode, sortsNaturally, 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, supportsNull, validateAndWrite
-
Constructor Details
-
FloatEncoding
-
-
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 outputvalue
- 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
-
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. -
convertNumber
- Specified by:
convertNumber
in classPrimitiveEncoding<Float>
-