binary-streams / loggersoft.kotlin.streams

Package loggersoft.kotlin.streams

Types

AbstractStream

This class is recommended as the base for any Stream implementations.

abstract class AbstractStream : Stream

BasicStream

Root interface of inheritance: contains the most generic properties of any stream.

interface BasicStream : Closeable, AutoCloseable

BinaryContext

Interface for objects which has binary representation (context) and can be serialized and deserialized through binary streams.

interface BinaryContext

BitStream

Bit access over Stream.

class BitStream : Closeable, AutoCloseable, Flushable

BufferedStreamInput

The decorator of StreamInput for buffering.

class BufferedStreamInput : StreamInput

BufferedStreamOutput

The decorator of StreamOutput for buffering.

class BufferedStreamOutput : StreamOutput

ByteArea

Represents area inside byte array buffer with specified offset and size.

open class ByteArea : ByteAreaBased, Iterable<Byte>

ByteAreaBased

Represents objects which based on binary data.

interface ByteAreaBased

ByteOrder

The byte order type.

enum class ByteOrder

ProxyStreamInput

Provides StreamInput interface from Stream.

class ProxyStreamInput : StreamInput

ProxyStreamOutput

Provides StreamOutput interface from Stream.

class ProxyStreamOutput : StreamOutput

Stream

Represents input and output stream.

interface Stream : StreamInput, StreamOutput

StreamAdapter

Provides Stream interface from Java InputStream and OutputStream.

class StreamAdapter : AbstractStream

StreamAdapterInput

Provides Stream interface from StreamInput.

class StreamAdapterInput : AbstractStream

StreamAdapterOutput

Provides Stream interface from StreamOutput.

class StreamAdapterOutput : AbstractStream

StreamByteArea

Implementation of the Stream for ByteArea (in fact for any ByteAreaBased objects).

class StreamByteArea : AbstractStream, ByteAreaBased

StreamFile

Implementation of Stream for random access file.

class StreamFile : AbstractStream

StreamInput

Represents streams for reading.

interface StreamInput : BasicStream

StreamOutput

Represents streams for writing.

interface StreamOutput : BasicStream, Flushable

StringEncoding

The string encoding type.

enum class StringEncoding

Exceptions

LimitOutOfBoundsException

Thrown when stream user read or write outside of current limit.

class LimitOutOfBoundsException : IOException

Extensions for External Classes

java.io.File

java.io.InputStream

java.io.OutputStream

java.math.BigInteger

kotlin.Byte

kotlin.ByteArray

kotlin.Int

kotlin.Long

kotlin.String

kotlin.ULong

Properties

BOM

The code point of BOM character.

const val BOM: Int

CRC16_START_VALUE

Default start value for CRC16.

const val CRC16_START_VALUE: Int

CRC32_START_VALUE

Default start value for CRC32.

const val CRC32_START_VALUE: Int

EOL

The code point of an end-of-line character.

const val EOL: Int

eolSkipChars

The immutable set of extra end-of-line characters for ignoring.

val eolSkipChars: Set<Int>

MaxUtf8CodePointSize

Maximum bytes count for any code point in UTF-8 encoding.

const val MaxUtf8CodePointSize: Int

nativeByteOrder

Current byte order for the native architecture.

val nativeByteOrder: ByteOrder

Functions

byteBitmask

Returns Byte's bit mask with specified bits count. If bits negative or greater than 8 -1 will be returned.

fun byteBitmask(bits: Int): Byte

crc16

Calculates CRC16 of ByteArea from offset with size starting from startValue.

fun ByteArea.crc16(startValue: Int = CRC16_START_VALUE, offset: Int = 0, size: Int = this.size - offset): Int

Calculates CRC16 for size bytes in the stream.

fun StreamInput.crc16(size: Int): Int

crc32

Calculates CRC32 of ByteArea from offset with size starting from startValue. If finalize is true returned value will be final (when data processed partially for the last block).

fun ByteArea.crc32(startValue: Int = CRC32_START_VALUE, finalize: Boolean = true, offset: Int = 0, size: Int = this.size - offset): Int

Calculates CRC32 for size bytes in the stream.

fun StreamInput.crc32(size: Int): Int

intBitmask

Returns Int's bit mask with specified bits count. If bits negative or greater than 32 -1 will be returned.

fun intBitmask(bits: Int): Int

longBitmask

Returns Long's bit mask with specified bits count. If bits negative or greater than 64 -1 will be returned.

fun longBitmask(bits: Int): Long

setLimit

Sets current stream position and limit. e.g. after setLimit(10, 5) the stream position will be 10 and limit 15.

fun Stream.setLimit(position: Long, limit: Long): Unit

tryDetectBom

Tries detect BOM signature in current position and if success updates Stream.defaultByteOrder and Stream.defaultStringEncoding.

fun Stream.tryDetectBom(): Boolean

validateUtf8Size

Validates the size of UTF-8 code point in bytes and if it is invalid throws CharacterCodingException.

fun validateUtf8Size(size: Int): Int