...
 
Commits (7)
......@@ -238,7 +238,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Deprecated
- `toObject` Function in Json Interface (Using Any)
- `Base58` Object (com.atvgstudios.klib.objects.base.Base58)
- `Base58` Object (com.atvgstudios.klib.encoding.base.Base58)
### Removed
- `Json` Object (com.atvgstudios.klib.objects.json.Json)
......
......@@ -7,7 +7,7 @@ plugins {
}
group 'klib'
version '3.2.0'
version '4.0.0-dev'
repositories {
mavenCentral()
......
package klib
class KString {
private val stringBuilder = StringBuilder()
val length = stringBuilder.length
fun line(value: String) {
stringBuilder.appendln(value)
}
fun text(value: String) {
stringBuilder.append(value)
}
operator fun plus(value: String) {
stringBuilder.append(value)
}
operator fun String.unaryPlus() {
stringBuilder.append(this)
}
operator fun plusAssign(value: String) {
stringBuilder.append(value)
}
override fun toString(): String {
return stringBuilder.toString()
}
}
\ No newline at end of file
package klib.objects
package klib
import klib.exceptions.KonfigParseException
import java.io.File
......
package klib.types
package klib
import klib.exceptions.InvalidTypeException
import klib.extensions.isNumeric
......
package klib.dummy
import klib.interfaces.Json
import klib.json.Json
import java.lang.reflect.Type
/**
......@@ -11,7 +11,7 @@ import java.lang.reflect.Type
* @deprecated
* @author Nils Rider
*/
@Deprecated(message = "This was a dummy because no JSON parser was part of kLib. But we now ship with a JSON Parser!", replaceWith = ReplaceWith("klib.types.JsonHandler"), level = DeprecationLevel.ERROR)
@Deprecated(message = "This was a dummy because no JSON parser was part of kLib. But we now ship with a JSON Parser!", replaceWith = ReplaceWith("klib.json.JsonHandler"), level = DeprecationLevel.ERROR)
class JsonHandler : Json {
override fun fromObject(data: Any): String {
TODO("not implemented") // To change body of created functions use File | Settings | File Templates.
......
package klib.objects.base
package klib.encoding.base
import java.math.BigInteger
......
package klib.extensions
import klib.kLibInf
import klib.typealiases.Function_Any
import klib.queue.Function_Any
/**
* Type Check and Type Cast made easy
......
package klib.extensions
import klib.types.word.Word
import klib.word.Word
/**
* Turn Word array into Bytes
......
package klib.extensions
import klib.objects.hash.Sha1
import klib.objects.hash.Sha256
import klib.hash.Sha1
import klib.hash.Sha256
import kotlin.experimental.xor
/**
......
package klib.extensions
import klib.objects.hash.Sha1
import klib.objects.hash.Sha256
import klib.objects.library.Library
import klib.types.hash.HashResult
import klib.types.library.LClass
import klib.types.library.LFunction
import klib.types.zip.ZipFile
import klib.hash.HashResult
import klib.hash.Sha1
import klib.hash.Sha256
import klib.library.LClass
import klib.library.LFunction
import klib.library.Library
import klib.zip.ZipFile
import java.io.File
import java.io.FileNotFoundException
import java.net.URL
......
package klib.extensions
import klib.types.zip.ZipFile
import klib.zip.ZipFile
import java.io.File
import java.io.InputStream
......
package klib.extensions
import klib.encoding.base.Base58e
import klib.exceptions.InvalidValueException
import klib.exceptions.RequireValueException
import klib.hash.Sha1
import klib.hash.Sha256
import klib.kLibInf
import klib.objects.base.Base58e
import klib.objects.hash.Sha1
import klib.objects.hash.Sha256
import klib.objects.library.Library
import klib.types.library.LClass
import klib.types.library.LFunction
import klib.library.LClass
import klib.library.LFunction
import klib.library.Library
import java.io.File
import java.io.FileNotFoundException
import java.lang.reflect.Type
......
package klib.functions
import klib.typealiases.Function
import klib.queue.Function
/**
* Require something to be not null; Else execute onError
......
package klib.functions
import klib.SemVer
import klib.kLibInf
import klib.types.SemVer
/**
* Check if the used kLib is the required version (Dependency Check)
......
package klib.functions
import klib.KString
fun kstring(builder: KString.() -> Unit): String {
return KString().apply(builder).toString()
}
\ No newline at end of file
package klib.types.hash
package klib.hash
import klib.extensions.inBoundsOf
import java.lang.IndexOutOfBoundsException
/**
* HashResults gets return from the Hasher with the Hex Hash and the used Algorithm
......
package klib.interfaces
package klib.hash
import klib.types.hash.HashResult
import java.security.MessageDigest
/**
......
package klib.objects.hash
package klib.hash
import klib.interfaces.Hasher
import klib.types.hash.HashResult
import java.nio.charset.Charset
/**
......
package klib.objects.hash
package klib.hash
import klib.interfaces.Hasher
import klib.types.hash.HashResult
import java.nio.charset.Charset
/**
......
package klib.interfaces
package klib.json
import java.lang.reflect.Type
......
package klib.types
package klib.json
import com.google.gson.Gson
import klib.interfaces.Json
import java.lang.reflect.Type
/**
......
package klib
import klib.interfaces.Json
import klib.types.JsonHandler
import klib.types.SemVer
import klib.json.Json
import klib.json.JsonHandler
/**
* kLib Information Center
......@@ -25,7 +24,7 @@ object kLibInf {
* @since 2.0.0
* @author Thomas Obernosterer
*/
val semver = SemVer(3, 2, 0)
val semver = SemVer(4, 0, 0, "dev")
/**
* Company creating kLib
......
package klib.types.library
package klib.library
import java.io.FileNotFoundException
import java.lang.reflect.Method
......
package klib.types.library
package klib.library
import java.lang.reflect.Method
......
package klib.objects.library
package klib.library
import klib.types.library.LClass
import klib.types.library.LFunction
import java.io.File
import java.io.FileNotFoundException
import java.net.URL
......
package klib.types.http
package klib.net.http
import klib.extensions.readText
import klib.kLibInf
......
package klib.net.socket
import klib.extensions.reset
import java.io.File
import java.nio.CharBuffer
import java.util.Timer
import java.util.TimerTask
class KSocket {
private lateinit var file: File
private lateinit var buffer: CharBuffer
private var fileName: String = ""
private var timeout: Long = 0
private var canReadFile: Boolean = false
val data = buffer
var canRead: Boolean
get() = canReadFile
set(value) = TODO()
fun open(file: String, timeout: Long = 25, buffer: CharBuffer = CharBuffer.allocate(1024)) {
this.fileName = file
this.timeout = timeout
this.buffer = buffer
this.file = File(fileName)
this.canReadFile = this.file.exists() && this.file.canRead()
}
fun read(): Int {
if(!isReadable()) {
data.clear()
return -1
}
return file.reader().read(buffer)
}
fun readTimed(block: (size: Int, data: CharBuffer) -> Unit) {
var lastTime = 0L
var size = 0
var lastMod = 0L
val timer = Timer()
timer.scheduleAtFixedRate(object : TimerTask() {
override fun run() {
lastMod = file.lastModified()
if (lastMod != lastTime) {
lastTime = lastMod
size = read()
block(size, data)
}
}
}, timeout, timeout)
}
private fun isReadable(): Boolean {
this.canReadFile = this.file.exists() && this.file.canRead()
return this.canReadFile
}
}
\ No newline at end of file
package klib.objects
package klib.net.socket
import klib.extensions.reset
import klib.functions.currentMillis
......@@ -13,6 +13,7 @@ import java.util.TimerTask
* @since 3.0.0
* @author Thomas Obernosterer
*/
@Deprecated("kSock has been replaced by KSocket", ReplaceWith("KSocket", "klib.net.socket.KSocket"), DeprecationLevel.ERROR)
object kSock {
private var id = 0L
......
package klib.typealiases
package klib.queue
/**
* Type alias for () -> Unit
......
package klib.types.queue
package klib.queue
import klib.typealiases.Function
import java.util.Timer
import java.util.TimerTask
......
package klib.types.word
package klib.word
import kotlin.experimental.xor
......
package klib.types.zip
package klib.zip
import klib.extensions.asFile
import java.io.BufferedInputStream
......@@ -6,7 +6,6 @@ import java.io.File
import java.io.FileInputStream
import java.io.FileNotFoundException
import java.io.FileOutputStream
import java.lang.Exception
import java.util.zip.ZipEntry
import java.util.zip.ZipInputStream
import java.util.zip.ZipOutputStream
......
......@@ -32,9 +32,11 @@ fun main() {
val users = klib.kLibInf.jsonHandler.toObject(jsonData, Array<User>::class.java)
if (users is Array<*>) {
(users as Array<User>).forEach {
it.id *= 5
println(it)
users.forEach {
if(it is User) {
it.id *= 5
println(it)
}
}
}
}
\ No newline at end of file
package devtests
import klib.net.socket.KSocket
fun main() {
useWhileLoop()
useTimedLoop()
}
fun useWhileLoop() {
val socket = KSocket()
socket.open("/tmp/kotlin-socket.sk")
while(socket.canRead) {
if(socket.read() >= 1) {
println(socket.data)
}
Thread.sleep(25)
}
}
fun useTimedLoop() {
val socket = KSocket()
socket.open("/tmp/kotlin-socket2.sk")
socket.readTimed { size, data ->
if(size >= 1) {
println(data)
}
}
}
\ No newline at end of file
package devtests
import klib.functions.kstring
fun main() {
val string = kstring {
line("Counter")
line("This will count to 100:")
for(i in 0 .. 100) {
+ "$i,"
}
}
println(string)
}
\ No newline at end of file
package devtests
import klib.types.SemVer
import klib.SemVer
fun main() {
val semver1 = SemVer.parse("1.0.0")
......
package devtests
import klib.extensions.deny
import klib.objects.uuid.UniqueID
import klib.uuid.UniqueID
fun main() {
UniqueID.random deny ""
......
package devtests
import klib.extensions.asFile
import klib.types.zip.ZipFile
import klib.zip.ZipFile
fun main() {
val zipFile = ZipFile("/stmp/Documents.zip")
......
package devtests
import klib.objects.kSock
import klib.net.socket.kSock
fun main() {
kSock.open {
......