Codec

Codec

Specifies the expected API interface for an encoding tool, which is capable of encoding data to a given format or expression, as well as decoding from that same format.

Parameters

Raw

Value class which wraps values produced by this encoder.

See also

for the interface each encoded-data record complies with.

for the interface description for decoding.

for the interface description for encoding.

Inheritors

Functions

Link copied to clipboard
open fun decode(data: Raw): ByteArray

Decode the provided raw data from the encoding implemented by this encoder; return a raw ByteArray of the resulting data.

Link copied to clipboard
abstract fun decodeBytes(data: ByteArray): ByteArray

Decode the provided data from the encoding implemented by this encoder; return a raw ByteArray of the resulting bytes.

Link copied to clipboard
open fun decoder(): Decoder<Raw>

Provide an Encoder specialized to the format implemented by this Codec; the resulting object can only guarantee a capability to encode data to the target encoding.

Link copied to clipboard
open fun decodeString(string: String): ByteArray

Decode the provided string using the encoding implemented by this encoder; return a raw ByteArray of the resulting bytes.

Link copied to clipboard

Decode the provided data from the encoding implemented by this encoder; return a String representation of the resulting data.

open fun decodeToString(string: String): String

Decode the provided string from the encoding implemented by this encoder; return a String representation of the resulting data.

Link copied to clipboard
abstract fun encode(data: ByteArray): Raw

Encoded the provided data using the encoding implemented by this encoder; the returned Raw instance is able to provide a resulting ByteArray or String.

Link copied to clipboard

Encode the provided data using the encoding implemented by this encoder; return a ByteArray representation of the result.

Link copied to clipboard
open fun encoder(): Encoder<Raw>

Provide a Decoder specialized to the format implemented by this Codec; the resulting object can only guarantee a capability to decode data from the subject encoding.

Link copied to clipboard
open fun encodeString(string: String): ByteArray

Encode the provided string data using the encoding implemented by this encoder; by default, the string will be interpreted using UTF-8 encoding, then encoded to the target encoding.

Link copied to clipboard

Encode the provided data to a string representation using the encoding implemented by this encoder.

open fun encodeToString(string: String): String

Encode the provided string to a string representation using the encoding implemented by this encoder; the string is interpreted using UTF-8 encoding.

Link copied to clipboard
abstract fun encoding(): Encoding

Return the enumerated Encoding which is implemented by this Codec.