Package io.permazen.encoding
Class BooleanEncoding
- All Implemented Interfaces:
Encoding<Boolean>
,NaturalSortAware
,Serializable
,Comparator<Boolean>
- 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 Boolean
convertNumber
(Number value) 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.withEncodingId
(EncodingId encodingId) Build an encoding that has the givenEncodingId
but is otherwise equivalent to this encoding.void
write
(ByteWriter writer, Boolean value) Write a value to the given output.Methods inherited from class io.permazen.encoding.PrimitiveEncoding
compare, convert, equals, fromString, hashCode, sortsNaturally, toString, validate
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, supportsNull, validateAndWrite
-
Constructor Details
-
BooleanEncoding
-
-
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
-
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.
The implementation in
Encoding
returnstrue
.- Returns:
- true if an encoded value starting with
0xff
exists
-
convertNumber
- Specified by:
convertNumber
in classPrimitiveEncoding<Boolean>
-