binary-streams / loggersoft.kotlin.streams / ProxyStreamInput

ProxyStreamInput

@ExperimentalUnsignedTypes class ProxyStreamInput : StreamInput

Provides StreamInput interface from Stream.

Author
Alexander Kornilov (akornilov.82@gmail.com).

Constructors

<init>

Provides StreamInput interface from Stream.

ProxyStreamInput(stream: Stream)

Properties

bytesAvailable

Contains available bytes for read/write and the negative value if available bytes is not available at moment. Also this property take into account limit value if it has non-negative value and isSupportLimit is true.

val bytesAvailable: Long

canFetchMore

Optional hint for fetch ability (may be useful for streams where size isn't available).

val canFetchMore: FetchHint

defaultByteOrder

Default byte order of the stream.

val defaultByteOrder: ByteOrder

defaultStringEncoding

Default string encoding of the stream.

val defaultStringEncoding: StringEncoding

isClosed

Indicate that stream is closed.

val isClosed: Boolean

isEof

Indicates that end of stream reached.

val isEof: Boolean

isFixedSize

Indicates that stream has fixed size.

val isFixedSize: Boolean

isNetwork

Indicates that stream is network based (pipe, socket etc).

val isNetwork: Boolean

isSeekable

Indicates that position of the stream can be changed.

val isSeekable: Boolean

isSupportLimit

Indicates that stream support validation of the limit field.

val isSupportLimit: Boolean

limit

The limit position of the stream for read and write. If someone try to read or write out of this bound (position >= limit) the LimitOutOfBoundsException should be thrown.

val limit: Long

position

Current position in the stream. Has negative value if seek is not supported or information about current position is not available at moment.

val position: Long

size

Current stream size in bytes or negative value if size isn't available at moment.

val size: Long

Functions

canRead

Returns true when stream can provide bytes.

fun canRead(bytes: Int): Boolean

close

fun close(): Unit

forLines

Calls the block callback giving it a sequence of all the lines in the stream.

fun forLines(encoding: StringEncoding, byteOrder: ByteOrder, block: (lines: Sequence<String>) -> Unit): Unit

readByte

Reads Byte from the stream.

fun readByte(): Byte

readBytes

Reads bytes size from the stream into the buffer starting from offset.

fun readBytes(buffer: ByteArray, size: Int, offset: Int): Int

readByteUnsigned

Reads unsigned Byte from the stream.

fun readByteUnsigned(): Int

readChar

Reads code point from the stream with specified encoding and byteOrder.

fun readChar(encoding: StringEncoding, byteOrder: ByteOrder): Int

readDouble

Reads Double from the stream with specified byteOrder.

fun readDouble(byteOrder: ByteOrder): Double

readFloat

Reads Float from the stream with specified byteOrder.

fun readFloat(byteOrder: ByteOrder): Float

readInt

Read integer value from the stream with specified bytes count and byteOrder. If signed is true the last bit interprets as a sign. This means that if last bit is 1 the rest of the bits higher than last bit would be filled by 1. The bytes should be in range 1..8.

fun readInt(bytes: Int, signed: Boolean, byteOrder: ByteOrder): Long

Reads Int from the stream with specified byteOrder.

fun readInt(byteOrder: ByteOrder): Int

readLine

Reads line from the stream with specified encoding and byteOrder.

fun readLine(encoding: StringEncoding, byteOrder: ByteOrder): String

readLong

Read integer value from the stream as BigInteger with specified bytes count and byteOrder. If signed is true the last bit interprets as a sign.

fun readLong(bytes: Int, signed: Boolean, byteOrder: ByteOrder): BigInteger

Reads Long from the stream with specified byteOrder.

fun readLong(byteOrder: ByteOrder): Long

readShort

Reads Short from the stream with specified byteOrder.

fun readShort(byteOrder: ByteOrder): Short

readString

Reads string from the stream with specified encoding, byteOrder and length limit.

fun readString(encoding: StringEncoding, length: Int, byteOrder: ByteOrder): String

readULong

Reads ULong from the stream with specified byteOrder.

fun readULong(byteOrder: ByteOrder): ULong

skip

Skips bytes in the stream.

fun skip(bytes: Long): Long

useLines

Calls the block callback giving it a sequence of all the lines in the stream and closes it once the processing is complete.

fun useLines(encoding: StringEncoding, byteOrder: ByteOrder, block: (lines: Sequence<String>) -> Unit): Unit

Extension Functions

crc16

Calculates CRC16 for size bytes in the stream.

fun StreamInput.crc16(size: Int): Int

crc32

Calculates CRC32 for size bytes in the stream.

fun StreamInput.crc32(size: Int): Int