Elektra  0.9.7
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 Iterable< Key >.

Public Member Functions

void release ()
 Clean-up method to release key set reference by trying to free the native reference

Call this method if you have obtained a KeySet via any of its public methods or KDB#get(Key) and you do not longer need it. More...
 
Iterator< Keyiterator ()
 
String toString ()
 Iterates though all keys in this key set and appends their representation to the output. More...
 
KeySet dup ()
 Duplicates the key set. More...
 
KeySet copy (KeySet source)
 Copies key references from. More...
 
int size ()
 Indicates the key set size. More...
 
KeySet append (Key key)
 Append key to key set. More...
 
KeySet append (KeySet source)
 Appends keys from key set. More...
 
KeySet cut (Key cutpoint)
 Creates new key set with help of a cut point. More...
 
Key remove (int cursor)
 Returns key from key set and also removes it from the set. More...
 
Key first ()
 Gets the key set head key. More...
 
Key last ()
 Gets the key set tail key. More...
 
Key at (int cursor)
 Gets the key at the given cursor position. More...
 
Optional< Keylookup (Key find)
 Search for a key in the key set. More...
 
Optional< Keylookup (Key find, int options)
 Search for a key in the key set. More...
 
Optional< Keylookup (String find)
 Search for a key in the key set. More...
 
Optional< Keylookup (String find, int options)
 Search for a key in the key set. More...
 

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"));. More...
 
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"));. More...
 
static KeySet create ()
 Constructs an empty KeySet with a default allocation hint of 16. More...
 

Protected Member Functions

 KeySet (long nativePointer)
 Constructor associating a new KeySet instance with a native pointer in long format. More...
 
 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. More...
 
 KeySet (Pointer pointer)
 Constructor associating a new KeySet instance with a JNA pointer. More...
 
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)
inlineprotected

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

Parameters
nativePointerNative pointer to key set in long format

◆ KeySet() [2/3]

org.libelektra.KeySet.KeySet ( long  nativePointer,
boolean  suppressCleanUp 
)
inlineprotected

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
nativePointerNative pointer to key set in long format
suppressCleanUpTrue to suppress native reference clean-up as soon as this KeySet instance becomes phantom reachable, false otherwise
See also
release()

◆ KeySet() [3/3]

org.libelektra.KeySet.KeySet ( Pointer  pointer)
inlineprotected

Constructor associating a new KeySet instance with a JNA pointer.

Parameters
pointerJNA Pointer to key set
Exceptions
IllegalArgumentExceptionif
pointer
is
null
See also
release()

Member Function Documentation

◆ append() [1/2]

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

Append key to key set.

Parameters
keyKey to append
Returns
This KeySet, enabling a fluent interface
Exceptions
IllegalArgumentExceptionif
key
is
null
KeySetReleasedExceptionif this KeySet has already been released

◆ append() [2/2]

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

Appends keys from key set.

Parameters
sourceSource KeySet to append all of its keys
Returns
This KeySet, enabling a fluent interface
Exceptions
KeySetReleasedExceptionif this KeySet or the specified
source
has already been released
IllegalArgumentExceptionif
source
is
null
KeySetAppendExceptionif appending the
source
failed

◆ at()

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

Gets the key at the given cursor position.

Parameters
cursorCursor position used to fetch key; starting from 0
Returns
Key found at specified cursor position
Exceptions
KeySetReleasedExceptionif this KeySet has already been released
IndexOutOfBoundsExceptionif position is out of bounds
See also
Key::release()

◆ copy()

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

Copies key references from.

source

to this KeySet

Parameters
sourceKey set that is used as source
Returns
This KeySet, enabling a fluent interface
Exceptions
KeySetReleasedExceptionif this KeySet or the specified
source
has already been released
IllegalArgumentExceptionif
source
is
null

◆ create() [1/3]

static KeySet org.libelektra.KeySet.create ( )
inlinestatic

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

Returns
Newly allocated key set
See also
release()

◆ create() [2/3]

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

Constructs a new KeySet containing the specified keys

Example: KeySet keySet = KeySet.create(10, Key.create("A"), Key.create("B"));.

