Class UFKeyedStorageAbstract

A base class for storage classes that store values together with keys. A subclass must implement the following methods: setString, getString, remove, has and clear.

Constructors

Methods

  • Retrieves a boolean from storage. The default implementation gets the value as string and checks if it equals '1'

    Parameters

    • aKey: string

      Key to get value for

    • aDefault: boolean

      Default value to use

    Returns boolean

    stored value is '1' or aDefault if there is no item

  • Retrieves a integer from storage. The default implementation gets the value as string and uses parseInt to convert it back to an integer.

    Parameters

    • aKey: string

      Key to get integer for

    • aDefault: number

      Default value to use

    Returns number

    parsed integer or aDefault if there is no item or parsing resulted in a NaN value.

  • Retrieves a number from storage. The default implementation gets the value as string and uses parseFloat to convert it back to a number.

    Parameters

    • aKey: string

      Key to get value for

    • aDefault: number

      Default value to use

    Returns number

    parsed number or aDefault if there is no item or parsing resulted in a NaN value.

  • Retrieves an object from storage. The default implementation gets a string using getString and uses JSON.parse to convert a string back to an object.

    Type Parameters

    • T

    Parameters

    • aKey: string

      Key to retrieve object for

    • aDefault: T

      Default value to use

    Returns T

    parsed object or aDefault if there is no item or an exception occurred while parsing the string.

  • Gets a string from the storage or return default when missing.

    Parameters

    • aKey: string

      Key to get value for

    • aDefault: string

      Default value to use when key is missing.

    Returns string

    either stored value or aDefault.

  • Checks if storage contains a certain item.

    Parameters

    • aKey: string

      Key of item

    Returns boolean

    true if item is contained in the storage.

  • Removes item from the storage.

    Parameters

    • aKey: string

      Key of item to remove

    Returns void

  • Stores a boolean in the storage. The default implementation stores either '1' or '0'.

    Parameters

    • aKey: string

      Key to store boolean for

    • aValue: boolean

      Boolean to store

    Returns void

  • Stores an integer in the storage. The default implementation converts the value to a string and stores it as a string.

    Parameters

    • aKey: string

      Key to store integer for

    • aValue: number

      Integer to store

    Returns void

  • Stores a number in the storage. The default implementation converts the value to a string and stores it as a string.

    Parameters

    • aKey: string

      Key to store number for

    • aValue: number

      number to store

    Returns void

  • Stores an object in the storage. The default implementation uses JSON.stringify and calls setString to store the object as string.

    Type Parameters

    • T

    Parameters

    • aKey: string

      Key to store object for

    • aValue: T

      Object to store

    Returns void

  • Stores string value in storage.

    Parameters

    • aKey: string

      Key to store value for

    • aValue: string

      Value to store

    Returns void