Interface for key-value storage operations, allowing storage and retrieval of various data types.
More...
|
| abstract boolean | contains (String key) |
| |
| abstract ArrayList< String > | getKeys () |
| |
| abstract int | getInt (String key, int defaultValue) |
| |
| abstract long | getLong (String key, long defaultValue) |
| |
| abstract boolean | getBool (String key, boolean defaultValue) |
| |
| abstract float | getFloat (String key, float defaultValue) |
| |
| abstract double | getDouble (String key, double defaultValue) |
| |
| abstract String | getString (String key, String defaultValue) |
| |
| abstract void | putInt (String key, int value) |
| |
| abstract void | putLong (String key, long value) |
| |
| abstract void | putBool (String key, boolean value) |
| |
| abstract void | putFloat (String key, float value) |
| |
| abstract void | putDouble (String key, double value) |
| |
| abstract void | putString (String key, String value) |
| |
| abstract void | remove (String key) |
| |
| abstract void | clear () |
| |
Interface for key-value storage operations, allowing storage and retrieval of various data types.
Referenced from StorageManager.
Definition at line 17 of file KeyValueStorage.java.
◆ clear()
| abstract void com.navigine.idl.java.KeyValueStorage.clear |
( |
| ) |
|
|
abstract |
Removes all entries from the storage.
Java code snippet:
userStorage.clear();
System.out.println("Cleared all data from user storage");
Kotlin code snippet:
// Clear all data
userStorage!!.clear()
println("Cleared all data from user storage")
◆ contains()
| abstract boolean com.navigine.idl.java.KeyValueStorage.contains |
( |
String | key | ) |
|
|
abstract |
Checks whether the key exists in the storage.
- Parameters
-
- Returns
- true if a value is stored under the key (regardless of type).
Java code snippet:
boolean hasUserName = userStorage.contains("user_name");
boolean hasNonExistent = userStorage.contains("non_existent_key");
System.out.println("Contains 'user_name': " + hasUserName);
System.out.println("Contains 'non_existent_key': " + hasNonExistent);
Kotlin code snippet:
// Check if keys exist
val hasUserName: Boolean = userStorage!!.contains("user_name")
val hasNonExistent: Boolean = userStorage!!.contains("non_existent_key")
println("Contains 'user_name': $hasUserName")
println("Contains 'non_existent_key': $hasNonExistent")
◆ getBool()
| abstract boolean com.navigine.idl.java.KeyValueStorage.getBool |
( |
String | key, |
|
|
boolean | defaultValue ) |
|
abstract |
Gets a boolean value. Returns defaultValue if the key is missing or the stored type is not bool.
- Parameters
-
| key | Lookup key. |
| defaultValue | Value to return when not found or type mismatch. |
- Returns
- Stored bool or defaultValue.
Java code snippet:
boolean isPremium = userStorage.getBool("is_premium", false);
boolean notificationsEnabled = userStorage.getBool("notifications_enabled", true);
boolean nonExistentBool = userStorage.getBool("non_existent_bool", false);
System.out.println("Is premium: " + isPremium);
System.out.println("Notifications enabled: " + notificationsEnabled);
System.out.println("Non-existent bool: " + nonExistentBool);
Kotlin code snippet:
// Retrieve boolean values with defaults
val isPremium: Boolean = userStorage!!.getBool("is_premium", false)
val notificationsEnabled: Boolean = userStorage!!.getBool("notifications_enabled", true)
val nonExistentBool: Boolean = userStorage!!.getBool("non_existent_bool", false)
println("Is premium: $isPremium")
println("Notifications enabled: $notificationsEnabled")
println("Non-existent bool: $nonExistentBool")
◆ getDouble()
| abstract double com.navigine.idl.java.KeyValueStorage.getDouble |
( |
String | key, |
|
|
double | defaultValue ) |
|
abstract |
Gets a 64-bit floating-point value. Returns defaultValue if the key is missing or the stored type is not double.
- Parameters
-
| key | Lookup key. |
| defaultValue | Value to return when not found or type mismatch. |
- Returns
- Stored double or defaultValue.
Java code snippet:
double userLat = userStorage.getDouble("user_location_lat", 0.0);
double userLng = userStorage.getDouble("user_location_lng", 0.0);
double nonExistentDouble = userStorage.getDouble("non_existent_double", -1.0);
System.out.println("User location lat: " + userLat);
System.out.println("User location lng: " + userLng);
System.out.println("Non-existent double: " + nonExistentDouble);
Kotlin code snippet:
// Retrieve double values with defaults
val userLat: Double = userStorage!!.getDouble("user_location_lat", 0.0)
val userLng: Double = userStorage!!.getDouble("user_location_lng", 0.0)
val nonExistentDouble: Double = userStorage!!.getDouble("non_existent_double", -1.0)
println("User location lat: $userLat")
println("User location lng: $userLng")
println("Non-existent double: $nonExistentDouble")
◆ getFloat()
| abstract float com.navigine.idl.java.KeyValueStorage.getFloat |
( |
String | key, |
|
|
float | defaultValue ) |
|
abstract |
Gets a 32-bit floating-point value. Returns defaultValue if the key is missing or the stored type is not float.
- Parameters
-
| key | Lookup key. |
| defaultValue | Value to return when not found or type mismatch. |
- Returns
- Stored float or defaultValue.
Java code snippet:
float userRating = userStorage.getFloat("user_rating", 0.0f);
float temperature = userStorage.getFloat("temperature", 0.0f);
float nonExistentFloat = userStorage.getFloat("non_existent_float", -1.0f);
System.out.println("User rating: " + userRating);
System.out.println("Temperature: " + temperature);
System.out.println("Non-existent float: " + nonExistentFloat);
Kotlin code snippet:
// Retrieve float values with defaults
val userRating: Float = userStorage!!.getFloat("user_rating", 0.0f)
val temperature: Float = userStorage!!.getFloat("temperature", 0.0f)
val nonExistentFloat: Float = userStorage!!.getFloat("non_existent_float", -1.0f)
println("User rating: $userRating")
println("Temperature: $temperature")
println("Non-existent float: $nonExistentFloat")
◆ getInt()
| abstract int com.navigine.idl.java.KeyValueStorage.getInt |
( |
String | key, |
|
|
int | defaultValue ) |
|
abstract |
Gets a 32-bit integer value. Returns defaultValue if the key is missing or the stored type is not int.
- Parameters
-
| key | Lookup key. |
| defaultValue | Value to return when not found or type mismatch. |
- Returns
- Stored int32 or defaultValue.
Java code snippet:
int userAge = userStorage.getInt("user_age", 0);
int loginCount = userStorage.getInt("login_count", 0);
int nonExistentInt = userStorage.getInt("non_existent_int", -1);
System.out.println("User age: " + userAge);
System.out.println("Login count: " + loginCount);
System.out.println("Non-existent int: " + nonExistentInt);
Kotlin code snippet:
// Retrieve integer values with defaults
val userAge: Int = userStorage!!.getInt("user_age", 0)
val loginCount: Int = userStorage!!.getInt("login_count", 0)
val nonExistentInt: Int = userStorage!!.getInt("non_existent_int", -1)
println("User age: $userAge")
println("Login count: $loginCount")
println("Non-existent int: $nonExistentInt")
◆ getKeys()
| abstract ArrayList< String > com.navigine.idl.java.KeyValueStorage.getKeys |
( |
| ) |
|
|
abstract |
Returns all keys currently stored.
- Returns
- List of keys. Order is implementation-defined (not guaranteed).
Java code snippet:
List<String> allKeys = userStorage.getKeys();
System.out.println("All stored keys: " + allKeys);
Kotlin code snippet:
// Get all stored keys
val allKeys: List<String> = userStorage!!.getKeys()
println("All stored keys: $allKeys")
◆ getLong()
| abstract long com.navigine.idl.java.KeyValueStorage.getLong |
( |
String | key, |
|
|
long | defaultValue ) |
|
abstract |
Gets a 64-bit integer value. Returns defaultValue if the key is missing or the stored type is not long.
- Parameters
-
| key | Lookup key. |
| defaultValue | Value to return when not found or type mismatch. |
- Returns
- Stored int64 or defaultValue.
Java code snippet:
long regTimestamp = userStorage.getLong("registration_timestamp", 0);
long lastLogin = userStorage.getLong("last_login_timestamp", 0);
long nonExistentLong = userStorage.getLong("non_existent_long", -1);
System.out.println("Registration timestamp: " + regTimestamp);
System.out.println("Last login timestamp: " + lastLogin);
System.out.println("Non-existent long: " + nonExistentLong);
Kotlin code snippet:
// Retrieve long values with defaults
val regTimestamp: Long = userStorage!!.getLong("registration_timestamp", 0)
val lastLogin: Long = userStorage!!.getLong("last_login_timestamp", 0)
val nonExistentLong: Long = userStorage!!.getLong("non_existent_long", -1)
println("Registration timestamp: $regTimestamp")
println("Last login timestamp: $lastLogin")
println("Non-existent long: $nonExistentLong")
◆ getString()
| abstract String com.navigine.idl.java.KeyValueStorage.getString |
( |
String | key, |
|
|
String | defaultValue ) |
|
abstract |
Gets a string value. Returns defaultValue if the key is missing or the stored type is not string.
- Parameters
-
| key | Lookup key. |
| defaultValue | Value to return when not found or type mismatch. |
- Returns
- Stored string or defaultValue.
Java code snippet:
String userName = userStorage.getString("user_name", "Unknown");
String userEmail = userStorage.getString("user_email", "");
String nonExistent = userStorage.getString("non_existent_key", "default_value");
System.out.println("User name: " + userName);
System.out.println("User email: " + userEmail);
System.out.println("Non-existent key: " + nonExistent);
Kotlin code snippet:
// Retrieve string values with defaults
val userName: String = userStorage!!.getString("user_name", "Unknown")
val userEmail: String = userStorage!!.getString("user_email", "")
val nonExistent: String = userStorage!!.getString("non_existent_key", "default_value")
println("User name: $userName")
println("User email: $userEmail")
println("Non-existent key: $nonExistent")
◆ putBool()
| abstract void com.navigine.idl.java.KeyValueStorage.putBool |
( |
String | key, |
|
|
boolean | value ) |
|
abstract |
Stores a boolean value under the key, replacing any existing value.
- Parameters
-
| key | Key to set. |
| value | Value to store. |
Java code snippet:
userStorage.putBool("is_premium", true);
userStorage.putBool("notifications_enabled", false);
System.out.println("Stored boolean values");
Kotlin code snippet:
// Store boolean values
userStorage!!.putBool("is_premium", true)
userStorage!!.putBool("notifications_enabled", false)
println("Stored boolean values")
◆ putDouble()
| abstract void com.navigine.idl.java.KeyValueStorage.putDouble |
( |
String | key, |
|
|
double | value ) |
|
abstract |
Stores a 64-bit floating-point value under the key, replacing any existing value.
- Parameters
-
| key | Key to set. |
| value | Value to store. |
Java code snippet:
userStorage.putDouble("user_location_lat", 55.7558);
userStorage.putDouble("user_location_lng", 37.6176);
System.out.println("Stored double values");
Kotlin code snippet:
// Store double values
userStorage!!.putDouble("user_location_lat", 55.7558)
userStorage!!.putDouble("user_location_lng", 37.6176)
println("Stored double values")
◆ putFloat()
| abstract void com.navigine.idl.java.KeyValueStorage.putFloat |
( |
String | key, |
|
|
float | value ) |
|
abstract |
Stores a 32-bit floating-point value under the key, replacing any existing value.
- Parameters
-
| key | Key to set. |
| value | Value to store. |
Java code snippet:
userStorage.putFloat("user_rating", 4.5f);
userStorage.putFloat("temperature", 23.5f);
System.out.println("Stored float values");
Kotlin code snippet:
// Store float values
userStorage!!.putFloat("user_rating", 4.5f)
userStorage!!.putFloat("temperature", 23.5f)
println("Stored float values")
◆ putInt()
| abstract void com.navigine.idl.java.KeyValueStorage.putInt |
( |
String | key, |
|
|
int | value ) |
|
abstract |
Stores a 32-bit integer value under the key, replacing any existing value.
- Parameters
-
| key | Key to set. |
| value | Value to store. |
Java code snippet:
userStorage.putInt("user_age", 25);
userStorage.putInt("login_count", 42);
System.out.println("Stored integer values");
Kotlin code snippet:
// Store integer values
userStorage!!.putInt("user_age", 25)
userStorage!!.putInt("login_count", 42)
println("Stored integer values")
◆ putLong()
| abstract void com.navigine.idl.java.KeyValueStorage.putLong |
( |
String | key, |
|
|
long | value ) |
|
abstract |
Stores a 64-bit integer value under the key, replacing any existing value.
- Parameters
-
| key | Key to set. |
| value | Value to store. |
Java code snippet:
userStorage.putLong("registration_timestamp", 1640995200000L);
userStorage.putLong("last_login_timestamp", System.currentTimeMillis());
System.out.println("Stored long values");
Kotlin code snippet:
// Store long values
userStorage!!.putLong("registration_timestamp", 1640995200000L)
userStorage!!.putLong("last_login_timestamp", System.currentTimeMillis())
println("Stored long values")
◆ putString()
| abstract void com.navigine.idl.java.KeyValueStorage.putString |
( |
String | key, |
|
|
String | value ) |
|
abstract |
Stores a string value under the key, replacing any existing value.
- Parameters
-
| key | Key to set. |
| value | Value to store. |
Java code snippet:
userStorage.putString("user_name", "John Doe");
userStorage.putString("user_email", "john.doe@example.com");
System.out.println("Stored string values");
Kotlin code snippet:
// Store string values
userStorage!!.putString("user_name", "John Doe")
userStorage!!.putString("user_email", "john.doe@example.com")
println("Stored string values")
◆ remove()
| abstract void com.navigine.idl.java.KeyValueStorage.remove |
( |
String | key | ) |
|
|
abstract |
Removes a value by key. No-op if the key does not exist.
- Parameters
-
Java code snippet:
userStorage.remove("user_age");
userStorage.remove("non_existent_key");
System.out.println("Removed 'user_age' key");
Kotlin code snippet:
// Remove specific keys
userStorage!!.remove("user_age")
userStorage!!.remove("non_existent_key") // No-op
println("Removed 'user_age' key")
The documentation for this class was generated from the following file: