Options
All
  • Public
  • Public/Protected
  • All
Menu

Class StringValueMap

Cross-language implementation of a map (dictionary) where all keys and values are strings. The stored values can be converted to different types using variety of accessor methods.

The string map is highly versatile. It can be converted into many formats, stored and sent over the wire.

This class is widely used in Pip.Services as a basis for variety of classes, such as ConfigParams, ConnectionParams, CredentialParams and others.

Example

let value1 = StringValueMap.fromString("key1=1;key2=123.456;key3=2018-01-01");

value1.getAsBoolean("key1");   // Result: true
value1.getAsInteger("key2");   // Result: 123
value1.getAsFloat("key2");     // Result: 123.456
value1.getAsDateTime("key3");  // Result: new Date(2018,0,1)
see

StringConverter

see

TypeConverter

see

BooleanConverter

see

IntegerConverter

see

LongConverter

see

DoubleConverter

see

FloatConverter

see

DateTimeConverter

Hierarchy

Index

Constructors

constructor

  • Creates a new instance of the map and assigns its value.

    Parameters

    • Default value map: any = null

    Returns StringValueMap

Methods

append

  • append(map: any): void
  • Appends new elements to this map.

    Parameters

    • map: any

      a map with elements to be added.

    Returns void

clear

  • clear(): any
  • Clears this map by removing all its elements.

    Returns any

clone

  • clone(): any
  • Creates a binary clone of this object.

    Returns any

    a clone of this object.

get

  • get(key: string): string
  • Gets a map element specified by its key.

    Parameters

    • key: string

      a key of the element to get.

    Returns string

    the value of the map element.

getAsArray

  • Converts map element into an AnyValueArray or returns empty AnyValueArray if conversion is not possible.

    see

    AnyValueArray

    see

    AnyValueArray.fromValue

    Parameters

    • key: string

      a key of element to get.

    Returns AnyValueArray

    AnyValueArray value of the element or empty AnyValueArray if conversion is not supported.

getAsArrayWithDefault

  • Converts map element into an AnyValueArray or returns default value if conversion is not possible.

    see

    AnyValueArray

    see

    getAsNullableArray

    Parameters

    • key: string

      a key of element to get.

    • defaultValue: AnyValueArray

      the default value

    Returns AnyValueArray

    AnyValueArray value of the element or default value if conversion is not supported.

getAsBoolean

  • getAsBoolean(key: string): boolean
  • Converts map element into a boolean or returns false if conversion is not possible.

    see

    getAsBooleanWithDefault

    Parameters

    • key: string

      a key of element to get.

    Returns boolean

    boolean value of the element or false if conversion is not supported.

getAsBooleanWithDefault

  • getAsBooleanWithDefault(key: string, defaultValue: boolean): boolean
  • Converts map element into a boolean or returns default value if conversion is not possible.

    see

    BooleanConverter.toBooleanWithDefault

    Parameters

    • key: string

      a key of element to get.

    • defaultValue: boolean

      the default value

    Returns boolean

    boolean value of the element or default value if conversion is not supported.

getAsDateTime

  • getAsDateTime(key: string): Date
  • Converts map element into a Date or returns the current date if conversion is not possible.

    see

    getAsDateTimeWithDefault

    Parameters

    • key: string

      a key of element to get.

    Returns Date

    Date value of the element or the current date if conversion is not supported.

getAsDateTimeWithDefault

  • getAsDateTimeWithDefault(key: string, defaultValue: Date): Date
  • Converts map element into a Date or returns default value if conversion is not possible.

    see

    DateTimeConverter.toDateTimeWithDefault

    Parameters

    • key: string

      a key of element to get.

    • defaultValue: Date

      the default value

    Returns Date

    Date value of the element or default value if conversion is not supported.

getAsDouble

  • getAsDouble(key: string): number
  • Converts map element into a double or returns 0 if conversion is not possible.

    see

    getAsDoubleWithDefault

    Parameters

    • key: string

      a key of element to get.

    Returns number

    double value of the element or 0 if conversion is not supported.

getAsDoubleWithDefault

  • getAsDoubleWithDefault(key: string, defaultValue: number): number
  • Converts map element into a double or returns default value if conversion is not possible.

    see

    DoubleConverter.toDoubleWithDefault

    Parameters

    • key: string

      a key of element to get.

    • defaultValue: number

      the default value

    Returns number

    double value of the element or default value if conversion is not supported.

getAsFloat

  • getAsFloat(key: string): number
  • Converts map element into a float or returns 0 if conversion is not possible.

    see

    getAsFloatWithDefault

    Parameters

    • key: string

      a key of element to get.

    Returns number

    float value of the element or 0 if conversion is not supported.

getAsFloatWithDefault

  • getAsFloatWithDefault(key: string, defaultValue: number): number
  • Converts map element into a flot or returns default value if conversion is not possible.

    see

    FloatConverter.toFloatWithDefault

    Parameters

    • key: string

      a key of element to get.

    • defaultValue: number

      the default value

    Returns number

    flot value of the element or default value if conversion is not supported.

getAsInteger

  • getAsInteger(key: string): number
  • Converts map element into an integer or returns 0 if conversion is not possible.

    see

    getAsIntegerWithDefault

    Parameters

    • key: string

      a key of element to get.

    Returns number

    integer value of the element or 0 if conversion is not supported.

getAsIntegerWithDefault

  • getAsIntegerWithDefault(key: string, defaultValue: number): number
  • Converts map element into an integer or returns default value if conversion is not possible.

    see

    IntegerConverter.toIntegerWithDefault

    Parameters

    • key: string

      a key of element to get.

    • defaultValue: number

      the default value

    Returns number

    integer value of the element or default value if conversion is not supported.

getAsLong

  • getAsLong(key: string): number
  • Converts map element into a long or returns 0 if conversion is not possible.

    see

    getAsLongWithDefault

    Parameters

    • key: string

      a key of element to get.

    Returns number

    long value of the element or 0 if conversion is not supported.

getAsLongWithDefault

  • getAsLongWithDefault(key: string, defaultValue: number): number
  • Converts map element into a long or returns default value if conversion is not possible.

    see

    LongConverter.toLongWithDefault

    Parameters

    • key: string

      a key of element to get.

    • defaultValue: number

      the default value

    Returns number

    long value of the element or default value if conversion is not supported.

getAsMap

  • Converts map element into an AnyValueMap or returns empty AnyValueMap if conversion is not possible.

    see

    fromValue

    Parameters

    • key: string

      a key of element to get.

    Returns AnyValueMap

    AnyValueMap value of the element or empty AnyValueMap if conversion is not supported.

getAsMapWithDefault

  • Converts map element into an AnyValueMap or returns default value if conversion is not possible.

    see

    getAsNullableMap

    Parameters

    • key: string

      a key of element to get.

    • defaultValue: AnyValueMap

      the default value

    Returns AnyValueMap

    AnyValueMap value of the element or default value if conversion is not supported.

getAsNullableArray

  • Converts map element into an AnyValueArray or returns null if conversion is not possible.

    see

    AnyValueArray

    see

    AnyValueArray.fromValue

    Parameters

    • key: string

      a key of element to get.

    Returns AnyValueArray

    AnyValueArray value of the element or null if conversion is not supported.

getAsNullableBoolean

  • getAsNullableBoolean(key: string): boolean
  • Converts map element into a boolean or returns null if conversion is not possible.

    see

    BooleanConverter.toNullableBoolean

    Parameters

    • key: string

      a key of element to get.

    Returns boolean

    boolean value of the element or null if conversion is not supported.

getAsNullableDateTime

  • getAsNullableDateTime(key: string): Date
  • Converts map element into a Date or returns null if conversion is not possible.

    see

    DateTimeConverter.toNullableDateTime

    Parameters

    • key: string

      a key of element to get.

    Returns Date

    Date value of the element or null if conversion is not supported.

getAsNullableDouble

  • getAsNullableDouble(key: string): number
  • Converts map element into a double or returns null if conversion is not possible.

    see

    DoubleConverter.toNullableDouble

    Parameters

    • key: string

      a key of element to get.

    Returns number

    double value of the element or null if conversion is not supported.

getAsNullableFloat

  • getAsNullableFloat(key: string): number
  • Converts map element into a float or returns null if conversion is not possible.

    see

    FloatConverter.toNullableFloat

    Parameters

    • key: string

      a key of element to get.

    Returns number

    float value of the element or null if conversion is not supported.

getAsNullableInteger

  • getAsNullableInteger(key: string): number
  • Converts map element into an integer or returns null if conversion is not possible.

    see

    IntegerConverter.toNullableInteger

    Parameters

    • key: string

      a key of element to get.

    Returns number

    integer value of the element or null if conversion is not supported.

getAsNullableLong

  • getAsNullableLong(key: string): number
  • Converts map element into a long or returns null if conversion is not possible.

    see

    LongConverter.toNullableLong

    Parameters

    • key: string

      a key of element to get.

    Returns number

    long value of the element or null if conversion is not supported.

getAsNullableMap

  • Converts map element into an AnyValueMap or returns null if conversion is not possible.

    see

    fromValue

    Parameters

    • key: string

      a key of element to get.

    Returns AnyValueMap

    AnyValueMap value of the element or null if conversion is not supported.

getAsNullableString

  • getAsNullableString(key: string): string
  • Converts map element into a string or returns null if conversion is not possible.

    see

    StringConverter.toNullableString

    Parameters

    • key: string

      a key of element to get.

    Returns string

    string value of the element or null if conversion is not supported.

