Package space.kscience.dataforge.names

Types

Name
Link copied to clipboard
common
class Name(tokens: List<NameToken>)

The general interface for working with names. The name is a dot separated list of strings like token1.token2.token3. Each token could contain additional index in square brackets.

NameSerializer
Link copied to clipboard
common
object NameSerializer : KSerializer<Name>
NameToken
Link copied to clipboard
common
data class NameToken(body: String, index: String?)

A single name token. Body is not allowed to be empty. Following symbols are prohibited in name tokens: {}.:\. A name token could have appendix in square brackets called index

NameTokenSerializer
Link copied to clipboard
common
object NameTokenSerializer : KSerializer<NameToken>

Functions

appendLeft
Link copied to clipboard
common
fun Name.appendLeft(other: String): Name
asName
Link copied to clipboard
common
fun String.asName(): Name

Convert the String to a Name by simply wrapping it in a single name token without parsing. The input string could contain dots and braces, but they are just escaped, not parsed.

fun NameToken.asName(): Name
cutFirst
Link copied to clipboard
common
fun Name.cutFirst(): Name

The reminder of the name after first element is cut. For empty name return itself.

cutLast
Link copied to clipboard
common
fun Name.cutLast(): Name

The reminder of the name after last element is cut. For empty name return itself.

endsWith
Link copied to clipboard
common
fun Name.endsWith(name: Name): Boolean
fun Name.endsWith(token: NameToken): Boolean
first
Link copied to clipboard
common
fun Name.first(): NameToken

First token or throw exception

firstOrNull
Link copied to clipboard
common
fun Name.firstOrNull(): NameToken?

First token of the name or null if it is empty

get
Link copied to clipboard
common
operator fun <T> Map<Name, T>.get(name: String): T?
operator fun Name.get(i: Int): NameToken
operator fun <T> Map<NameToken, T>.get(body: String, query: String? = null): T?

Fast String-based accessor for item map

hasIndex
Link copied to clipboard
common
fun NameToken.hasIndex(): Boolean

Check if index is defined for this token

isEmpty
Link copied to clipboard
common
fun Name.isEmpty(): Boolean
lastOrNull
Link copied to clipboard
common
fun Name.lastOrNull(): NameToken?

Last token of the name or null if it is empty

matches
Link copied to clipboard
common
fun Name.matches(pattern: String): Boolean
fun Name.matches(pattern: Name): Boolean

Matches all names in pattern according to NameToken.matches rules.

fun NameToken.matches(pattern: NameToken): Boolean

Checks if this token matches a given NameToken. The match successful if:

parseAsName
Link copied to clipboard
common
fun String.parseAsName(): Name
plus
Link copied to clipboard
common
operator fun Name.plus(other: String): Name
operator fun Name.plus(other: Name): Name
operator fun Name.plus(other: NameToken): Name
operator fun NameToken.plus(other: Name): Name
removeHeadOrNull
Link copied to clipboard
common
fun Name.removeHeadOrNull(head: Name): Name?

if this starts with given head name, returns the reminder of the name (could be empty). Otherwise, returns null

set
Link copied to clipboard
common
operator fun <T> MutableMap<Name, T>.set(name: String, value: T)
startsWith
Link copied to clipboard
common
fun Name.startsWith(name: Name): Boolean
fun Name.startsWith(token: NameToken): Boolean
withIndex
Link copied to clipboard
common
fun Name.withIndex(index: String): Name

Set or replace last token index

fun NameToken.withIndex(newIndex: String): NameToken

Add or replace index part of this token

Properties

length
Link copied to clipboard
common
val Name.length: Int