| Elektra 0.11.0

Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | List of all members
org.libelektra.ReadableKey Class Reference

Read only key representing a native Elektra key providing read access to its name and value. More...

Inheritance diagram for org.libelektra.ReadableKey:

## Public Member Functions
String | toString ()
Iterator< String > | keyNameIterator ()
boolean | getBoolean ()
byte | getByte ()
short | getShort ()
int | getInt ()
long | getLong ()
float | getFloat ()
double | getDouble ()
String | getString ()
Key | dup ()
| Duplicates this `ReadableKey` as `Key`.
Key | dup (int flags)
| Duplicates this `ReadableKey` as `Key`.
int | compareTo (ReadableKey other)
| Compares this key with the `other` key by comparing the key name with string comparison.
boolean | isBelow (ReadableKey other)
| Checks whether this key is sub-key of the `other` key.
boolean | isBelowOrSame (ReadableKey other)
| Checks whether this key is the same as the `other` key or a sub-key of the `other` key.
boolean | isDirectlyBelow (ReadableKey other)
| Checks whether this key is direct sub-key of the `other` key.
boolean | isBinary ()
boolean | isString ()
String | getName ()
int | getNameSize ()
String | getBaseName ()
int | getBaseNameSize ()
int | getValueSize ()
boolean | isNull ()

## Static Public Attributes
static final int | KEY_CP_NAME = 1 << 0
| Flag for use with `Key#copy(Key, int)` and `dup(int)` for copying the key name.
static final int | KEY_CP_STRING = 1 << 1
| Flag for use with `Key#copy(Key, int)` and `dup(int)` for copying the key value, if it is a string.
static final int | KEY_CP_VALUE = 1 << 2
| Flag for use with `Key#copy(Key, int)` and `dup(int)` for copying the key value.
static final int | KEY_CP_META = 1 << 3
| Flag for use with `Key#copy(Key, int)` and `dup(int)` for copying the key metadata.
static final int | KEY_CP_ALL = KEY_CP_NAME | KEY_CP_VALUE | KEY_CP_META
| Flag for use with `Key#copy(Key, int)` and `dup(int)` for copying the key name, value and metadata.

## Protected Member Functions
| ReadableKey (Pointer pointer)
| Constructor associating a new `ReadableKey` instance with a JNA pointer.
| ReadableKey (Pointer pointer, boolean suppressCleanUp)
| Constructor associating a new `ReadableKey` instance with a JNA pointer Suppressing clean-up has been introduced for usage of this binding as JNI plug-in and should normally not be used in any other case.
void | release ()
| Clean-up method to release key reference by first decrementing its reference counter and then trying to free the native reference `keys`, will get cleaned up by garbage collection as soon as they get phantom reachable.
Pointer | getPointer ()

## Static Protected Member Functions
static Optional< ReadableKey > | createReadOnly (@Nullable Pointer pointer)
| Constructs a new `ReadableKey` instance associated with a JNA pointer.

## Detailed Description

Read only key representing a native Elektra key providing read access to its name and value.

@apiNote This abstraction is used to represent meta keys being read only by definition and cannot contain binary data

## Constructor & Destructor Documentation

## ◆ ReadableKey() [1/2]

org.libelektra.ReadableKey.ReadableKey | ( | Pointer | pointer | ) |
| inline protected

Constructor associating a new `ReadableKey` instance with a JNA pointer.

Parameters

  pointer | JNA `Pointer` to key

## ◆ ReadableKey() [2/2]

org.libelektra.ReadableKey.ReadableKey | ( | Pointer | pointer,
|  | boolean | suppressCleanUp
| ) |  |
| inline protected

Constructor associating a new `ReadableKey` instance with a JNA pointer
Suppressing clean-up has been introduced for usage of this binding as JNI plug-in and should normally not be used in any other case.

Parameters

  pointer | JNA `Pointer` to key
  suppressCleanUp | True to suppress native reference clean-up as soon as this `Key` instance becomes phantom reachable, false otherwise

## Member Function Documentation

## ◆ compareTo()

int org.libelektra.ReadableKey.compareTo | ( | ReadableKey | other | ) |
| inline

Compares this key with the `other` key by comparing the key name with string comparison.

Parameters

  other | Other key to compare this key to

Returns
  - 0 if key name is equal
  - -1 if this key name has lower alphabetical order than the `other` key
  - 1 if this key has higher alphabetical order

