Config

abstract class Config(source)

Base configuration for an EncoderDecoder. More options may be specified by the implementation.

Constructors

Link copied to clipboard
protected constructor(isLenient: Boolean?, lineBreakInterval: Byte, lineBreakResetOnFlush: Boolean, paddingChar: Char?, maxDecodeEmit: Int, maxEncodeEmit: Int, backFillBuffers: Boolean)

Instantiates a new Config instance.

Types

Link copied to clipboard
object Companion
Link copied to clipboard
protected inner class Setting(name: String, val value: Any?)

Additional setting to Config, unique to the implementing class. Used in the toString output

Properties

Link copied to clipboard
@JvmField
val backFillBuffers: Boolean

When the functions Encoder.encodeToString, Encoder.encodeToCharArray, Encoder.encodeBuffered, Encoder.encodeBufferedAsync, Decoder.decodeBuffered, and Decoder.decodeBufferedAsync are utilized, they may allocate an appropriate medium (a buffer) to store encoded/decoded data (e.g. a StringBuilder, CharArray, or ByteArray). Depending on the underlying operation, such as an array over-allocation due to encodeOutMaxSize or decodeOutMaxSize, those initially allocated buffers may not be returned as the function's result. Prior versions of this library always back-filled them with 0 or the null character \u0000, but that can be computationally expensive for large datasets and potentially unnecessary if data is known to not be sensitive in nature.

Link copied to clipboard
@JvmField
val isLenient: Boolean?

If true, the characters ('\n', '\r', ' ', '\t') will be skipped over (i.e. allowed but ignored) during decoding operations. If false, a MalformedEncodingException will be thrown when those characters are encountered. If null, those characters are passed along to the Decoder.Feed implementation as input.

Link copied to clipboard
@JvmField
val lineBreakInterval: Byte

If greater than 0, Encoder.newEncoderFeed may use a LineBreakOutFeed such that for every lineBreakInterval number of encoded characters output by the Encoder.Feed, the next encoded character output will be preceded with a new line character \n.

Link copied to clipboard
@JvmField
val lineBreakResetOnFlush: Boolean

If and only if Encoder.newEncoderFeed wraps the Encoder.OutFeed passed to it with a LineBreakOutFeed, will this setting then be used for the LineBreakOutFeed.resetOnFlush parameter. If true and Encoder.newEncoderFeed wrapped its provided Encoder.OutFeed, then LineBreakOutFeed.reset will be called after every invocation of Encoder.Feed.flush.

Link copied to clipboard
@JvmField
val maxDecodeEmit: Int

The maximum number of bytes that the implementation's Decoder.Feed can potentially emit on a single invocation of Decoder.Feed.consume, Decoder.Feed.flush, or Decoder.Feed.doFinal.

Link copied to clipboard
@JvmField
val maxEncodeEmit: Int

The maximum number of characters that the implementation's Encoder.Feed can potentially emit on a single invocation of Encoder.Feed.consume, Encoder.Feed.flush, or Encoder.Feed.doFinal.

Link copied to clipboard
@JvmField
val maxEncodeEmitWithLineBreak: Int

The maximum number of characters that the Encoder.Feed produced by Encoder.newEncoderFeed can potentially emit on a single invocation of Encoder.Feed.consume, Encoder.Feed.flush, or Encoder.Feed.doFinal. This is the calculated result from Companion.calculateMaxEncodeEmit using maxEncodeEmit and lineBreakInterval as arguments.

Link copied to clipboard
@JvmField
val paddingChar: Char?

The character that is used when padding encoded output. This is used by Decoder.Feed to mark input as "completing" such that further non-padding input can be exceptionally rejected with a MalformedEncodingException. If the encoding specification does not use padding, null may be specified.

Functions

Link copied to clipboard
fun decodeOutMaxSize(encodedSize: Long): Long

Pre-calculates and returns the maximum size of the output, after decoding would occur, for input that is not yet known (i.e. cannot be wrapped in DecoderInput, such as the contents of a File where only the file size is known) based off of the Config options set for the implementation.

Link copied to clipboard

Pre-calculates and returns the maximum size of the output, after decoding would occur, for input that is known based off of the Config options set for the implementation.

Link copied to clipboard
protected abstract fun decodeOutMaxSizeOrFailProtected(encodedSize: Int, input: DecoderInput): Int

Calculate and return a maximum size that a decoding would be for the encodedSize data.

Link copied to clipboard
protected abstract fun decodeOutMaxSizeProtected(encodedSize: Long): Long

Calculate and return a maximum size that a decoding would be for the encodedSize data.

Link copied to clipboard
inline fun encodeOutMaxSize(unEncodedSize: Int): Int
fun encodeOutMaxSize(unEncodedSize: Long): Long
fun encodeOutMaxSize(unEncodedSize: Int, lineBreakInterval: Byte): Int
fun encodeOutMaxSize(unEncodedSize: Long, lineBreakInterval: Byte): Long

Pre-calculates and returns the maximum size of the output, after encoding would occur, based off the Config options set for the implementation. Most implementations, such as Base16, Base32, and Base64, are able to return an exact size whereby no post-encoding resize is necessary, while others, such as UTF-8 byte to text transformations, return a maximum and may require a post-encoding resize.

Link copied to clipboard
protected abstract fun encodeOutSizeProtected(unEncodedSize: Long): Long

Calculate and return an exact (preferably), or maximum, size that an encoding would be for the unEncodedSize data.

Link copied to clipboard
protected abstract fun toStringAddSettings(): Set<EncoderDecoder.Config.Setting>

Will be called whenever toString is invoked, allowing inheritors of Config to add their settings to the output.