|
DthingApi
|
Public Member Functions | |
| URL (String protocol, String host, String file) throws MalformedURLException | |
| URL (String protocol, String host, int port, String file) throws MalformedURLException | |
| URL (String spec) throws MalformedURLException | |
| URL (URL context, String spec) throws MalformedURLException | |
| URL (URL context, String spec, URLStreamHandler handler) throws MalformedURLException | |
| String | getQuery () |
| String | getPath () |
| String | getUserInfo () |
| String | getAuthority () |
| int | getPort () |
| int | getDefaultPort () |
| String | getProtocol () |
| String | getHost () |
| String | getFile () |
| String | getRef () |
| boolean | equals (Object obj) |
| synchronized int | hashCode () |
| boolean | sameFile (URL other) |
| String | toString () |
| String | toExternalForm () |
| URLConnection | openConnection () throws java.io.IOException |
| final InputStream | openStream () throws java.io.IOException |
| final Object | getContent () throws java.io.IOException |
| final Object | getContent (Class[] classes) throws java.io.IOException |
Protected Member Functions | |
| void | set (String protocol, String host, int port, String file, String ref) |
| void | set (String protocol, String host, int port, String authority, String userInfo, String path, String query, String ref) |
|
inline |
Creates a URL from the specified protocol name, host name, and file name. The default port for the specified protocol is used.
This method is equivalent to calling the four-argument constructor with the arguments being protocol, host, -1, and file.
No validation of the inputs is performed by this constructor.
| protocol | the name of the protocol to use. |
| host | the name of the host. |
| file | the file on the host. |
| MalformedURLException | if an unknown protocol is specified. |
|
inline |
Creates a URL object from the specified protocol, host, port number, file, and handler. Specifying a port number of -1 indicates that the URL should use the default port for the protocol. Specifying a handler of null indicates that the URL should use a default stream handler for the protocol, as outlined for: java.net.URL::URL(java.lang.String, java.lang.String, int, java.lang.String)
If the handler is not null and there is a security manager, the security manager's checkPermission method is called with a NetPermission("specifyStreamHandler") permission. This may result in a SecurityException.
No validation of the inputs is performed by this constructor.
| protocol | the name of the protocol to use. |
| host | the name of the host. |
| port | the port number on the host. |
| file | the file on the host |
| handler | the stream handler for the URL. |
| MalformedURLException | |
| MalformedURLException | if an unknown protocol is specified. |
| SecurityException | if a security manager exists and its checkPermission method doesn't allow specifying a stream handler explicitly. |
if host is a literal IPv6 address, we will make it conform to RFC 2732
|
inline |
Creates a URL object from the String representation.
This constructor is equivalent to a call to the two-argument constructor with a null first argument.
| spec | the String to parse as a URL. |
| MalformedURLException | If the string specifies an unknown protocol. |
|
inline |
Creates a URL by parsing the given spec within a specified context.
The new URL is created from the given context URL and the spec argument as described in RFC2396 "Uniform Resource Identifiers : Generic * Syntax" :
<scheme>://<authority><path>?<query>#<fragment>
The reference is parsed into the scheme, authority, path, query and fragment parts. If the path component is empty and the scheme, authority, and query components are undefined, then the new URL is a reference to the current document. Otherwise, the fragment and query parts present in the spec are used in the new URL.
If the scheme component is defined in the given spec and does not match the scheme of the context, then the new URL is created as an absolute URL based on the spec alone. Otherwise the scheme component is inherited from the context URL.
If the authority component is present in the spec then the spec is treated as absolute and the spec authority and path will replace the context authority and path. If the authority component is absent in the spec then the authority of the new URL will be inherited from the context.
If the spec's path component begins with a slash character "/" then the path is treated as absolute and the spec path replaces the context path.
Otherwise, the path is treated as a relative path and is appended to the context path, as described in RFC2396. Also, in this case, the path is canonicalized through the removal of directory changes made by occurences of ".." and ".".
For a more detailed description of URL parsing, refer to RFC2396.
| context | the context in which to parse the specification. |
| spec | the String to parse as a URL. |
| MalformedURLException | if no protocol is specified, or an unknown protocol is found. |
|
inline |
Creates a URL by parsing the given spec with the specified handler within a specified context. If the handler is null, the parsing occurs as with the two argument constructor.
| context | the context in which to parse the specification. |
| spec | the String to parse as a URL. |
| handler | the stream handler for the URL. |
| MalformedURLException | if no protocol is specified, or an unknown protocol is found. |
| SecurityException | if a security manager exists and its checkPermission method doesn't allow specifying a stream handler. |
|
inline |
Compares this URL for equality with another object.
If the given object is not a URL then this method immediately returns false.
Two URL objects are equal if they have the same protocol, reference equivalent hosts, have the same port number on the host, and the same file and fragment of the file.
Two hosts are considered equivalent if both host names can be resolved into the same IP addresses; else if either host name can't be resolved, the host names must be equal without regard to case; or both host names equal to null.
Since hosts comparison requires name resolution, this operation is a blocking operation.
Note: The defined behavior for equals is known to be inconsistent with virtual hosting in HTTP.
| obj | the URL to compare against. |
true if the objects are the same; false otherwise.
|
inline |
|
inline |
Gets the contents of this URL. This method is a shorthand for:
openConnection().getContent()
| IOException | if an I/O exception occurs. |
|
inline |
Gets the contents of this URL. This method is a shorthand for:
openConnection().getContent(Class[])
| classes | an array of Java types |
| IOException | if an I/O exception occurs. |
|
inline |
Gets the default port number of the protocol associated with this URL. If the URL scheme or the URLStreamHandler for the URL do not define a default port number, then -1 is returned.
|
inline |
Gets the file name of this URL. The returned file portion will be the same as getPath(), plus the concatenation of the value of getQuery(), if any. If there is no query portion, this method and getPath() will return identical results.
URL, or an empty string if one does not exist
|
inline |
|
inline |
|
inline |
Gets the port number of this URL.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
modify ok
|
inline |
Returns a URLConnection object that represents a connection to the remote object referred to by the URL.
A new connection is opened every time by calling the openConnection method of the protocol handler for this URL.
If for the URL's protocol (such as HTTP or JAR), there exists a public, specialized URLConnection subclass belonging to one of the following packages or one of their subpackages: java.lang, java.io, java.util, java.net, the connection returned will be of that subclass. For example, for HTTP an HttpURLConnection will be returned, and for JAR a JarURLConnection will be returned. NOTE: java.net.HttpURLConnection is found in J2ME CDC profiles such as J2ME Foundation Profile. Subclasses of these should
URLConnection to the URL. | IOException | if an I/O exception occurs. |
|
inline |
Opens a connection to this URL and returns an InputStream for reading from that connection. This method is a shorthand for:
openConnection().getInputStream()
| IOException | if an I/O exception occurs. |
|
inline |
|
inlineprotected |
Sets the fields of the URL. This is not a public method so that only URLStreamHandlers can modify URL fields. URLs are otherwise constant.
| protocol | the name of the protocol to use |
| host | the name of the host |
| port | the port number on the host |
| file | the file on the host |
| ref | the internal reference in the URL |
|
inlineprotected |
Sets the specified 8 fields of the URL. This is not a public method so that only URLStreamHandlers can modify URL fields. URLs are otherwise constant.
| protocol | the name of the protocol to use |
| host | the name of the host |
| port | the port number on the host |
| authority | the authority part for the url |
| userInfo | the username and password |
| path | the file on the host |
| ref | the internal reference in the URL |
| query | the query part of this URL |
|
inline |
Constructs a string representation of this URL. The string is created by calling the toExternalForm method of the stream protocol handler for this object.
|
inline |
modify ok
1.8.13