loggersoft.kotlin.streams.ProxyStreamInput.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of binary-streams Show documentation
Show all versions of binary-streams Show documentation
Implementation of I/O binary streams for Kotlin.
/*
* Copyright (C) 2018 Alexander Kornilov ([email protected])
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package loggersoft.kotlin.streams
import java.math.BigInteger
/**
* Provides [StreamInput] interface from [Stream].
*
* @author Alexander Kornilov ([email protected]).
*/
class ProxyStreamInput(private val stream: Stream) : StreamInput {
override val isNetwork: Boolean
get() = stream.isNetwork
override val canFetchMore
get() = stream.canFetchMore
override val bytesAvailable
get() = stream.bytesAvailable
override val isEof
get() = stream.isEof
override val isClosed
get() = stream.isClosed
override val isSeekable
get() = stream.isSeekable
override val isFixedSize
get() = stream.isFixedSize
override val isSupportLimit
get() = stream.isSupportLimit
override val position
get() = stream.position
override val limit
get() = stream.limit
override val size
get() = stream.size
override val defaultByteOrder
get() = stream.defaultByteOrder
override val defaultStringEncoding
get() = stream.defaultStringEncoding
override fun skip(bytes: Long): Long = stream.skip(bytes)
override fun readBytes(buffer: ByteArray, size: Int, offset: Int): Int
= stream.readBytes(buffer, size, offset)
override fun readByte(): Byte = stream.readByte()
override fun readByteUnsigned(): Int = stream.readByteUnsigned()
override fun readInt(bytes: Int, signed: Boolean, byteOrder: ByteOrder): Long
= stream.readInt(bytes, signed, byteOrder)
override fun readLong(bytes: Int, signed: Boolean, byteOrder: ByteOrder): BigInteger
= stream.readLong(bytes, signed, byteOrder)
override fun canRead(bytes: Int): Boolean = stream.canRead(bytes)
override fun readShort(byteOrder: ByteOrder): Short = stream.readShort(byteOrder)
override fun readInt(byteOrder: ByteOrder): Int = stream.readInt(byteOrder)
override fun readLong(byteOrder: ByteOrder): Long = stream.readLong(byteOrder)
override fun readFloat(byteOrder: ByteOrder): Float = stream.readFloat(byteOrder)
override fun readDouble(byteOrder: ByteOrder): Double = stream.readDouble(byteOrder)
override fun readChar(encoding: StringEncoding, byteOrder: ByteOrder): Int = stream.readChar(encoding, byteOrder)
override fun readString(encoding: StringEncoding, length: Int, byteOrder: ByteOrder): String
= stream.readString(encoding, length, byteOrder)
override fun readLine(encoding: StringEncoding, byteOrder: ByteOrder): String
= stream.readLine(encoding, byteOrder)
override fun forLines(encoding: StringEncoding, byteOrder: ByteOrder, block: (lines: Sequence) -> Unit)
= stream.forLines(encoding, byteOrder, block)
override fun useLines(encoding: StringEncoding, byteOrder: ByteOrder, block: (lines: Sequence) -> Unit)
= stream.useLines(encoding, byteOrder, block)
/**
* @see java.io.Closeable.close
*/
override fun close() = stream.close()
}