projects/wms-framework/src/lib/baseframework/UriBuilder.ts
Utility to build a URL and get the corresponding Uri.
Properties |
Accessors |
constructor(p1?: any, p2?: any)
|
Creates an instance of UriBuilder. |
Private _hostName |
Type : string
|
Default value : null
|
The host name or IP address. |
Private _scheme |
Type : string
|
Default value : null
|
The Internet protocol. |
Uri |
getUri()
|
Gets the Uri corresponding to the URL constructed by the UriBuilder.
Returns :
Uri
|
import { Uri } from './Uri';
/**
* Utility to build a URL and get the corresponding Uri.
*
* @export
* @class UriBuilder
* @wType System.UriBuilder
*/
export class UriBuilder {
/**
* The Internet protocol.
*
* @private
* @type {string}
* @memberof UriBuilder
*/
private _scheme: string = null;
/**
* The host name or IP address.
*
* @private
* @type {string}
* @memberof UriBuilder
*/
private _hostName: string = null;
/**
* Creates an instance of UriBuilder.
* @param {string} schemeName The Internet protocol.
* @param {string} hostName The host name or IP address.
* @memberof UriBuilder
*/
constructor(schemeName: string, hostName: string);
/**
* Creates an instance of UriBuilder.
* @param {*} [p1]
* @param {*} [p2]
* @memberof UriBuilder
*/
constructor(p1?: any, p2?: any) {
if (typeof p1 === 'string' && typeof p2 === 'string') {
this._scheme = p1;
this._hostName = p2;
} else {
throw 'Invalid constructor parameters for UriBuilder';
}
}
/**
* Gets the Uri corresponding to the URL constructed by the UriBuilder.
*
* @readonly
* @type {Uri}
* @memberof UriBuilder
*/
public get Uri(): Uri {
return new Uri(`${this._scheme}://${this._hostName}/`);
}
}