Exceptions

  IllegalStateException | if this or the `other` `ReadableKey` has already been released
  IllegalArgumentException | if `other` is `null`

## ◆ createReadOnly()

static Optional< ReadableKey > org.libelektra.ReadableKey.createReadOnly | ( | @Nullable Pointer | pointer | ) |
| inline static protected

Constructs a new `ReadableKey` instance associated with a JNA pointer.

Parameters

  pointer | Optional JNA `Pointer` to key

Returns
  New `ReadableKey` instance if `pointer` is non-null, `Optional#empty()` otherwise

## ◆ dup() [1/2]

Key org.libelektra.ReadableKey.dup | ( |  | ) |
| inline

Duplicates this `ReadableKey` as `Key`.

Returns
  New `Key` object containing the same information as this key

Exceptions

  KeyException | if copying failed
  IllegalStateException | if this `ReadableKey` has already been released

See also
  #dup(int)

## ◆ dup() [2/2]

Key org.libelektra.ReadableKey.dup | ( | int | flags | ) |
| inline

Duplicates this `ReadableKey` as `Key`.

Parameters

  flags | Flags indicating which parts of the key to copy Example: `KEY_CP_NAME` | `KEY_CP_VALUE`

Returns
  New `Key` object containing the same information as this key

Exceptions

  KeyException | if copying failed
  IllegalStateException | if this `ReadableKey` has already been released

See also
  #dup()
  KEY_CP_ALL
  KEY_CP_META
  KEY_CP_NAME
  KEY_CP_STRING
  KEY_CP_VALUE

## ◆ getBaseName()

String org.libelektra.ReadableKey.getBaseName | ( |  | ) |
| inline

Returns
  Key's base name as String

Exceptions

  IllegalStateException | if this `ReadableKey` has already been released

## ◆ getBaseNameSize()

int org.libelektra.ReadableKey.getBaseNameSize | ( |  | ) |
| inline

Returns
  Length of key's base name

Exceptions

  IllegalStateException | if this `ReadableKey` has already been released

## ◆ getBoolean()

boolean org.libelektra.ReadableKey.getBoolean | ( |  | ) |
| inline

See also
  Definition of Bool

Returns
  `getString()` interpreted as boolean value

Exceptions

  KeyStringValueException | if the underlying native key is not of type string
  IllegalStateException | if this `ReadableKey` has already been released

## ◆ getByte()

byte org.libelektra.ReadableKey.getByte | ( |  | ) |
| inline

Returns
  `getString()` parsed as `byte`

Exceptions

  NumberFormatException | if the `getString()` does not return a parsable `byte`
  KeyStringValueException | if the underlying native key is not of type string
  IllegalStateException | if this `ReadableKey` has already been released

## ◆ getDouble()

double org.libelektra.ReadableKey.getDouble | ( |  | ) |
| inline

Returns
  `getString()` parsed as `double`

Exceptions

  NumberFormatException | if the `getString()` does not return a parsable `double`
  KeyStringValueException | if the underlying native key is not of type string
  IllegalStateException | if this `ReadableKey` has already been released

## ◆ getFloat()

float org.libelektra.ReadableKey.getFloat | ( |  | ) |
| inline

Returns
  `getString()` parsed as `float`

Exceptions

  NumberFormatException | if the `getString()` does not return a parsable `float`
  KeyStringValueException | if the underlying native key is not of type string
  IllegalStateException | if this `ReadableKey` has already been released

## ◆ getInt()

int org.libelektra.ReadableKey.getInt | ( |  | ) |
| inline

Returns
  `getString()` parsed as integer

Exceptions

  NumberFormatException | if the `getString()` does not return a parsable integer
  KeyStringValueException | if the underlying native key is not of type string
  IllegalStateException | if this `ReadableKey` has already been released

## ◆ getLong()

long org.libelektra.ReadableKey.getLong | ( |  | ) |
| inline

Returns
  `getString()` parsed as `long`

Exceptions

  NumberFormatException | if the `getString()` does not return a parsable `long`
  KeyStringValueException | if the underlying native key is not of type string
  IllegalStateException | if this `ReadableKey` has already been released

## ◆ getName()

String org.libelektra.ReadableKey.getName | ( |  | ) |
| inline

Returns
  Key name (key part of "key-value" pair)

Exceptions

  IllegalStateException | if this `ReadableKey` has already been released

## ◆ getNameSize()

int org.libelektra.ReadableKey.getNameSize | ( |  | ) |
| inline

Returns
  Length of key name

