$darkmode
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:
Inheritance graph
[legend]

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. More...
 
Key dup (int flags)
 Duplicates this ReadableKey as Key. More...
 
int compareTo (ReadableKey other)
 Compares this key with the. More...
 
boolean isBelow (ReadableKey other)
 Checks whether this key is sub-key of the. More...
 
boolean isBelowOrSame (ReadableKey other)
 Checks whether this key is the same as the. More...
 
boolean isDirectlyBelow (ReadableKey other)
 Checks whether this key is direct sub-key of the. More...
 
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. More...
 
static final int KEY_CP_VALUE = 1 << 2
 Flag for use with Key#copy(Key, int) and dup(int) for copying the key value. More...
 
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. More...
 
 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. More...
 
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< ReadableKeycreateReadOnly (@Nullable Pointer pointer)
 Constructs a new ReadableKey instance associated with a JNA pointer. More...
 

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)
inlineprotected

Constructor associating a new ReadableKey instance with a JNA pointer.

Parameters
pointerJNA Pointer to key

◆ ReadableKey() [2/2]

org.libelektra.ReadableKey.ReadableKey ( Pointer  pointer,
boolean  suppressCleanUp 
)
inlineprotected

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
pointerJNA Pointer to key
suppressCleanUpTrue 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
otherOther 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
IllegalStateExceptionif this or the
other
ReadableKey has already been released
IllegalArgumentExceptionif
other
is
null

◆ createReadOnly()

static Optional<ReadableKey> org.libelektra.ReadableKey.createReadOnly ( @Nullable Pointer  pointer)
inlinestaticprotected

Constructs a new ReadableKey instance associated with a JNA pointer.

Parameters
pointerOptional JNA Pointer to key
Returns
New ReadableKey instance if
pointer
is non-null, {} 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
KeyExceptionif copying failed
IllegalStateExceptionif 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
flagsFlags 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
KeyExceptionif copying failed
IllegalStateExceptionif 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
IllegalStateExceptionif this ReadableKey has already been released

◆ getBaseNameSize()

int org.libelektra.ReadableKey.getBaseNameSize ( )
inline
Returns
Length of key's base name
Exceptions
IllegalStateExceptionif 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
KeyStringValueExceptionif the underlying native key is not of type string
IllegalStateExceptionif this ReadableKey has already been released

◆ getByte()

byte org.libelektra.ReadableKey.getByte ( )
inline
Returns
getString() parsed as
byte
Exceptions
NumberFormatExceptionif the getString() does not return a parsable
byte
KeyStringValueExceptionif the underlying native key is not of type string
IllegalStateExceptionif this ReadableKey has already been released

◆ getDouble()

double org.libelektra.ReadableKey.getDouble ( )
inline
Returns
getString() parsed as
double
Exceptions
NumberFormatExceptionif the getString() does not return a parsable
double
KeyStringValueExceptionif the underlying native key is not of type string
IllegalStateExceptionif this ReadableKey has already been released

◆ getFloat()

float org.libelektra.ReadableKey.getFloat ( )
inline
Returns
getString() parsed as
float
Exceptions
NumberFormatExceptionif the getString() does not return a parsable
float
KeyStringValueExceptionif the underlying native key is not of type string
IllegalStateExceptionif this ReadableKey has already been released

◆ getInt()

int org.libelektra.ReadableKey.getInt ( )
inline
Returns
getString() parsed as integer
Exceptions
NumberFormatExceptionif the getString() does not return a parsable integer
KeyStringValueExceptionif the underlying native key is not of type string
IllegalStateExceptionif this ReadableKey has already been released

◆ getLong()

long org.libelektra.ReadableKey.getLong ( )
inline
Returns
getString() parsed as
long
Exceptions
NumberFormatExceptionif the getString() does not return a parsable
long
KeyStringValueExceptionif the underlying native key is not of type string
IllegalStateExceptionif this ReadableKey has already been released

◆ getName()

String org.libelektra.ReadableKey.getName ( )
inline
Returns
Key name (key part of "key-value" pair)
Exceptions
IllegalStateExceptionif this ReadableKey has already been released

◆ getNameSize()

int org.libelektra.ReadableKey.getNameSize ( )
inline
Returns
Length of key name
Exceptions
IllegalStateExceptionif this ReadableKey has already been released

◆ getPointer()

Pointer org.libelektra.ReadableKey.getPointer ( )
inlineprotected
Returns
JNA pointer to the native pointer for this key
Exceptions
IllegalStateExceptionif this ReadableKey has already been released

◆ getShort()

short org.libelektra.ReadableKey.getShort ( )
inline
Returns
getString() parsed as
short
Exceptions
NumberFormatExceptionif the getString() does not return a parsable
short
KeyStringValueExceptionif the underlying native key is not of type string
IllegalStateExceptionif this ReadableKey has already been released

◆ getString()

String org.libelektra.ReadableKey.getString ( )
inline
Returns
This key's value as string
Exceptions
KeyStringValueExceptionif the underlying native key is not of type string
IllegalStateExceptionif this ReadableKey has already been released

◆ getValueSize()

int org.libelektra.ReadableKey.getValueSize ( )
inline
Returns
Length / size of key value in bytes
Exceptions
IllegalStateExceptionif 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
otherKey that is used in check as parent key
Returns
Boolean if this key is (non-direct) sub-key of other-key
Exceptions
IllegalStateExceptionif this or the
other
ReadableKey has already been released
IllegalArgumentExceptionif
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
otherKey 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
IllegalStateExceptionif this or the
other
ReadableKey has already been released
IllegalArgumentExceptionif
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
IllegalStateExceptionif 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
otherKey that is used in check as parent key
Returns
Boolean if this key is direct sub-key of other key ("child")
Exceptions
IllegalStateExceptionif this or the
other
ReadableKey has already been released
IllegalArgumentExceptionif
other
is
null

◆ isNull()

boolean org.libelektra.ReadableKey.isNull ( )
inline
Returns
True, if the key has no value, false otherwise
Exceptions
IllegalStateExceptionif 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
IllegalStateExceptionif this ReadableKey has already been released

◆ keyNameIterator()

Iterator<String> org.libelektra.ReadableKey.keyNameIterator ( )
inline
Returns
New KeyNameIterator backed by this ReadableKey
Exceptions
IllegalStateExceptionif 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: