ArcGIS for Developers

UrlInfo QML Type

A convenience component that allows a user to deconstruct a link such as a web address. More...

Import Statement: import ArcGIS.AppFramework 1.0

Properties

Methods

Detailed Description

The UrlInfo component provides a number of properties and methods that help construct and deconstruct urls. For more information on the URI schemes - https://en.wikipedia.org/wiki/Uniform_Resource_Identifier

For example,

App {
        id: app
        width: 700
        height: 250

        UrlInfo {
                id: urlInfo
        }

        Column {
                spacing: 5

                Text {
                        id: urlTxt
                        text: "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/0?f=pjson"
                }
                Button {
                        text: qsTr("Test")
                        onClicked: urlInfo.fromString(urlTxt.text);
                }

                CheckBox {
                        text: "Is valid?"
                        checked: urlInfo.isValid
                        enabled: false
                }
        }
}

Property Documentation

authority : string

This property is comprised of the user information (optional), host and port if available. For example, username:password@example.com:123


[read-only] fileName : string

Name of the file that is opened. For example, myPage.html.


fragment : string

Provides direction to a secondary resource, such as a section heading in an article identified by the remainder of the URI. For example, "myPage.html#section3". The #section3 denotes a location within the page.


[read-only] hasFragment : bool

Boolean value. Returns true if the url passed in has a fragment.


[read-only] hasQuery : bool

Boolean value. Returns true if the url has a query as part of the structure.


host : string

The host consists of either a registered name (including but not limited to a hostname), or an IP address. IPv4 addresses must be in dot-decimal notation, and IPv6 addresses must be enclosed in brackets ([ ]).


[read-only] isEmpty : bool

Boolean value. Returns true if the url provided is empty.


[read-only] isLocalFile : bool

Boolean value. Returns true if the url is referring to a local file. For example, "file:///c:/temp/Bruce.txt"


[read-only] isValid : bool

Boolean value. Returns true if the url has a valid address/location and is well formed.


localFile : string

Returns the string of the objects file path if it is a local file.

For example,

var pictureUrlInfo = AppFramework.urlInfo(pictureUrl); var picturePath = pictureUrlInfo.localFile;

returns an address like "C:/temp/Bruce.jpg"


password : string

Returns a string value of the optional property of a url.


path : string

Returns the string value that is directly after the authority section of a url. For example, "/pathname/Bruce.html".


port : int

An optional number in the url that is separated from the hostname by a colon. For example, example.com:1234.


query : string

An optional parameter of a url. This can be used to define a question about the data/content that is being accessed by the url.


queryPairDelimiter : string

Returns the character used to delimit between keys-value pairs when reconstructing the query string.


queryParameters : object

JSON object. Set of key-pair values that define a query for a specific url. For example,

urlInfo.queryParameters = {"name": "Ashton", "sister":"Indie"};

queryValueDelimiter : string

Returns the character used to delimit between keys and values when reconstructing the query string.


scheme : string

String value. Returns the standard protocol that is used for the url provided. For example, "http" or "file" or "survey123".


[read-only] topLevelDomain : string

String value. Returns the segment that describes the domain type of the url. For example, ".com".


url : url

Stores the full url of the string passed in.


userInfo : string

String value. Returns the optional parameters of user name and password. For example, username:password.


userName : string

String value. Optional property of authentication within a url.


Method Documentation

bool fromPercentEncoding(string)

The string parameter


bool fromString(string)

This method initialises the dissemenation of the url provided.

Setting a string can be static or dynamically done, depending on the requirements of the app. For example, urlInfo.fromString("http://appstudioRocks.com")

The string parameter

String value. "www.example.com:1234" or "file:///c:/temp/Bruce.txt"


bool fromUserInput(userInput)

This method initialises the dissemenation of the url provided.

Most applications that can browse the web, allow the user to input a URL in the form of a plain string. This string can be manually typed into a location bar, obtained from the clipboard, or passed in via command line arguments.

The userInput parameter

String value. For example, "http://www.esri.com"


bool fromUserInput(userInput, string workingDirectory)

Returns a valid url from a user supplied userInput string if one can be deducted.

Most applications that can browse the web, allow the user to input a URL in the form of a plain string. This string can be manually typed into a location bar, obtained from the clipboard, or passed in via command line arguments.

The userInput parameter

String value. For example, "http://www.arcgis.com"

The workingDirectory parameter

This property is particularly useful when handling command line arguments. If workingDirectory is empty, no handling of relative paths will be done, so this method will behave like its one argument overload.


bool isParentOf(url)

Returns true if the url property is a parent of the childUrl parameter.

childUrl is a child of this URL if the two URLs share the same scheme and authority and this URL's path is a parent of the path of childUrl.

For example,

Item {
        UrlInfo {
                id: urlInfo
                url: "http://arcgis-server1022-2082234468.us-east-1.elb.amazonaws.com/arcgis/rest/services/MobileApps/Water_Leaks_VGI/FeatureServer"
        }

        Component.onCompleted {
                var testParent = urlInfo.isParentOf("http://arcgis-server1022-2082234468.us-east-1.elb.amazonaws.com/arcgis/rest/services/MobileApps/Water_Leaks_VGI/FeatureServer/0/query")
                console.log(testParent) // would return true.
        }
}

The url parameter

For example, "http://www.arcgis.com"