up: IO     index Zimbu documentation

CLASS IO.Url @public

summary

     

Uniform Resource Locator

string  $protocol @file 
string  $domain @file 
int  $port @file 
string  $path @file 
dict<string, string>  $params @file 
string  $fragment @file 
 
NEW(url) @public  Create a new Url from a string.
NEW(domain, path) @public  Create a new Url for domain and path.
$getProtocol() string @public  Return the protocol.
$setProtocol(protocol) @public  Set the protocol to protocol.
$getDomain() string @public  Returns the domain.
$setDomain(domain) @public  Set the domain.
$getPort() int @public  Returns the port.
$setPort(port) @public  Set the port.
$getPath() string @public  Returns the path.
$setPath(path) @public  Set the path.
$hasParameter(name) bool @public  Returns TRUE if parameter name is present.
$getParameter(name) string @public  Returns the value parameter of name.
$getAllParameters() dict<string, string> @public  Returns a dictionary with all parameters.
$setParameter(name, value) @public  Set parameter name to value.
$removeParameter(name) @public  Remove parameter name.
$getFragment() string @public  Returns the value of the fragment, what comes after "#".
$setFragment(value) @public  Set the value of the fragment, what comes after "#".
$ToString() string @public  Return all values put together as a string.
 

members (alphabetically)

     

string $domain @file

string $fragment @file

dict<string, string> $params @file

string $path @file

int $port @file

string $protocol @file

PROC NEW(string url) @public

     

Create a new Url from a string.

This splits the url into parts, so that it can be changed.

Example:

 ZUT.Url url = NEW("http://zimbu.org/docs?fmt=nice")
 url.setParameter("hl", "de")
 IO.print(url.ToString())  # prints http://zimbu.org/docs?fmt=nice&hl=de

PROC NEW(string domain, string path) @public

     

Create a new Url for domain and path.

$ToString() would return "http://domain/path"

When path is NIL then $ToString() would return "http://domain", without the trailing slash. When path is an empty string the trailing slash gets added.

path should not start with a slash to avoid double slashes.

FUNC $ToString() string @public

     

Return all values put together as a string.

With all values set: "protocol://domain:port/path?param=value#fragment".

FUNC $getAllParameters() dict<string, string> @public

     

Returns a dictionary with all parameters.

Returns NIL if there are no parameters.

FUNC $getDomain() string @public

     

Returns the domain.

FUNC $getFragment() string @public

     

Returns the value of the fragment, what comes after "#".

Return NIL if there is no frament, an empty string means only a "#" is added.

FUNC $getParameter(string name) string @public

     

Returns the value parameter of name.

Returns NIL if the parameter is not present or has no value.

FUNC $getPath() string @public

     

Returns the path.

NIL means no path, an empty string results in just a slash.

path normally does not start with a slash.

FUNC $getPort() int @public

     

Returns the port.

When zero this means no port is specified.

FUNC $getProtocol() string @public

     

Return the protocol.

The value includes the colon, e.g. "http:" or "file:".

When not set NIL is returned, which implies using "http:".

FUNC $hasParameter(string name) bool @public

     

Returns TRUE if parameter name is present.

PROC $removeParameter(string name) @public

     

Remove parameter name.

When the parameter did not exist nothing happens.

PROC $setDomain(string domain) @public

     

Set the domain.

PROC $setFragment(string value) @public

     

Set the value of the fragment, what comes after "#".

Use NIL for value to reset the fragment, an empty string results in just "#" to be added.

PROC $setParameter(string name, string value) @public

     

Set parameter name to value.

$ToString() will add "?name=value".

PROC $setPath(string path) @public

     

Set the path.

Use NIL to leave the path out. An empty string results in just a slash.

path should not start with a slash.

PROC $setPort(int port) @public

     

Set the port.

PROC $setProtocol(string protocol) @public

     

Set the protocol to protocol.

The value must include the colon, e.g. "http:" or "file:".

When not set or NIL "http:" is used.

license

      Copyright 2009 Bram Moolenaar All Rights Reserved.

      Licensed under the Apache License, Version 2.0. See the LICENSE file or obtain a copy at: http://www.apache.org/licenses/LICENSE-2.0