DataItem

sealed class DataItem

Abstract base class for CBOR data items.

Instances of DataItem are immutable and implement the equals, hashCode, and toString methods.

To assist with parsing, a number of helper properties are included on this class to access the data using specific types. These include asBstr, asTstr, asNumber etc. for primitive types and also include higher-level types such as asCoseSign1 to get a CoseSign1.

CBOR maps and CBOR arrays can be accessed using the get method which is also available via the bracket operator. Note that get will throw if the requested key isn't available in the map. The hasKey, getOrDefault, or getOrNull methods can be used in situations where the key is optional.

Parameters

majorType

the CBOR major type of the data item.

Inheritors

Properties

Link copied to clipboard

The value of a CborArray data item.

Link copied to clipboard

The value of a Simple data item containing either true/false.

Link copied to clipboard

The value of a Bstr data item.

Link copied to clipboard

The value of a data item containing a COSE_Key.

Link copied to clipboard

The value of a data item containing a COSE label (either number or string)

Link copied to clipboard

The value of a data item containing a COSE_Mac0.

Link copied to clipboard

The value of a data item containing a COSE_Sign1.

Link copied to clipboard
val asDateString: LocalDate

The date-time from a tstr with tag Tagged.FULL_DATE_STRING.

Link copied to clipboard
val asDateTimeString: Instant

The date-time from a tstr with tag Tagged.DATE_TIME_STRING.

Link copied to clipboard

The value of a Double data item.

Link copied to clipboard

The value of a Float data item.

Link copied to clipboard

The value of a CborMap data item.

Link copied to clipboard

The value of a Uint or Nint data item.

Link copied to clipboard

The value of a Tagged data item.

Link copied to clipboard

The decoded CBOR from a bstr with tag Tagged.ENCODED_CBOR.

Link copied to clipboard

The value of a Tstr data item.

Link copied to clipboard

The value of a data item containing a certificate.

Link copied to clipboard

The value of a data item containing a certificate chain.

Link copied to clipboard

Functions

Link copied to clipboard
operator fun get(key: Long): DataItem

Gets the value of a key in a map or an index in an array

operator fun get(key: String): DataItem
operator fun get(key: DataItem): DataItem

Gets the value of a key in a map.

Link copied to clipboard
fun getOrDefault(key: Long, defaultValue: DataItem): DataItem
fun getOrDefault(key: String, defaultValue: DataItem): DataItem
fun getOrDefault(key: DataItem, defaultValue: DataItem): DataItem

Gets the value of a key in a map or a default value if the key doesn't exist.

Link copied to clipboard
fun getOrNull(key: Long): DataItem?

Gets the value of a key in a map or null if the key doesn't exist.

Link copied to clipboard
fun hasKey(key: Long): Boolean
fun hasKey(key: String): Boolean

Returns whether a map has a value for a given key