KeyValue

class KeyValue @JvmOverloads constructor(var name: String? = null, var value: String? = null)

Represents a recursive string key to arbitrary value container.

Parameters

name

The optional name of the root key.

value

The optional value assigned to the root key.

Constructors

Link copied to clipboard
constructor(name: String? = null, value: String? = null)

Initializes a new instance of the class.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Gets the children of this instance.

Link copied to clipboard
var name: String?

Gets or sets the name of this instance.

Link copied to clipboard

Gets or sets the value of this instance.

Functions

Link copied to clipboard
fun asBoolean(defaultValue: Boolean = false): Boolean

Attempts to convert and return the value of this instance as a boolean. If the conversion is invalid, the default value is returned.

Link copied to clipboard
fun asByte(defaultValue: Byte = 0): Byte

Attempts to convert and return the value of this instance as a byte. If the conversion is invalid, the default value is returned.

Link copied to clipboard
fun <T : Enum<T>> asEnum(enumClass: Class<T>, defaultValue: T): EnumSet<T>
fun <T : Enum<T>> asEnum(enumClass: Class<T>, defaultValue: EnumSet<T>): EnumSet<T>

Attempts to convert and return the value of this instance as an enum. If the conversion is invalid, the default value is returned.

Link copied to clipboard
fun asFloat(defaultValue: Float = 0.0f): Float

Attempts to convert and return the value of this instance as a float. If the conversion is invalid, the default value is returned.

Link copied to clipboard
fun asInteger(defaultValue: Int = 0): Int

Attempts to convert and return the value of this instance as an integer. If the conversion is invalid, the default value is returned.

Link copied to clipboard
fun asLong(defaultValue: Long = 0): Long

Attempts to convert and return the value of this instance as a long. If the conversion is invalid, the default value is returned.

Link copied to clipboard
fun asShort(defaultValue: Short = 0): Short

Attempts to convert and return the value of this instance as a short. If the conversion is invalid, the default value is returned.

Link copied to clipboard

Returns the value of this instance as a string.

Link copied to clipboard

Attempts to convert and return the value of this instance as an unsigned byte. If the conversion is invalid, the default value is returned.

Link copied to clipboard

Attempts to convert and return the value of this instance as an unsigned integer. If the conversion is invalid, the default value is returned.

Link copied to clipboard

Attempts to convert and return the value of this instance as an unsigned long. If the conversion is invalid, the default value is returned.

Link copied to clipboard

Attempts to convert and return the value of this instance as an unsigned short. If the conversion is invalid, the default value is returned.

Link copied to clipboard
operator fun get(key: String): KeyValue

Gets the child KeyValue with the specified key. If no child with the given key exists, KeyValue.INVALID is returned.

Link copied to clipboard

Populate this instance from the given InputStream as a text KeyValue.

Link copied to clipboard
fun readFileAsText(filename: String): Boolean

Opens and reads the given filename as text.

Link copied to clipboard
fun saveToFile(file: File, asBinary: Boolean)
fun saveToFile(path: String, asBinary: Boolean)

Saves this instance to file.

Link copied to clipboard
fun saveToStream(stream: OutputStream, asBinary: Boolean)

Saves this instance to a given OutputStream

Link copied to clipboard
operator fun set(key: String, value: KeyValue)
Link copied to clipboard
open override fun toString(): String

Returns a String that represents this instance.

Link copied to clipboard

Populate this instance from the given InputStream as a binary KeyValue.