Exceptions

  IllegalStateException | if this `ReadableKey` has already been released

## ◆ getPointer()

Pointer org.libelektra.ReadableKey.getPointer | ( |  | ) |
| inline protected

Returns
  JNA pointer to the native pointer for this key

Exceptions

  IllegalStateException | if this `ReadableKey` has already been released

## ◆ getShort()

short org.libelektra.ReadableKey.getShort | ( |  | ) |
| inline

Returns
  `getString()` parsed as `short`

Exceptions

  NumberFormatException | if the `getString()` does not return a parsable `short`
  KeyStringValueException | if the underlying native key is not of type string
  IllegalStateException | if this `ReadableKey` has already been released

## ◆ getString()

String org.libelektra.ReadableKey.getString | ( |  | ) |
| inline

Returns
  This key's value as string

Exceptions

  KeyStringValueException | if the underlying native key is not of type string
  IllegalStateException | if this `ReadableKey` has already been released

## ◆ getValueSize()

int org.libelektra.ReadableKey.getValueSize | ( |  | ) |
| inline

Returns
  Length / size of key value in bytes

Exceptions

  IllegalStateException | if this `ReadableKey` has already been released

## ◆ isBelow()

boolean org.libelektra.ReadableKey.isBelow | ( | ReadableKey | other | ) |
| inline

Checks whether this key is sub-key of the `other` key.

Parameters

  other | Key that is used in check as parent key

Returns
  Boolean if this key is (non-direct) sub-key of other-key

Exceptions

  IllegalStateException | if this or the `other` `ReadableKey` has already been released
  IllegalArgumentException | if `other` is `null`

## ◆ isBelowOrSame()

boolean org.libelektra.ReadableKey.isBelowOrSame | ( | ReadableKey | other | ) |
| inline

Checks whether this key is the same as the `other` key or a sub-key of the `other` key.

Parameters

  other | Key that is used in check as parent key

Returns
  Boolean if this key is other key or (non-direct) sub-key of other-key

Exceptions

  IllegalStateException | if this or the `other` `ReadableKey` has already been released
  IllegalArgumentException | if `other` is `null`

## ◆ isBinary()

boolean org.libelektra.ReadableKey.isBinary | ( |  | ) |
| inline

Returns
  True if the underlying native key's value is of type binary, false otherwise

Exceptions

  IllegalStateException | if this `ReadableKey` has already been released

## ◆ isDirectlyBelow()

boolean org.libelektra.ReadableKey.isDirectlyBelow | ( | ReadableKey | other | ) |
| inline

Checks whether this key is direct sub-key of the `other` key.

Parameters

  other | Key that is used in check as parent key

Returns
  Boolean if this key is direct sub-key of other key ("child")

Exceptions

  IllegalStateException | if this or the `other` `ReadableKey` has already been released
  IllegalArgumentException | if `other` is `null`

## ◆ isNull()

boolean org.libelektra.ReadableKey.isNull | ( |  | ) |
| inline

Returns
  True, if the key has no value, false otherwise

Exceptions

  IllegalStateException | if this `ReadableKey` has already been released

## ◆ isString()

boolean org.libelektra.ReadableKey.isString | ( |  | ) |
| inline

Returns
  True if the underlying native key's value is a valid string, false otherwise

Exceptions

  IllegalStateException | if this `ReadableKey` has already been released

## ◆ keyNameIterator()

Iterator< String > org.libelektra.ReadableKey.keyNameIterator | ( |  | ) |
| inline

Returns
  New `KeyNameIterator` backed by this `ReadableKey`

Exceptions

  IllegalStateException | if this `ReadableKey` has already been released

## ◆ toString()

String org.libelektra.ReadableKey.toString | ( |  | ) |
| inline

Returns
  Key name in string format as returned by `getName()`

## Member Data Documentation

## ◆ KEY_CP_STRING

final int org.libelektra.ReadableKey.KEY_CP_STRING = 1 << 1
| static

Flag for use with `Key#copy(Key, int)` and `dup(int)` for copying the key value, if it is a string.

@apiNote Do not use together with `KEY_CP_VALUE`

## ◆ KEY_CP_VALUE

final int org.libelektra.ReadableKey.KEY_CP_VALUE = 1 << 2
| static

Flag for use with `Key#copy(Key, int)` and `dup(int)` for copying the key value.

@apiNote Do not use together with `KEY_CP_STRING`

The documentation for this class was generated from the following file:

- ReadableKey.java