A valid URL as defined by Java
<scheme>://<authority><path>?<query>#<fragment>
<scheme>: -mandatory
// -mandatoryin case it's not a file
<authority> -mandatory,<authority>is defined as<host>:<port>,<host> -mandatory,:<port> -optional
<path> -optional
? -optional
<query> -optional
# -optional
<fragment> -optional
Protocols supported by Java URL
http , https , ftp , file , and jar
Creates a URL object from the String representation, if it's a valid URL.
A URL without scheme will return
no protocol: <host>
if<port>is not defined
unknown protocol: <host>
if<port>is defined
Creates a URL object from the specified @NotNullOrEmpty protocol, host, port number, and @NotNull file.
in case of host is null, port will be ignored
in case of null protocol
Cannot invoke "String.equals(Object)" because "protocol" is null error will be thrown
in case of null file
Cannot invoke "String.equals(Object)" because "file" is null error will be thrown
in case of empty protocol
unknown protocol error will be thrown
output will be<protocol>://<host>:<port><file>in case host is not null
output will be<protocol>:<file>in case host is null
Creates a URL from the specified @NotNullOrEmpty protocol, host, and NotNull file.
in case of null protocol
Cannot invoke "String.equals(Object)" because "protocol" is null error will be thrown
in case of null file
Cannot invoke "String.equals(Object)" because "file" is null error will be thrown
in case of empty protocol
unknown protocol error will be thrown
output will be<protocol>://<host><file>in case host is not null and not empty
output will be<protocol>:<file>in case host is null or empty
Creates a URL by parsing the given @NotNull spec within a specified context
in case of null context the URL, the spec part has to be a valid URL or a file orno protocolwill be thrown
in case of null spec
Cannot invoke "String.equals(Object)" because "spec" is null error will be thrown
in case of empty spec
full context will be returned as is
in case of spec as query
context will be returned until<query>and what's after it, and they will be replaced by spec in case of spec as path
context will be returned until<path>and what's after it, and they will be replaced by spec
| Return type | Method | Index supported | num |
|---|---|---|---|
| boolean | equals(URL url1, URL url2) | Y | 3 |
| varchar | getAuthority() | N | 1 |
| int | getDefaultPort() | N | 2 |
| varchar | getFile() | N | 1 |
| varchar | getHost() | N | 4 |
| varchar | getPath() | N | 1 |
| int | getPort() | N | 2 |
| varchar | getProtocol() | N | 3 |
| varchar | getQuery() | N | 3 |
| String | getRef() | N | 4 |
| String | getUserInfo() | N | 2 |
| boolean | sameFile(URL url1, URL url2) | Y | 4 |
| boolean | sameHost(URL url1, URL url2) | Y | 1 |
| varchar | toString() | N | 2 |
Abd -1 Isa -2 Jez -3 Mir -4
Compares two URLs for equality.
URLs are equals if
their<scheme>is the same
and their<host>:<port>is the same, or if its:<port>is not the shown in one and the other have the default port depend on the<scheme>
and their<path>?<query>#<fragment>are the same
Gets the authority part of this URL. returns
<host>:<port>if:<port>is defined
else<host>
Gets the default port number of the protocol associated with this URL. returns
80if protocol is HTTP
returns443if protocol is HTTPS
returns21if protocol is FTP
returns-1if it's file or jar
Gets the file name of this URL.
returns<path>?<query>if they are defined or empty if not
Gets the host name of this URL, if applicable.
returns<host>unless<scheme>is file, then it returns empty
Gets the path part of this URL.
returns<path>or empty if not defined
in case of file, it returns everything after<scheme>:
Gets the port number of this URL.
returns<port>if it defined or-1if not
Gets the protocol name of this URL.
returns<scheme>
Gets the query part of this URL.
returns<query>if defined ornullif not
Gets the anchor (also known as the "reference") of this URL.
returns<fragment>if defined ornullif not
Gets the userInfo part of this URL.
returns<userInfo>if defined as<scheme>://<userInfo>@<website>, else it returnsnull
Compares two URLs, excluding the fragment component.
returnstrueif this URL and the other argument are equal without taking the fragment component into consideration
Compares the hosts of two URLs.
returns<true>if<host>argument is equal in both URLs
Constructs a string representation of this URL
returns the whole URL as string