ConnectionUtils

A set of utility functions used to process connection parameters

Description

The ConnectionUtils class provides a set of utility functions used to process connection parameters.

Static methods

composeUri

Composes URI from config parameters. The result URI will be in the following form: protocol://username@password@host1:port1,host2:port2,…?param1=abc¶m2=xyz&…

public static composeUri(options: ConfigParams, defaultProtocol: string, defaultPort: number): string

  • options: ConfigParams - configuration parameters
  • defaultProtocol: string - a default protocol
  • defaultPort: number - a default port
  • returns: string - a composed URI

concat

Concatinates two options by combining duplicated properties into comma-separated list

public static concat(options1: ConfigParams, options2: ConfigParams, …keys: string): ConfigParams

  • options1: ConfigParams - first options to merge
  • options2: ConfigParams - second options to merge
  • keys: string - when defined, it limits only to specific keys
  • returns: ConfigParams - new connection parameters to be added

exclude

Excludes specified keys from the config parameters.

public static exclude(options: ConfigParams, …keys: string[]): ConfigParams

  • options: ConfigParams - configuration parameters to be processed.
  • keys: string[] - a list of keys to be excluded.
  • returns: ConfigParams - a processed config parameters.

include

Includes specified keys from the config parameters.

public static include(options: ConfigParams, …keys: string[]): ConfigParams

  • options: ConfigParams - configuration parameters to be processed.
  • keys: string[] - a list of keys to be included.
  • returns: ConfigParams - a processed config parameters.

parseUri

Parses URI into config parameters. The URI shall be in the following form: protocol://username@password@host1:port1,host2:port2,...?param1=abc¶m2=xyz&...

public static parseUri(uri: string, defaultProtocol: string, defaultPort: string): ConfigParams

  • uri: string - the URI to be parsed
  • defaultProtocol: string - a default protocol
  • defaultPort: string - a default port
  • returns: ConfigParams - a configuration parameters with URI elements

rename

Renames property if the target name is not used.

public static rename(options: ConfigParams, fromName: string, toName: string): ConfigParams

  • options: ConfigParams - configuration options
  • fromName: string - original property name.
  • toName: string - property name to rename to.
  • returns: ConfigParams - updated configuration options