Package io.bytestreams.codec.core
Class BooleanCodec
java.lang.Object
io.bytestreams.codec.core.BooleanCodec
A codec for boolean values encoded as a single byte.
Encodes false as 0x00 and true as 0x01. Decoding is strict:
any value other than 0x00 or 0x01 throws a CodecException.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondecode(InputStream input) Decodes a value from the input stream.encode(Boolean value, OutputStream output) Encodes the given value and writes it to the output stream.
-
Constructor Details
-
BooleanCodec
public BooleanCodec()
-
-
Method Details
-
encode
Description copied from interface:CodecEncodes the given value and writes it to the output stream.- Specified by:
encodein interfaceCodec<Boolean>- Parameters:
value- the value to encodeoutput- the output stream to write the encoded bytes to- Returns:
- the encode result containing logical count and bytes written
- Throws:
IOException- if an I/O error occurs during encoding
-
decode
Description copied from interface:CodecDecodes a value from the input stream.- Specified by:
decodein interfaceCodec<Boolean>- Parameters:
input- the input stream to read the encoded bytes from- Returns:
- the decoded value
- Throws:
IOException- if an I/O error occurs during decoding
-