forked from StarOpenSource/Engine
Rename file streams to just streams
This commit is contained in:
parent
046ccea7b1
commit
b133f7e3a7
17 changed files with 102 additions and 102 deletions
|
@ -19,14 +19,14 @@
|
|||
|
||||
package de.staropensource.engine.base.exception.io
|
||||
|
||||
import de.staropensource.engine.base.implementable.stream.FileStream
|
||||
import de.staropensource.engine.base.implementable.stream.Stream
|
||||
|
||||
/**
|
||||
* Thrown when trying to
|
||||
* access a closed [FileStream].
|
||||
* access a closed [Stream].
|
||||
*
|
||||
* @see FileStream
|
||||
* @see FileStream.closed
|
||||
* @see Stream
|
||||
* @see Stream.closed
|
||||
* @since v1-alpha10
|
||||
*/
|
||||
class StreamClosedException(stream: FileStream) : RuntimeException("The file stream ${stream} was access whilst already closed")
|
||||
class StreamClosedException(stream: Stream) : RuntimeException("The stream ${stream} was accessed whilst already closed")
|
||||
|
|
|
@ -20,11 +20,11 @@
|
|||
package de.staropensource.engine.base.implementable.stream
|
||||
|
||||
/**
|
||||
* A read-only [FileStream].
|
||||
* A read-only [Stream].
|
||||
*
|
||||
* @since v1-alpha10
|
||||
*/
|
||||
abstract class ReadFileStream : FileStream(streamMode = StreamMode.READ) {
|
||||
override fun writeByte(byte: Byte): FileStream = this
|
||||
override fun writeBytes(bytes: ByteArray): FileStream = this
|
||||
abstract class ReadStream : Stream(streamMode = StreamMode.READ) {
|
||||
override fun writeByte(byte: Byte): Stream = this
|
||||
override fun writeBytes(bytes: ByteArray): Stream = this
|
||||
}
|
|
@ -21,7 +21,7 @@ package de.staropensource.engine.base.implementable.stream
|
|||
|
||||
import de.staropensource.engine.base.annotation.NonKotlinContact
|
||||
import de.staropensource.engine.base.exception.io.IOAccessException
|
||||
import de.staropensource.engine.base.implementation.stream.NullFileStream
|
||||
import de.staropensource.engine.base.implementation.stream.NullStream
|
||||
import java.io.IOException
|
||||
import java.io.InputStream
|
||||
import java.io.OutputStream
|
||||
|
@ -32,19 +32,19 @@ import java.io.OutputStream
|
|||
* @param streamMode supported [StreamMode]s
|
||||
* @since v1-alpha10
|
||||
*/
|
||||
abstract class FileStream(val streamMode: StreamMode) : AutoCloseable {
|
||||
abstract class Stream(val streamMode: StreamMode) : AutoCloseable {
|
||||
/**
|
||||
* Companion object of [FileStream].
|
||||
* Companion object of [Stream].
|
||||
*
|
||||
* @since v1-alpha10
|
||||
*/
|
||||
companion object {
|
||||
/**
|
||||
* Returns a [FileStream] which does nothing.
|
||||
* Returns a [Stream] which does nothing.
|
||||
*
|
||||
* @since v1-alpha10
|
||||
*/
|
||||
val nullStream: FileStream = NullFileStream.instance
|
||||
val nullStream: Stream = NullStream.instance
|
||||
}
|
||||
|
||||
|
||||
|
@ -59,7 +59,7 @@ abstract class FileStream(val streamMode: StreamMode) : AutoCloseable {
|
|||
|
||||
/**
|
||||
* Contains the [java.io.InputStream]
|
||||
* for this [FileStream] instance.
|
||||
* for this [Stream] instance.
|
||||
*
|
||||
* @since v1-alpha10
|
||||
*/
|
||||
|
@ -67,7 +67,7 @@ abstract class FileStream(val streamMode: StreamMode) : AutoCloseable {
|
|||
|
||||
/**
|
||||
* Contains the [java.io.OutputStream]
|
||||
* for this [FileStream] instance.
|
||||
* for this [Stream] instance.
|
||||
*
|
||||
* @since v1-alpha10
|
||||
*/
|
||||
|
@ -112,7 +112,7 @@ abstract class FileStream(val streamMode: StreamMode) : AutoCloseable {
|
|||
* for a single byte, just add this
|
||||
* line to your implementation instead:
|
||||
* ```kotlin
|
||||
* override fun writeByte(byte: Byte): FileStream = writeBytes(byteArrayOf(byte))
|
||||
* override fun writeByte(byte: Byte): Stream = writeBytes(byteArrayOf(byte))
|
||||
* ```
|
||||
*
|
||||
* @param byte [Byte] to write
|
||||
|
@ -121,7 +121,7 @@ abstract class FileStream(val streamMode: StreamMode) : AutoCloseable {
|
|||
* @since v1-alpha10
|
||||
*/
|
||||
@Throws(IOAccessException::class)
|
||||
abstract fun writeByte(byte: Byte): FileStream
|
||||
abstract fun writeByte(byte: Byte): Stream
|
||||
|
||||
/**
|
||||
* Writes (or rather: appends)
|
||||
|
@ -133,7 +133,7 @@ abstract class FileStream(val streamMode: StreamMode) : AutoCloseable {
|
|||
* @since v1-alpha10
|
||||
*/
|
||||
@Throws(IOAccessException::class)
|
||||
abstract fun writeBytes(bytes: ByteArray): FileStream
|
||||
abstract fun writeBytes(bytes: ByteArray): Stream
|
||||
|
||||
/**
|
||||
* Writes (or rather: appends)
|
||||
|
@ -145,7 +145,7 @@ abstract class FileStream(val streamMode: StreamMode) : AutoCloseable {
|
|||
* @since v1-alpha10
|
||||
*/
|
||||
@Throws(IOAccessException::class)
|
||||
fun writeString(string: String): FileStream = writeBytes(string.toByteArray())
|
||||
fun writeString(string: String): Stream = writeBytes(string.toByteArray())
|
||||
|
||||
/**
|
||||
* Writes (or rather: appends)
|
||||
|
@ -157,7 +157,7 @@ abstract class FileStream(val streamMode: StreamMode) : AutoCloseable {
|
|||
* @since v1-alpha10
|
||||
*/
|
||||
@Throws(IOAccessException::class)
|
||||
fun write(value: Any): FileStream = writeBytes(value.toString().toByteArray())
|
||||
fun write(value: Any): Stream = writeBytes(value.toString().toByteArray())
|
||||
|
||||
|
||||
// -----> Reading
|
||||
|
@ -230,7 +230,7 @@ abstract class FileStream(val streamMode: StreamMode) : AutoCloseable {
|
|||
* @since v1-alpha10
|
||||
*/
|
||||
@Throws(IOAccessException::class)
|
||||
fun skipNextByte(): FileStream {
|
||||
fun skipNextByte(): Stream {
|
||||
readNextByte()
|
||||
return this
|
||||
}
|
||||
|
@ -244,7 +244,7 @@ abstract class FileStream(val streamMode: StreamMode) : AutoCloseable {
|
|||
* @since v1-alpha10
|
||||
*/
|
||||
@Throws(IOAccessException::class)
|
||||
fun skipNBytes(n: UInt): FileStream {
|
||||
fun skipNBytes(n: UInt): Stream {
|
||||
readNBytes(n)
|
||||
return this
|
||||
}
|
||||
|
@ -257,7 +257,7 @@ abstract class FileStream(val streamMode: StreamMode) : AutoCloseable {
|
|||
* @since v1-alpha10
|
||||
*/
|
||||
@Throws(IOAccessException::class)
|
||||
fun skipRemainingBytes(): FileStream {
|
||||
fun skipRemainingBytes(): Stream {
|
||||
readRemainingBytes()
|
||||
return this
|
||||
}
|
||||
|
@ -266,8 +266,8 @@ abstract class FileStream(val streamMode: StreamMode) : AutoCloseable {
|
|||
// -----> Redirection
|
||||
/**
|
||||
* Reads the next byte of this
|
||||
* [FileStream] and writes it
|
||||
* to the specified [FileStream].
|
||||
* [Stream] and writes it
|
||||
* to the specified [Stream].
|
||||
*
|
||||
* @param stream stream to write to
|
||||
* @return this instance
|
||||
|
@ -275,7 +275,7 @@ abstract class FileStream(val streamMode: StreamMode) : AutoCloseable {
|
|||
* @since v1-alpha10
|
||||
*/
|
||||
@Throws(IOAccessException::class)
|
||||
fun writeNextByteTo(stream: FileStream): FileStream {
|
||||
fun writeNextByteTo(stream: Stream): Stream {
|
||||
val byte: Byte? = readNextByte()
|
||||
|
||||
if (byte != null)
|
||||
|
@ -286,8 +286,8 @@ abstract class FileStream(val streamMode: StreamMode) : AutoCloseable {
|
|||
|
||||
/**
|
||||
* Reads the next [n] byte of this
|
||||
* [FileStream] and writes it
|
||||
* to the specified [FileStream].
|
||||
* [Stream] and writes it
|
||||
* to the specified [Stream].
|
||||
*
|
||||
* @param stream stream to write to
|
||||
* @return this instance
|
||||
|
@ -295,16 +295,16 @@ abstract class FileStream(val streamMode: StreamMode) : AutoCloseable {
|
|||
* @since v1-alpha10
|
||||
*/
|
||||
@Throws(IOAccessException::class)
|
||||
fun writeNBytesTo(stream: FileStream, n: UInt): FileStream {
|
||||
fun writeNBytesTo(stream: Stream, n: UInt): Stream {
|
||||
stream.writeBytes(readNBytes(n))
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads all bytes of this
|
||||
* [FileStream] and writes
|
||||
* [Stream] and writes
|
||||
* them to the specified
|
||||
* [FileStream].
|
||||
* [Stream].
|
||||
*
|
||||
* @param stream stream to write to
|
||||
* @return this instance
|
||||
|
@ -312,7 +312,7 @@ abstract class FileStream(val streamMode: StreamMode) : AutoCloseable {
|
|||
* @since v1-alpha10
|
||||
*/
|
||||
@Throws(IOAccessException::class)
|
||||
fun writeRemainingBytesTo(stream: FileStream): FileStream {
|
||||
fun writeRemainingBytesTo(stream: Stream): Stream {
|
||||
stream.writeBytes(readRemainingBytes())
|
||||
return this
|
||||
}
|
||||
|
@ -351,13 +351,13 @@ abstract class FileStream(val streamMode: StreamMode) : AutoCloseable {
|
|||
// -----> Inner classes
|
||||
/**
|
||||
* Represents the mode in which
|
||||
* [FileStream]s can operate in.
|
||||
* [Stream]s can operate in.
|
||||
*
|
||||
* @since v1-alpha10
|
||||
*/
|
||||
enum class StreamMode {
|
||||
/**
|
||||
* A [FileStream] which only
|
||||
* A [Stream] which only
|
||||
* supports reading.
|
||||
*
|
||||
* @since v1-alpha10
|
||||
|
@ -365,7 +365,7 @@ abstract class FileStream(val streamMode: StreamMode) : AutoCloseable {
|
|||
READ,
|
||||
|
||||
/**
|
||||
* A [FileStream] which only
|
||||
* A [Stream] which only
|
||||
* supports writing.
|
||||
*
|
||||
* @since v1-alpha10
|
||||
|
@ -373,7 +373,7 @@ abstract class FileStream(val streamMode: StreamMode) : AutoCloseable {
|
|||
WRITE,
|
||||
|
||||
/**
|
||||
* A [FileStream] which supports
|
||||
* A [Stream] which supports
|
||||
* both reading and writing.
|
||||
*
|
||||
* @since v1-alpha10
|
||||
|
@ -383,15 +383,15 @@ abstract class FileStream(val streamMode: StreamMode) : AutoCloseable {
|
|||
|
||||
/**
|
||||
* An implementation of Java
|
||||
* [InputStream]s for [FileStream]s.
|
||||
* [InputStream]s for [Stream]s.
|
||||
*
|
||||
* @param fileStream [FileStream] to use
|
||||
* @param stream [Stream] to use
|
||||
* @throws IOException on IO error
|
||||
* @since v1-alpha10
|
||||
*/
|
||||
class InputFileStream
|
||||
@NonKotlinContact
|
||||
internal constructor(val fileStream: FileStream)
|
||||
internal constructor(val stream: Stream)
|
||||
: InputStream() {
|
||||
/**
|
||||
* Reads the next byte.
|
||||
|
@ -402,7 +402,7 @@ abstract class FileStream(val streamMode: StreamMode) : AutoCloseable {
|
|||
*/
|
||||
@Throws(IOException::class)
|
||||
override fun read(): Int = try {
|
||||
fileStream.readNextByte()?.toInt() ?: -1
|
||||
stream.readNextByte()?.toInt() ?: -1
|
||||
} catch (exception: IOAccessException) {
|
||||
throw IOException("Failed reading the next byte", exception)
|
||||
}
|
||||
|
@ -410,15 +410,15 @@ abstract class FileStream(val streamMode: StreamMode) : AutoCloseable {
|
|||
|
||||
/**
|
||||
* An implementation of Java
|
||||
* [OutputStream]s for [FileStream]s.
|
||||
* [OutputStream]s for [Stream]s.
|
||||
*
|
||||
* @param fileStream [FileStream] to use
|
||||
* @param stream [Stream] to use
|
||||
* @since v1-alpha10
|
||||
*/
|
||||
@NonKotlinContact
|
||||
class OutputFileStream
|
||||
@NonKotlinContact
|
||||
internal constructor(val fileStream: FileStream)
|
||||
internal constructor(val stream: Stream)
|
||||
: OutputStream() {
|
||||
/**
|
||||
* Writes (or rather: appends) a byte.
|
||||
|
@ -430,7 +430,7 @@ abstract class FileStream(val streamMode: StreamMode) : AutoCloseable {
|
|||
@Throws(IOException::class)
|
||||
override fun write(byte: Int) {
|
||||
try {
|
||||
fileStream.writeByte(byte.toByte())
|
||||
stream.writeByte(byte.toByte())
|
||||
} catch (exception: IOAccessException) {
|
||||
throw IOException("Failed writing the next byte", exception)
|
||||
}
|
|
@ -20,11 +20,11 @@
|
|||
package de.staropensource.engine.base.implementable.stream
|
||||
|
||||
/**
|
||||
* A write-only [FileStream].
|
||||
* A write-only [Stream].
|
||||
*
|
||||
* @since v1-alpha10
|
||||
*/
|
||||
abstract class WriteFileStream : FileStream(streamMode = StreamMode.WRITE) {
|
||||
abstract class WriteStream : Stream(streamMode = StreamMode.WRITE) {
|
||||
override fun remaining(): Boolean = false
|
||||
override fun available(): UInt = 0u
|
||||
override fun readNextByte(): Byte? = 0x00
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* Streams. Particularly [FileStream]s.
|
||||
* [Streams].
|
||||
*
|
||||
* @since v1-alpha10
|
||||
*/
|
||||
|
|
|
@ -20,18 +20,18 @@
|
|||
package de.staropensource.engine.base.implementation.stream
|
||||
|
||||
import de.staropensource.engine.base.exception.io.StreamClosedException
|
||||
import de.staropensource.engine.base.implementable.stream.FileStream
|
||||
import de.staropensource.engine.base.implementable.stream.ReadFileStream
|
||||
import de.staropensource.engine.base.implementable.stream.Stream
|
||||
import de.staropensource.engine.base.implementable.stream.ReadStream
|
||||
import java.io.ByteArrayInputStream
|
||||
|
||||
/**
|
||||
* A [FileStream] which can
|
||||
* A [Stream] which can
|
||||
* only read [Byte]s.
|
||||
*
|
||||
* @param bytesRead [ByteArray] to provide for reading
|
||||
* @since v1-alpha10
|
||||
*/
|
||||
open class ByteReadFileStream(val bytesRead: ByteArray) : ReadFileStream() {
|
||||
open class ByteReadStream(val bytesRead: ByteArray) : ReadStream() {
|
||||
/**
|
||||
* Contains the [ByteArrayInputStream]
|
||||
* for the supplied [bytesRead] property.
|
|
@ -20,17 +20,17 @@
|
|||
package de.staropensource.engine.base.implementation.stream
|
||||
|
||||
import de.staropensource.engine.base.exception.io.StreamClosedException
|
||||
import de.staropensource.engine.base.implementable.stream.FileStream
|
||||
import de.staropensource.engine.base.implementable.stream.Stream
|
||||
import java.io.ByteArrayInputStream
|
||||
|
||||
/**
|
||||
* A [FileStream] which can
|
||||
* A [Stream] which can
|
||||
* read and write [Byte]s.
|
||||
*
|
||||
* @param bytesRead [ByteArray] to provide for reading
|
||||
* @since v1-alpha10
|
||||
*/
|
||||
open class ByteFileStream(val bytesRead: ByteArray) : FileStream(streamMode = StreamMode.READ_WRITE) {
|
||||
open class ByteStream(val bytesRead: ByteArray) : Stream(streamMode = StreamMode.READ_WRITE) {
|
||||
/**
|
||||
* Contains the [ByteArrayInputStream]
|
||||
* for the supplied [bytesRead] property.
|
||||
|
@ -56,7 +56,7 @@ open class ByteFileStream(val bytesRead: ByteArray) : FileStream(streamMode = St
|
|||
|
||||
|
||||
// -----> Writing
|
||||
override fun writeByte(byte: Byte): FileStream {
|
||||
override fun writeByte(byte: Byte): Stream {
|
||||
if (closed)
|
||||
throw StreamClosedException(this)
|
||||
|
||||
|
@ -64,7 +64,7 @@ open class ByteFileStream(val bytesRead: ByteArray) : FileStream(streamMode = St
|
|||
return this
|
||||
}
|
||||
|
||||
override fun writeBytes(bytes: ByteArray): FileStream {
|
||||
override fun writeBytes(bytes: ByteArray): Stream {
|
||||
if (closed)
|
||||
throw StreamClosedException(this)
|
||||
|
|
@ -20,16 +20,16 @@
|
|||
package de.staropensource.engine.base.implementation.stream
|
||||
|
||||
import de.staropensource.engine.base.exception.io.StreamClosedException
|
||||
import de.staropensource.engine.base.implementable.stream.FileStream
|
||||
import de.staropensource.engine.base.implementable.stream.WriteFileStream
|
||||
import de.staropensource.engine.base.implementable.stream.Stream
|
||||
import de.staropensource.engine.base.implementable.stream.WriteStream
|
||||
|
||||
/**
|
||||
* A [FileStream] which can
|
||||
* A [Stream] which can
|
||||
* only write [Byte]s.
|
||||
*
|
||||
* @since v1-alpha10
|
||||
*/
|
||||
open class ByteWriteFileStream : WriteFileStream() {
|
||||
open class ByteWriteStream : WriteStream() {
|
||||
/**
|
||||
* Contains the bytes written
|
||||
* to this stream.
|
||||
|
@ -45,7 +45,7 @@ open class ByteWriteFileStream : WriteFileStream() {
|
|||
|
||||
|
||||
// -----> Writing
|
||||
override fun writeByte(byte: Byte): FileStream {
|
||||
override fun writeByte(byte: Byte): Stream {
|
||||
if (closed)
|
||||
throw StreamClosedException(this)
|
||||
|
||||
|
@ -53,7 +53,7 @@ open class ByteWriteFileStream : WriteFileStream() {
|
|||
return this
|
||||
}
|
||||
|
||||
override fun writeBytes(bytes: ByteArray): FileStream {
|
||||
override fun writeBytes(bytes: ByteArray): Stream {
|
||||
if (closed)
|
||||
throw StreamClosedException(this)
|
||||
|
|
@ -22,12 +22,12 @@ package de.staropensource.engine.base.implementation.stream
|
|||
import de.staropensource.engine.base.exception.VerificationFailedException
|
||||
import de.staropensource.engine.base.exception.io.IOAccessException
|
||||
import de.staropensource.engine.base.exception.io.StreamClosedException
|
||||
import de.staropensource.engine.base.implementable.stream.FileStream
|
||||
import de.staropensource.engine.base.implementable.stream.Stream
|
||||
import de.staropensource.engine.base.utility.FileAccess
|
||||
import java.io.InputStream
|
||||
|
||||
/**
|
||||
* A [FileStream] used exclusively for
|
||||
* A [Stream] used exclusively for
|
||||
* accessing files via the [FileAccess]
|
||||
* API.
|
||||
*
|
||||
|
@ -35,7 +35,7 @@ import java.io.InputStream
|
|||
* @see FileAccess.toStream
|
||||
* @since v1-alpha10
|
||||
*/
|
||||
class FileAccessStream internal constructor(val file: FileAccess) : FileStream(streamMode = StreamMode.READ_WRITE) {
|
||||
class FileAccessStream internal constructor(val file: FileAccess) : Stream(streamMode = StreamMode.READ_WRITE) {
|
||||
// -----> Metadata
|
||||
/**
|
||||
* Contains the [InputStream] used
|
||||
|
@ -53,9 +53,9 @@ class FileAccessStream internal constructor(val file: FileAccess) : FileStream(s
|
|||
|
||||
|
||||
// -----> Writing
|
||||
override fun writeByte(byte: Byte): FileStream = writeBytes(byteArrayOf(byte))
|
||||
override fun writeByte(byte: Byte): Stream = writeBytes(byteArrayOf(byte))
|
||||
|
||||
override fun writeBytes(bytes: ByteArray): FileStream {
|
||||
override fun writeBytes(bytes: ByteArray): Stream {
|
||||
if (closed)
|
||||
throw StreamClosedException(this)
|
||||
|
||||
|
|
|
@ -19,14 +19,14 @@
|
|||
|
||||
package de.staropensource.engine.base.implementation.stream
|
||||
|
||||
import de.staropensource.engine.base.implementable.stream.FileStream
|
||||
import de.staropensource.engine.base.implementable.stream.WriteFileStream
|
||||
import de.staropensource.engine.base.implementable.stream.Stream
|
||||
import de.staropensource.engine.base.implementable.stream.WriteStream
|
||||
import de.staropensource.engine.base.logging.Logger
|
||||
import de.staropensource.engine.base.type.logging.Level
|
||||
import de.staropensource.engine.base.utility.FileAccess
|
||||
|
||||
/**
|
||||
* A [FileStream] used exclusively
|
||||
* A [Stream] used exclusively
|
||||
* for printing log messages.
|
||||
*
|
||||
* A log message is only printed
|
||||
|
@ -36,7 +36,7 @@ import de.staropensource.engine.base.utility.FileAccess
|
|||
* @see FileAccess.toStream
|
||||
* @since v1-alpha10
|
||||
*/
|
||||
class LoggerFileStream internal constructor(val logger: Logger, val level: Level) : WriteFileStream() {
|
||||
class LoggerStream internal constructor(val logger: Logger, val level: Level) : WriteStream() {
|
||||
/**
|
||||
* Contains the current line.
|
||||
*
|
||||
|
@ -48,9 +48,9 @@ class LoggerFileStream internal constructor(val logger: Logger, val level: Level
|
|||
logger.stream.remove(level)
|
||||
}
|
||||
|
||||
override fun writeByte(byte: Byte): FileStream = writeBytes(byteArrayOf(byte))
|
||||
override fun writeByte(byte: Byte): Stream = writeBytes(byteArrayOf(byte))
|
||||
|
||||
override fun writeBytes(bytes: ByteArray): FileStream {
|
||||
override fun writeBytes(bytes: ByteArray): Stream {
|
||||
line.append(bytes.decodeToString())
|
||||
|
||||
checkAndPrint()
|
|
@ -19,33 +19,33 @@
|
|||
|
||||
package de.staropensource.engine.base.implementation.stream
|
||||
|
||||
import de.staropensource.engine.base.implementable.stream.FileStream
|
||||
import de.staropensource.engine.base.implementable.stream.Stream
|
||||
|
||||
/**
|
||||
* A [FileStream] which does nothing.
|
||||
* A [Stream] which does nothing.
|
||||
*
|
||||
* @since v1-alpha10
|
||||
*/
|
||||
class NullFileStream private constructor() : FileStream(streamMode = StreamMode.READ_WRITE) {
|
||||
class NullStream private constructor() : Stream(streamMode = StreamMode.READ_WRITE) {
|
||||
/**
|
||||
* Companion object of [NullFileStream].
|
||||
* Companion object of [NullStream].
|
||||
*
|
||||
* @since v1-alpha10
|
||||
*/
|
||||
companion object {
|
||||
/**
|
||||
* Global instance of [NullFileStream].
|
||||
* Global instance of [NullStream].
|
||||
*
|
||||
* @since v1-alpha10
|
||||
*/
|
||||
@JvmStatic
|
||||
val instance: NullFileStream = NullFileStream()
|
||||
val instance: NullStream = NullStream()
|
||||
}
|
||||
|
||||
override fun closeStream() = Unit
|
||||
|
||||
override fun writeByte(byte: Byte): FileStream = this
|
||||
override fun writeBytes(bytes: ByteArray): FileStream = this
|
||||
override fun writeByte(byte: Byte): Stream = this
|
||||
override fun writeBytes(bytes: ByteArray): Stream = this
|
||||
|
||||
override fun remaining(): Boolean = true
|
||||
override fun available(): UInt = 0u
|
|
@ -19,13 +19,13 @@
|
|||
|
||||
package de.staropensource.engine.base.implementation.stream
|
||||
|
||||
import de.staropensource.engine.base.implementable.stream.FileStream
|
||||
import de.staropensource.engine.base.implementable.stream.Stream
|
||||
|
||||
/**
|
||||
* A [FileStream] which can
|
||||
* A [Stream] which can
|
||||
* only read strings.
|
||||
*
|
||||
* @param stringRead string to provide for reading
|
||||
* @since v1-alpha10
|
||||
*/
|
||||
open class StringReadFileStream(val stringRead: String) : ByteReadFileStream(bytesRead = stringRead.toByteArray())
|
||||
open class StringReadStream(val stringRead: String) : ByteReadStream(bytesRead = stringRead.toByteArray())
|
|
@ -19,16 +19,16 @@
|
|||
|
||||
package de.staropensource.engine.base.implementation.stream
|
||||
|
||||
import de.staropensource.engine.base.implementable.stream.FileStream
|
||||
import de.staropensource.engine.base.implementable.stream.Stream
|
||||
|
||||
/**
|
||||
* A [FileStream] which can
|
||||
* A [Stream] which can
|
||||
* read and write strings.
|
||||
*
|
||||
* @param stringRead string to provide for reading
|
||||
* @since v1-alpha10
|
||||
*/
|
||||
open class StringFileStream(val stringRead: String) : ByteFileStream(bytesRead = stringRead.toByteArray()) {
|
||||
open class StringStream(val stringRead: String) : ByteStream(bytesRead = stringRead.toByteArray()) {
|
||||
/**
|
||||
* Returns the written string.
|
||||
*
|
|
@ -19,15 +19,15 @@
|
|||
|
||||
package de.staropensource.engine.base.implementation.stream
|
||||
|
||||
import de.staropensource.engine.base.implementable.stream.FileStream
|
||||
import de.staropensource.engine.base.implementable.stream.Stream
|
||||
|
||||
/**
|
||||
* A [FileStream] which can
|
||||
* A [Stream] which can
|
||||
* only write strings.
|
||||
*
|
||||
* @since v1-alpha10
|
||||
*/
|
||||
open class StringWriteFileStream : ByteWriteFileStream() {
|
||||
open class StringWriteStream : ByteWriteStream() {
|
||||
/**
|
||||
* Returns the written string.
|
||||
*
|
|
@ -18,10 +18,10 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* Implementations of [FileStream] far and wide.
|
||||
* Implementations of [Stream] far and wide.
|
||||
*
|
||||
* @since v1-alpha10
|
||||
*/
|
||||
package de.staropensource.engine.base.implementation.stream
|
||||
|
||||
import de.staropensource.engine.base.implementable.stream.FileStream
|
||||
import de.staropensource.engine.base.implementable.stream.Stream
|
||||
|
|
|
@ -22,9 +22,9 @@ package de.staropensource.engine.base.logging
|
|||
import de.staropensource.engine.base.EngineConfiguration
|
||||
import de.staropensource.engine.base.annotation.NonKotlinContact
|
||||
import de.staropensource.engine.base.implementable.logging.LoggerThreadingHandler
|
||||
import de.staropensource.engine.base.implementable.stream.FileStream
|
||||
import de.staropensource.engine.base.implementable.stream.Stream
|
||||
import de.staropensource.engine.base.implementation.stream.FileAccessStream
|
||||
import de.staropensource.engine.base.implementation.stream.LoggerFileStream
|
||||
import de.staropensource.engine.base.implementation.stream.LoggerStream
|
||||
import de.staropensource.engine.base.type.logging.Call
|
||||
import de.staropensource.engine.base.type.logging.Level
|
||||
import de.staropensource.engine.base.utility.misc.StackTraceUtils
|
||||
|
@ -81,11 +81,11 @@ class Logger {
|
|||
private val channel: String
|
||||
|
||||
/**
|
||||
* Contains the [LoggerFileStream] for this instance.
|
||||
* Contains the [LoggerStream] for this instance.
|
||||
*
|
||||
* @since v1-alpha10
|
||||
*/
|
||||
internal val stream: MutableMap<Level, LoggerFileStream> = mutableMapOf()
|
||||
internal val stream: MutableMap<Level, LoggerStream> = mutableMapOf()
|
||||
@NonKotlinContact
|
||||
@JvmName(name = "getActualStream") get
|
||||
|
||||
|
@ -233,13 +233,13 @@ class Logger {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a [FileStream] for
|
||||
* Returns a [Stream] for
|
||||
* writing to the specified
|
||||
* [Level] using this instance.
|
||||
*
|
||||
* @param level [Level] to which the [FileStream] shall log to
|
||||
* @param level [Level] to which the [Stream] shall log to
|
||||
* @return [FileAccessStream] instance
|
||||
* @since v1-alpha10
|
||||
*/
|
||||
fun toStream(level: Level): LoggerFileStream = stream.computeIfAbsent(level) { level -> LoggerFileStream(this, level) }
|
||||
fun toStream(level: Level): LoggerStream = stream.computeIfAbsent(level) { level -> LoggerStream(this, level) }
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import de.staropensource.engine.base.exception.io.FileOrDirectoryNotFoundExcepti
|
|||
import de.staropensource.engine.base.exception.io.FileTooLargeException
|
||||
import de.staropensource.engine.base.exception.io.IOAccessException
|
||||
import de.staropensource.engine.base.exception.VerificationFailedException
|
||||
import de.staropensource.engine.base.implementable.stream.FileStream
|
||||
import de.staropensource.engine.base.implementable.stream.Stream
|
||||
import de.staropensource.engine.base.implementation.stream.FileAccessStream
|
||||
import de.staropensource.engine.base.utility.Environment.OperatingSystem.*
|
||||
import de.staropensource.engine.base.utility.FileAccess.Companion.configDirectory
|
||||
|
@ -570,7 +570,7 @@ class FileAccess {
|
|||
|
||||
// -----> Streams getters
|
||||
/**
|
||||
* Returns a [FileStream] for reading
|
||||
* Returns a [Stream] for reading
|
||||
* and writing from and to this file.
|
||||
*
|
||||
* @return [FileAccessStream] instance
|
||||
|
|
Loading…
Reference in a new issue