calculateMaxEncodeEmit

@JvmStatic
fun calculateMaxEncodeEmit(emitSize: Int, insertionInterval: Int): Int(source)

Calculates and returns the maximum character emission size, given some sort of emitSize and desire to insert characters every insertionInterval. The way things are calculated are based on how lineBreakInterval operates, whereby if insertionInterval encoded characters have been output, the next encoded character output will be preceded with some arbitrary character (such as a hyphen for Base32.Crockford, which uses this function to calculate its final maxEncodeEmit value passed to the Config constructor).

NOTE: Implementors of Config utilizing this to calculate their maxEncodeEmit values must consider that it may return a value greater than 255, depending on the input arguments, resulting in an IllegalArgumentException when passed into the Config constructor. For example, an insertionInterval of 1 will inflate the provided emitSize by 2x.

Return

The calculated emission size for a provided character insertionInterval, or emitSize itself if insertionInterval is less than 1.

Parameters

emitSize

The number of characters that are expected to be emitted.

insertionInterval

The interval at which 1 character is to be inserted.

See also

Throws

IllegalArgumentException

If emitSize is less than 1 or greater than 255.