getAsNullableType

  • getAsNullableType<T>(type: TypeCode, key: string): T
  • Converts map element into a value defined by specied typecode. If conversion is not possible it returns null.

    see

    TypeConverter.toNullableType

    Type parameters

    • T

    Parameters

    • type: TypeCode

      the TypeCode that defined the type of the result

    • key: string

      a key of element to get.

    Returns T

    element value defined by the typecode or null if conversion is not supported.

getAsObject

  • getAsObject(key?: string): any
  • Gets the value stored in map element without any conversions. When element key is not defined it returns the entire map value.

    Parameters

    • Default value key: string = undefined

      (optional) a key of the element to get

    Returns any

    the element value or value of the map when index is not defined.

getAsString

  • getAsString(key: string): string
  • Converts map element into a string or returns "" if conversion is not possible.

    see

    getAsStringWithDefault

    Parameters

    • key: string

      a key of element to get.

    Returns string

    string value of the element or "" if conversion is not supported.

getAsStringWithDefault

  • getAsStringWithDefault(key: string, defaultValue: string): string
  • Converts map element into a string or returns default value if conversion is not possible.

    see

    StringConverter.toStringWithDefault

    Parameters

    • key: string

      a key of element to get.

    • defaultValue: string

      the default value

    Returns string

    string value of the element or default value if conversion is not supported.

getAsType

  • getAsType<T>(type: TypeCode, key: string): T
  • Converts map element into a value defined by specied typecode. If conversion is not possible it returns default value for the specified type.

    see

    getAsTypeWithDefault

    Type parameters

    • T

    Parameters

    • type: TypeCode

      the TypeCode that defined the type of the result

    • key: string

      a key of element to get.

    Returns T

    element value defined by the typecode or default if conversion is not supported.

getAsTypeWithDefault

  • getAsTypeWithDefault<T>(type: TypeCode, key: string, defaultValue: T): T
  • Converts map element into a value defined by specied typecode. If conversion is not possible it returns default value.

    see

    TypeConverter.toTypeWithDefault

    Type parameters

    • T

    Parameters

    • type: TypeCode

      the TypeCode that defined the type of the result

    • key: string

      a key of element to get.

    • defaultValue: T

      the default value

    Returns T

    element value defined by the typecode or default value if conversion is not supported.

getAsValue

  • Converts map element into an AnyValue or returns an empty AnyValue if conversion is not possible.

    see

    AnyValue

    see

    AnyValue.constructor

    Parameters

    • key: string

      a key of element to get.

    Returns AnyValue

    AnyValue value of the element or empty AnyValue if conversion is not supported.

getKeys

  • getKeys(): string[]
  • Gets keys of all elements stored in this map.

    Returns string[]

    a list with all map keys.

length

  • length(): number
  • Gets a number of elements stored in this map.

    Returns number

    the number of elements in this map.

put

  • put(key: string, value: any): any
  • Puts a new value into map element specified by its key.

    Parameters

    • key: string

      a key of the element to put.

    • value: any

      a new value for map element.

    Returns any

remove

  • remove(key: string): void
  • Removes a map element specified by its key

    Parameters

    • key: string

      a key of the element to remove.

    Returns void

setAsObject

  • setAsObject(key: any, value?: any): void
  • Sets a new value to map element specified by its index. When the index is not defined, it resets the entire map value. This method has double purpose because method overrides are not supported in JavaScript.

    see

    MapConverter.toMap

    Parameters

    • key: any

      (optional) a key of the element to set

    • Default value value: any = undefined

      a new element or map value.

    Returns void

toString

  • toString(): string
  • Gets a string representation of the object. The result is a semicolon-separated list of key-value pairs as "key1=value1;key2=value2;key=value3"

    Returns string

    a string representation of the object.

Static fromMaps

  • Creates a new AnyValueMap by merging two or more maps. Maps defined later in the list override values from previously defined maps.

    Parameters

    • Rest ...maps: any[]

      an array of maps to be merged

    Returns StringValueMap

    a newly created AnyValueMap.

Static fromString

  • Parses semicolon-separated key-value pairs and returns them as a StringValueMap.

    Parameters

    • line: string

      semicolon-separated key-value list to initialize StringValueMap.

    Returns StringValueMap

    a newly created StringValueMap.

Static fromTuples

  • Creates a new StringValueMap from a list of key-value pairs called tuples.

    see

    fromTuplesArray

    Parameters

    • Rest ...tuples: any[]

      a list of values where odd elements are keys and the following even elements are values

    Returns StringValueMap

    a newly created StringValueMap.

Static fromTuplesArray

  • Creates a new StringValueMap from a list of key-value pairs called tuples. The method is similar to fromTuples but tuples are passed as array instead of parameters.

    Parameters

    • tuples: any[]

      a list of values where odd elements are keys and the following even elements are values

    Returns StringValueMap

    a newly created StringValueMap.

Static fromValue

  • Converts specified value into StringValueMap.

    see

    setAsObject

    Parameters

    • value: any

      value to be converted

    Returns StringValueMap

    a newly created StringValueMap.

Generated using TypeDoc