| Elektra 0.11.0

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

Java representation of a native Elektra key set, a container for keys. More...

Inherits AbstractSet< Key >, and NavigableSet< Key >.

## Public Member Functions
KeySet | dup ()
| Duplicates the key set.
KeySet | copy (KeySet source)
| Copies key references from `source` to this `KeySet`.
KeySet | append (Key key)
| Append key to key set.
KeySet | append (KeySet source)
| Appends keys from key set.
KeySet | cut (Key cutpoint)
| Creates new key set with help of a cut point.
Optional< Key > | remove (ReadableKey key)
| Removes the specified key from key set.
Optional< Key > | remove (String find)
| Removes the key with the specified name from key set.
Key | remove (int cursor)
| Returns key from key set and also removes it from the set.
Key | at (int cursor)
| Gets the key at the given cursor position.
int | indexOf (Key key)
Optional< Key > | lookup (Key find)
| Search for a key in the key set.
Optional< Key > | lookup (String find)
| Search for a key in the key set.
String | toString ()
| Iterates though all keys in this key set and appends their representation to the output.
int | size ()
boolean | isEmpty ()
boolean | contains (@Nullable Object o)
Key | lower (Key key)
Key | floor (Key key)
Key | ceiling (Key key)
Key | higher (Key key)
Key | pollFirst ()
Key | pollLast ()
Iterator< Key > | iterator ()
NavigableSet< Key > | descendingSet ()
Iterator< Key > | descendingIterator ()
NavigableSet< Key > | subSet (Key fromElement, boolean fromInclusive, Key toElement, boolean toInclusive)
NavigableSet< Key > | headSet (Key toElement, boolean inclusive)
NavigableSet< Key > | tailSet (Key fromElement, boolean inclusive)
Object[] | toArray ()
boolean | add (Key e)
boolean | remove (Object o)
boolean | containsAll (Collection<?> c)
boolean | addAll (Collection<? extends Key > c)
boolean | retainAll (Collection<?> c)
boolean | removeAll (Collection<?> c)
void | clear ()
| Removes all elements form this `KeySet`.
Comparator<? super Key > | comparator ()
SortedSet< Key > | subSet (Key fromElement, Key toElement)
SortedSet< Key > | headSet (Key toElement)
SortedSet< Key > | tailSet (Key fromElement)
Key | first ()
Key | last ()

## Static Public Member Functions
static KeySet | create (Key... keys)
| Constructs a new `KeySet` containing the specified `keys` Example: KeySet keySet = KeySet.create(Key.create("A"), Key.create("B"));.
static KeySet | create (int allocationHint, Key... keys)
| Constructs a new `KeySet` containing the specified `keys` Example: KeySet keySet = KeySet.create(10, Key.create("A"), Key.create("B"));.
static KeySet | create ()
| Constructs an empty `KeySet` with a default allocation hint of 16.

## Protected Member Functions
| KeySet (long nativePointer)
| Constructor associating a new `KeySet` instance with a native pointer in long format.
| KeySet (long nativePointer, boolean suppressCleanUp)
| Constructor associating a new `KeySet` instance with a native pointer in long format 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.
| KeySet (Pointer pointer)
| Constructor associating a new `KeySet` instance with a JNA pointer.
void | release ()
| Clean-up method to release key set reference by trying to free the native reference `key sets`, will get cleaned up by garbage collection as soon as they get phantom reachable.
Pointer | getPointer ()

## Detailed Description

Java representation of a native Elektra key set, a container for keys.

## Constructor & Destructor Documentation

## ◆ KeySet() [1/3]

org.libelektra.KeySet.KeySet | ( | long | nativePointer | ) |
| inline protected

Constructor associating a new `KeySet` instance with a native pointer in long format.

Parameters

  nativePointer | Native pointer to key set in long format

## ◆ KeySet() [2/3]

org.libelektra.KeySet.KeySet | ( | long | nativePointer,
|  | boolean | suppressCleanUp
| ) |  |
| inline protected

Constructor associating a new `KeySet` instance with a native pointer in long format
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

  nativePointer | Native pointer to key set in long format
  suppressCleanUp | True to suppress native reference clean-up as soon as this `KeySet` instance becomes phantom reachable, false otherwise

## ◆ KeySet() [3/3]

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

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

Parameters

  pointer | JNA `Pointer` to key set

Exceptions

  IllegalArgumentException | if `pointer` is `null`

## Member Function Documentation

## ◆ add()

boolean org.libelektra.KeySet.add | ( | Key | e | ) |
| inline

Exceptions

  IllegalStateException | if this `KeySet` or the specified `key` has already been released
  NullPointerException | if `key` is `null`
  KeySetException | if inserting the `key` failed because of allocation problems

See also
  #append(Key)

## ◆ addAll()

boolean org.libelektra.KeySet.addAll | ( | Collection<? extends Key > | c | ) |
| inline

Exceptions

  IllegalStateException | if this `KeySet` or any `Key` contained in the specified collection `c` has already been released
  NullPointerException | if the specified collection is `null` or contains `null` elements
  KeySetException | if inserting the `key` failed because of allocation problems

## ◆ append() [1/2]

KeySet org.libelektra.KeySet.append | ( | Key | key | ) |
| inline

Append key to key set.

Parameters

  key | `Key` to append

Returns
  This `KeySet`, enabling a fluent interface

Exceptions

  IllegalStateException | if this `KeySet` or the specified `key` has already been released
  IllegalArgumentException | if `key` is `null`
  KeySetException | if appending the `key` failed because of allocation problems

See also
  #add(Key)

## ◆ append() [2/2]

KeySet org.libelektra.KeySet.append | ( | KeySet | source | ) |
| inline

Appends keys from key set.

Parameters

  source | Source `KeySet` to append all of its `keys`

Returns
  This `KeySet`, enabling a fluent interface

Exceptions

  IllegalStateException | if this `KeySet` or the specified `source` has already been released
  IllegalArgumentException | if `source` is `null`
  KeySetException | if appending the `source` failed because of allocation problems

## ◆ at()

Key org.libelektra.KeySet.at | ( | int | cursor | ) |
| inline

Gets the key at the given cursor position.

Parameters

  cursor | Cursor position used to fetch key; starting from 0

Returns
  Key found at specified cursor position

Exceptions

  IllegalStateException | if this `KeySet` has already been released
  IndexOutOfBoundsException | if position is out of bounds

## ◆ ceiling()

Key org.libelektra.KeySet.ceiling | ( | Key | key | ) |
| inline

Exceptions

  IllegalStateException | if this `KeySet` has already been released

## ◆ clear()

void org.libelektra.KeySet.clear | ( |  | ) |
| inline

Removes all elements form this `KeySet`.

Exceptions

  IllegalStateException | if this `KeySet` has already been released

## ◆ comparator()

Comparator<? super Key > org.libelektra.KeySet.comparator | ( |  | ) |
| inline

@implSpec Returns `null` because natural ordering of keys is used (`ReadableKey` implements `Comparable`)

Exceptions

  IllegalStateException | if this `KeySet` has already been released

## ◆ contains()

boolean org.libelektra.KeySet.contains | ( | @Nullable Object | o | ) |
| inline

Exceptions

  IllegalStateException | if this `KeySet` has already been released or the passed `o` is a `Key` that has already been released
  NullPointerException | if the specified element `o` is `null`

See also
  #lookup(Key)

## ◆ containsAll()

boolean org.libelektra.KeySet.containsAll | ( | Collection<?> | c | ) |
| inline

Exceptions

  IllegalStateException | if this `KeySet` has already been released
  NullPointerException | if the specified collection is `null` or contains `null` elements

## ◆ copy()

KeySet org.libelektra.KeySet.copy | ( | KeySet | source | ) |
| inline

Copies key references from `source` to this `KeySet`.

Parameters

  source | Key set that is used as source

Returns
  This `KeySet`, enabling a fluent interface

Exceptions

  IllegalStateException | if this `KeySet` or the specified `source` has already been released
  IllegalArgumentException | if `source` is `null`

## ◆ create() [1/3]

static KeySet org.libelektra.KeySet.create | ( |  | ) |
| inline static

Constructs an empty `KeySet` with a default allocation hint of 16.

Returns
  Newly allocated key set

Exceptions

  KeySetException | on allocation problems

## ◆ create() [2/3]

static KeySet org.libelektra.KeySet.create | ( | int | allocationHint,
|  | Key... | keys
| ) |  |
| inline static

Constructs a new `KeySet` containing the specified `keys`
Example: KeySet keySet = KeySet.create(10, Key.create("A"), Key.create("B"));.

Parameters

  allocationHint | Hint indicating the expected size of the key set
  keys | List of initial keys for the key set

Returns
  New key set containing the specified initial keys

Exceptions

  KeySetException | on allocation problems

## ◆ create() [3/3]

static KeySet org.libelektra.KeySet.create | ( | Key... | keys | ) |
| inline static

Constructs a new `KeySet` containing the specified `keys`
Example: KeySet keySet = KeySet.create(Key.create("A"), Key.create("B"));.

Parameters

  keys | List of initial keys for the key set

Returns
  New key set containing the specified initial keys

Exceptions

  KeySetException | on allocation problems

## ◆ cut()

KeySet org.libelektra.KeySet.cut | ( | Key | cutpoint | ) |
| inline

Creates new key set with help of a cut point.

Parameters

  cutpoint | Key that is used as cutting point

Returns
  New `KeySet` containing all keys until the cutting point

Exceptions

  IllegalStateException | if this `KeySet` has already been released
  IllegalArgumentException | if `cutpoint` is `null`
  KeySetException | if `cutpoint` is missing a key name or on allocation problems

## ◆ descendingIterator()

Iterator< Key > org.libelektra.KeySet.descendingIterator | ( |  | ) |
| inline

Returns
  New `DescendingKeySetIterator` backed by this `KeySet`

## ◆ descendingSet()

NavigableSet< Key > org.libelektra.KeySet.descendingSet | ( |  | ) |
| inline

Returns
  New `DescendingKeySetView` backed by this `KeySet`

## ◆ dup()

KeySet org.libelektra.KeySet.dup | ( |  | ) |
| inline

Duplicates the key set.

Returns
  New `KeySet` containing the same key references as this `KeySet` does

Exceptions

  IllegalStateException | if this `KeySet` has already been released

## ◆ first()

Key org.libelektra.KeySet.first | ( |  | ) |
| inline

Exceptions

  IllegalStateException | if this `KeySet` has already been released
  NoSuchElementException |

## ◆ floor()

Key org.libelektra.KeySet.floor | ( | Key | key | ) |
| inline

Exceptions

  IllegalStateException | if this `KeySet` has already been released

## ◆ getPointer()

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

Returns
  JNA pointer to the native pointer for this key set

Exceptions

  IllegalStateException | if this `KeySet` has already been released

## ◆ headSet() [1/2]

SortedSet< Key > org.libelektra.KeySet.headSet | ( | Key | toElement | ) |
| inline

Exceptions

  IllegalStateException | if this `KeySet` has already been released
  NullPointerException | if `toElement` is `null`
  IllegalArgumentException |

## ◆ headSet() [2/2]

NavigableSet< Key > org.libelektra.KeySet.headSet | ( | Key | toElement,
|  | boolean | inclusive
| ) |  |
| inline

Exceptions

  IllegalStateException | if this `KeySet` has already been released
  NullPointerException | if `toElement` is `null`
  IllegalArgumentException |

## ◆ higher()

Key org.libelektra.KeySet.higher | ( | Key | key | ) |
| inline

Exceptions

  IllegalStateException | if this `KeySet` has already been released

## ◆ indexOf()

int org.libelektra.KeySet.indexOf | ( | Key | key | ) |
| inline

Parameters

  key | Key to look for

Returns
  Index of the `key` in this `KeySet`

Exceptions

  IllegalStateException | if `KeySet` or `key` has already been released
  IllegalArgumentException | if `key` was not found in this `KeySet`

## ◆ isEmpty()

boolean org.libelektra.KeySet.isEmpty | ( |  | ) |
| inline

Exceptions

  IllegalStateException | if this `KeySet` has already been released

## ◆ iterator()

Iterator< Key > org.libelektra.KeySet.iterator | ( |  | ) |
| inline

Returns
  New `KeySetIterator` backed by this `KeySet`

## ◆ last()

Key org.libelektra.KeySet.last | ( |  | ) |
| inline

Exceptions

  IllegalStateException | if this `KeySet` has already been released
  NoSuchElementException |

## ◆ lookup() [1/2]

Optional< Key > org.libelektra.KeySet.lookup | ( | Key | find | ) |
| inline

Search for a key in the key set.

Parameters

  find | Key used in search

Returns
  Key if search successful, `Optional#empty()` otherwise

Exceptions

  IllegalStateException | if this `KeySet` has already been released
  IllegalArgumentException | if `key` is `null`

See also
  #contains(Object)

## ◆ lookup() [2/2]

Optional< Key > org.libelektra.KeySet.lookup | ( | String | find | ) |
| inline

Search for a key in the key set.

Parameters

  find | Key name used in search

Returns
  Key if search successful, `Optional#empty()` otherwise

Exceptions

  IllegalStateException | if this `KeySet` has already been released
  IllegalArgumentException | if `find` is `blank`

## ◆ lower()

Key org.libelektra.KeySet.lower | ( | Key | key | ) |
| inline

Exceptions

  IllegalStateException | if this `KeySet` has already been released

## ◆ pollFirst()

Key org.libelektra.KeySet.pollFirst | ( |  | ) |
| inline

Exceptions

  IllegalStateException | if this `KeySet` has already been released

## ◆ pollLast()

Key org.libelektra.KeySet.pollLast | ( |  | ) |
| inline

Exceptions

  IllegalStateException | if this `KeySet` has already been released

## ◆ remove() [1/4]

Key org.libelektra.KeySet.remove | ( | int | cursor | ) |
| inline

Returns key from key set and also removes it from the set.

Parameters

  cursor | Cursor position of the key to remove; starting from 0

Returns
  Key found at given cursor position

Exceptions

  IllegalStateException | if this `KeySet` has already been released
  IndexOutOfBoundsException | if position is out of bounds

## ◆ remove() [2/4]

boolean org.libelektra.KeySet.remove | ( | Object | o | ) |
| inline

Exceptions

  IllegalStateException | if this `KeySet` has already been released

See also
  #remove(ReadableKey)

## ◆ remove() [3/4]

Optional< Key > org.libelektra.KeySet.remove | ( | ReadableKey | key | ) |
| inline

Removes the specified key from key set.

Parameters

  key | Key to remove

Returns
  Removed `Key` from the key set, matching the specified `key`'s name. May or may not reference the same native key resource. `Optional#empty()` if the specified `key` was not found.

Exceptions

  IllegalStateException | if `KeySet` or `key` has already been released
  IllegalArgumentException | if `key` is `null`

See also
  #remove(Object)

## ◆ remove() [4/4]

Optional< Key > org.libelektra.KeySet.remove | ( | String | find | ) |
| inline

Removes the key with the specified name from key set.

Parameters

  find | Name of the key to remove

Returns
  Removed `Key` from the key set, matching the specified `key`'s name. `Optional#empty()` if the no key matching the specified name was not found.

Exceptions

  IllegalStateException | if this `KeySet` has already been released
  IllegalArgumentException | if `find` is `blank`

## ◆ removeAll()

boolean org.libelektra.KeySet.removeAll | ( | Collection<?> | c | ) |
| inline

Exceptions

  IllegalStateException | if this `KeySet` has already been released
  NullPointerException | if the specified collection is `null` or contains `null` elements

## ◆ retainAll()

boolean org.libelektra.KeySet.retainAll | ( | Collection<?> | c | ) |
| inline

Exceptions

  IllegalStateException | if this `KeySet` has already been released
  NullPointerException | if the specified collection is `null` or contains `null` elements

## ◆ size()

int org.libelektra.KeySet.size | ( |  | ) |
| inline

Exceptions

  IllegalStateException | if this `KeySet` has already been released

## ◆ subSet() [1/2]

NavigableSet< Key > org.libelektra.KeySet.subSet | ( | Key | fromElement,
|  | boolean | fromInclusive,
|  | Key | toElement,
|  | boolean | toInclusive
| ) |  |
| inline

Exceptions

  IllegalStateException | if this `KeySet` has already been released
  NullPointerException | if `fromElement` or `toElement` is `null`
  IllegalArgumentException |

## ◆ subSet() [2/2]

SortedSet< Key > org.libelektra.KeySet.subSet | ( | Key | fromElement,
|  | Key | toElement
| ) |  |
| inline

Exceptions

  IllegalStateException | if this `KeySet` has already been released
  NullPointerException | if `fromElement` or `toElement` is `null`
  IllegalArgumentException |

## ◆ tailSet() [1/2]

SortedSet< Key > org.libelektra.KeySet.tailSet | ( | Key | fromElement | ) |
| inline

Exceptions

  IllegalStateException | if this `KeySet` has already been released
  NullPointerException | if `fromElement` is `null`
  IllegalArgumentException |

## ◆ tailSet() [2/2]

NavigableSet< Key > org.libelektra.KeySet.tailSet | ( | Key | fromElement,
|  | boolean | inclusive
| ) |  |
| inline

Exceptions

  IllegalStateException | if this `KeySet` has already been released
  NullPointerException | if `fromElement` is `null`
  IllegalArgumentException |

## ◆ toArray()

Object[] org.libelektra.KeySet.toArray | ( |  | ) |
| inline

Exceptions

  IllegalStateException | if this `KeySet` has already been released

## ◆ toString()

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

Iterates though all keys in this key set and appends their representation to the output.

Uses the toString() function of the Key objects.

Returns
  Represents this `KeySet` as string

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

- KeySet.java