# Standard nwg services reference

This appendix is a reference of the standard nwg services module.

## Standard nwg services module

Symbol | Description
--- | ---
afnix-nwg | module
afnix:nwg | nameset

Uri

The `Uri` class is a base object used to parse or build a uniform resource identifier as defined by RFC 3986. The URI can be built by specifying each component or by parsing a string. When a string is given in the constructor, the class parses the string and extract all components. The uri components are the scheme, the authority, the path, the query and the fragment. The class also takes care of the character escaping.

uri-p
Object
Uri
none

The `Uri` constructor creates an empty uri object.

Uri
String

The `Uri` constructor create a uri object by value. The string argument is the uri to parse at the object construction.

parse
none
String

The `parse` method reset the uri object, parse the string argument and fill the uri object with the result.

get-scheme
String
none

The `get-scheme` method returns the scheme of the parsed uri object.

get-authority
String
none

The `get-authority` method returns the authority part of the parsed uri.

get-path
String
none

The `get-path` method returns the path of the parsed uri.

get-path-target
String
none

The `get-path-target` method returns the path target of the parsed uri. The path target is the last element of the uri path.

get-query
String
none

The `get-query` method returns the complete query string of the parsed uri. Note that characters are not escaped when getting the string.

get-fragment
String
none

The `get-fragment` method returns the complete query string of the parsed uri.

get-base
String
none

The `get-base` method returns the combined uri scheme and authority.

get-hname
String
none

The `get-hname` method returns the combined uri scheme, authority and path.

add-path
Uri
String

The `add-path` method adds a path to the calling uri and returns a new uri with the new path added to the old one.

get-href
Uri
String

The `get-href` method returns a new uri by eventually combining the string argument. If the strign argument correspond to an uri, the corresponding uri is built. Otherwise, the string argument is considered as a pth to be added to the current uri in order to build a new uri.

get-system-path
String
none

The `get-system-path` method returns the system path representation of the uri path. This function works only if the scheme if a file scheme.

get-path-encoded
String
none

The `get-path-encoded` method returns the uri in the encoded form. Normally the `get-path` removes the percent-encoded characters which might not be appropriate with some protocol such like the http protocol. The `get-path-encoded` returns the original path. Note that getting the path with `getpath` and doing a percent coding might result in a different result since the internal representation uses normalized string.

get-host
String
none

The `get-host` method returns the authority or path host name if any can be found with respect to the scheme. With a ftp, http or https scheme, the ost is extracted from the authority. With a mailto scheme, the host is extracted fromthe path.

get-port
Integer
none

The `get-port` method returns the authority port if any can be found with respect to the scheme.

UriQuery

The `UriQuery` class is a simple class that parses a uri query string and build property list. during the parsing process, a special transliteration process is done as specified by RFC 3986. This class is primarily used with cgi scripts. Note that the string to parse is exactly the one produced by the `get-query` method of the `Uri` class.

uri-query-p
Plist
UriQuery
none

The `UriQuery` constructor creates an empty uri query object.

UriQuery
String

The `UriQuery` constructor create a uri object by value. The string argument is the uri query string to parse at the object construction. The query string is the one obtained from the `get-query` method of the `Uri` class.

parse
none
String

The `parse` method reset the uri query object, parses the string argument and fill the property list object with the result.

get-query
String
none

The `get-query` method returns the original query string.

normalize-uri-name
String
String

The `normalize-uri-name` function normalizes the string argument by adding a uri scheme if missing in the original string. If the function detects that the name starts with a host name, the "http" scheme is added. If the function detects that the string starts with a path, the "file" scheme is added. otherwise, the name argument is left untouched.

system-uri-name
String
String

The `system-uri-name` function normalizes the string argument by prioritizing the system name. The function attempts to find a file that match the sring argument and eventually build a uri file scheme. If the file is not fond, the normalization process occurs with the `normalize-uri-name` function.