Package-level declarations

This package contains the Fixed LengthFile Format.

Usage

John Doe  

To decode from the given Fixed-Length string you need to apply @FixedLength(length = n):

@Serializable
data class Names(
@FixedLength(5) val firstName: String,
@FixedLength(5) val lastName: String
)

FixedLengthFormat.decodeFromString(Names.serializer(), flf)

And to encode:

FixedLengthFormat.encodeToString(Names.serializer(), Names("John", "Doe"))

"""
John Doe
"""

Limitations

  • The order of the properties of the class must match the order of the fields!

  • All whitespaces are trimmed.

  • Because this format does not have any delimiters, there is no check, if a given length is too long and consumes the next value.

  • Because this format does not have any delimiters, it is not possible to decode/encode primitives. You must use a class with @FixedLength annotated properties.

  • Inner lists are not supported, eg. data class NotSupported(val innerList: List<String>)

This package contains the Fixed LengthFile Format.

Usage

John Doe  

To decode from the given Fixed-Length string you need to apply @FixedLength(length = n):

@Serializable
data class Names(
@FixedLength(5) val firstName: String,
@FixedLength(5) val lastName: String
)

FixedLengthFormat.decodeFromString(Names.serializer(), flf)

And to encode:

FixedLengthFormat.encodeToString(Names.serializer(), Names("John", "Doe"))

"""
John Doe
"""

Limitations

  • The order of the properties of the class must match the order of the fields!

  • All whitespaces are trimmed.

  • Because this format does not have any delimiters, there is no check, if a given length is too long and consumes the next value.

  • Because this format does not have any delimiters, it is not possible to decode/encode primitives. You must use a class with @FixedLength annotated properties.

  • Inner lists are not supported, eg. data class NotSupported(val innerList: List<String>)

Types

Functions

Link copied to clipboard
fun <T> Appendable.append(serializer: SerializationStrategy<T>, value: T, format: FixedLengthFormat = FixedLengthFormat)
Link copied to clipboard
fun Sequence<String>.appendLines(file: File, charset: Charset = Charsets.UTF_8, lineSeparator: String = "")
Link copied to clipboard
fun <T> Sequence<String>.decode(deserializationStrategy: DeserializationStrategy<T>, format: FixedLengthFormat = FixedLengthFormat): Sequence<T>
Link copied to clipboard
fun <T> Sequence<T>.encode(serializationStrategy: SerializationStrategy<T>, format: FixedLengthFormat = FixedLengthFormat): Sequence<String>
Link copied to clipboard
fun Sequence<String>.writeLines(file: File, charset: Charset = Charsets.UTF_8, lineSeparator: String = "")