Skip to content

Configurations

Overview

The Configurations class provides a set of methods to interact with the configuration settings using the platform. This API allows you to retrieve, modify, and manage configuration parameters for your application.

Methods

get

public static get(key: string, defaultValue?: string): string | undefined

Retrieve the value associated with the specified configuration key. If the key is not found, it returns the specified default value, or undefined if not provided.

Example

const value = Configurations.get("myConfigKey", "defaultValue");
console.log(value); // Output: "configuredValue" or "defaultValue" if not found

set

public static set(key: string, value: string): void

Set the value for the specified configuration key.

Example

Configurations.set("myConfigKey", "configuredValue");

remove

public static remove(key: string): void

Remove the configuration entry associated with the specified key.

Example

Configurations.remove("myConfigKey");

getKeys

public static getKeys(): string[]

Retrieve an array of all configuration keys.

Example

const keys = Configurations.getKeys();
console.log(keys); // Output: ["key1", "key2", ...]

load

public static load(path: string): void

Load configuration settings from the specified path.

Example

Configurations.load("/path/to/config/file.properties");

update

public static update(): void

Update the configuration settings.

Example

Configurations.update();

getOS

public static getOS(): string

Retrieve the operating system name.

Example

const osName = Configurations.getOS();
console.log(osName); // Output: "Windows", "Mac OS X", "Linux", "Solaris", etc.

isOSWindows

public static isOSWindows(): boolean

Check if the operating system is Windows.

Example

const isWindows = Configurations.isOSWindows();
console.log(isWindows); // Output: true or false

isOSMac

public static isOSMac(): boolean

Check if the operating system is Mac OS.

Example

const isMac = Configurations.isOSMac();
console.log(isMac); // Output: true or false

isOSUNIX

public static isOSUNIX(): boolean

Check if the operating system is UNIX-based.

Example

const isUNIX = Configurations.isOSUNIX();
console.log(isUNIX); // Output: true or false

isOSSolaris

public static isOSSolaris(): boolean

Check if the operating system is Solaris.

Example

const isSolaris = Configurations.isOSSolaris();
console.log(isSolaris); // Output: true or false

Functions


Function Description Returns
get(key, defaultValue)() Returns the value for the specified key, or the default value string
set(key, value) Sets a value, for the specified key -
getKeys() Returns an arrays of keys array of string
load(path) Loads a configuration from a properties file at path -
update() Updates the loaded configurations -