Parameters
allocationHintHint indicating the expected size of the key set
keysList of initial keys for the key set
Returns
New key set containing the specified initial keys
See also
release()

◆ create() [3/3]

static KeySet org.libelektra.KeySet.create ( Key...  keys)
inlinestatic

Constructs a new KeySet containing the specified keys

Example: KeySet keySet = KeySet.create(Key.create("A"), Key.create("B"));.

Parameters
keysList of initial keys for the key set
Returns
New key set containing the specified initial keys
See also
release()

◆ cut()

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

Creates new key set with help of a cut point.

Parameters
cutpointKey that is used as cutting point
Returns
New KeySet containing all keys until the cutting point, this if null was provided
Exceptions
KeySetReleasedExceptionif this KeySet has already been released
IllegalArgumentExceptionif
cutpoint
is
null
See also
release()

◆ dup()

KeySet org.libelektra.KeySet.dup ( )
inline

Duplicates the key set.

Returns
New KeySet containing the same key references as this KeySet does
Exceptions
KeySetReleasedExceptionif this KeySet has already been released
See also
release()

◆ first()

Key org.libelektra.KeySet.first ( )
inline

Gets the key set head key.

Returns
First element of the key set
Exceptions
KeySetReleasedExceptionif this KeySet has already been released
NoSuchElementExceptionif key set is empty
See also
Key::release()

◆ getPointer()

Pointer org.libelektra.KeySet.getPointer ( )
inlineprotected
Returns
JNA pointer to the native pointer for this key set
Exceptions
KeySetReleasedExceptionif 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

Gets the key set tail key.

Returns
Last element of the key set
Exceptions
KeySetReleasedExceptionif this KeySet has already been released
NoSuchElementExceptionif key set is empty
See also
Key::release()

◆ lookup() [1/4]

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

Search for a key in the key set.

Parameters
findKey used in search
Returns
Key if search successful, Optional#empty() otherwise
Exceptions
KeySetReleasedExceptionif this KeySet has already been released
IllegalArgumentExceptionif
key
is
null
See also
Key::release()

◆ lookup() [2/4]

Optional<Key> org.libelektra.KeySet.lookup ( Key  find,
int  options 
)
inline

Search for a key in the key set.

Parameters
findKey used in search
optionsCustom search options; concatenation of flags
Returns
Key if search successful, Optional#empty() otherwise
Exceptions
KeySetReleasedExceptionif this KeySet has already been released
IllegalArgumentExceptionif
find
is
null
See also
Key::release()

◆ lookup() [3/4]

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

Search for a key in the key set.

Parameters
findKey name used in search
Returns
Key if search successful, Optional#empty() otherwise
Exceptions
KeySetReleasedExceptionif this KeySet has already been released
IllegalArgumentExceptionif
find
is blank
See also
Key::release()

◆ lookup() [4/4]

Optional<Key> org.libelektra.KeySet.lookup ( String  find,
int  options 
)
inline

Search for a key in the key set.

Parameters
findKey name used in search
optionsCustom search options; concatenation of flags
Returns
Key if search successful, Optional#empty() otherwise
Exceptions
KeySetReleasedExceptionif this KeySet has already been released
IllegalArgumentExceptionif
find
is blank
See also
Key::release()

◆ release()

void org.libelektra.KeySet.release ( )
inline

Clean-up method to release key set reference by trying to free the native reference

Call this method if you have obtained a KeySet via any of its public methods or KDB#get(Key) and you do not longer need it.

If you do not manually release such key sets, they will get cleaned up by garbage collection as soon as they get phantom reachable. Therefore its encouraged to release key set instances as soon as you do not use them anymore.

◆ remove()

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

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

Parameters
cursorCursor position of the key to remove; starting from 0
Returns
Key found at given cursor position
Exceptions
KeySetReleasedExceptionif this KeySet has already been released
IndexOutOfBoundsExceptionif position is out of bounds
See also
Key::release()

◆ size()

int org.libelektra.KeySet.size ( )
inline

Indicates the key set size.

Returns
Number of keys contained by this key set
Exceptions
KeySetReleasedExceptionif 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: