Package jakarta.mail
Class URLName
java.lang.Object
jakarta.mail.URLName
The name of a URL. This class represents a URL name and also
provides the basic parsing functionality to parse most internet
standard URL schemes.
Note that this class differs from java.net.URL
in that this class just represents the name of a URL, it does
not model the connection to a URL.
- Author:
- Christopher Cotton, Bill Shannon
-
Field Summary
-
Constructor Summary
ConstructorDescriptionConstruct a URLName from the string.Creates a URLName object from the specified protocol, host, port number, file, username, and password.Construct a URLName from a java.net.URL object. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Compares two URLNames.getFile()
Returns the file name of this URLName.getHost()
Returns the host of this URLName.Returns the password of this URLName.int
getPort()
Returns the port number of this URLName.Returns the protocol of this URLName.getRef()
Returns the reference of this URLName.getURL()
Constructs a URL from the URLName.Returns the user name of this URLName.int
hashCode()
Compute the hash code for this URLName.protected void
parseString
(String url) Method which does all of the work of parsing the string.toString()
Constructs a string representation of this URLName.
-
Field Details
-
fullURL
The full version of the URL
-
-
Constructor Details
-
URLName
public URLName(String protocol, String host, int port, String file, String username, String password) Creates a URLName object from the specified protocol, host, port number, file, username, and password. Specifying a port number of -1 indicates that the URL should use the default port for the protocol.- Parameters:
protocol
- the protocolhost
- the host nameport
- the port numberfile
- the fileusername
- the user namepassword
- the password
-
URLName
Construct a URLName from a java.net.URL object.- Parameters:
url
- the URL
-
URLName
Construct a URLName from the string. Parses out all the possible information (protocol, host, port, file, username, password).- Parameters:
url
- the URL string
-
-
Method Details
-
toString
Constructs a string representation of this URLName. -
parseString
Method which does all of the work of parsing the string.- Parameters:
url
- the URL string to parse
-
getPort
public int getPort()Returns the port number of this URLName. Returns -1 if the port is not set.- Returns:
- the port number
-
getProtocol
Returns the protocol of this URLName. Returns null if this URLName has no protocol.- Returns:
- the protocol
-
getFile
Returns the file name of this URLName. Returns null if this URLName has no file name.- Returns:
- the file name of this URLName
-
getRef
Returns the reference of this URLName. Returns null if this URLName has no reference.- Returns:
- the reference part of the URLName
-
getHost
Returns the host of this URLName. Returns null if this URLName has no host.- Returns:
- the host name
-
getUsername
Returns the user name of this URLName. Returns null if this URLName has no user name.- Returns:
- the user name
-
getPassword
Returns the password of this URLName. Returns null if this URLName has no password.- Returns:
- the password
-
getURL
Constructs a URL from the URLName.- Returns:
- the URL
- Throws:
MalformedURLException
- if the URL is malformed
-
equals
Compares two URLNames. The result is true if and only if the argument is not null and is a URLName object that represents the same URLName as this object. Two URLName objects are equal if they have the same protocol and the same host, the same port number on the host, the same username, and the same file on the host. The fields (host, username, file) are also considered the same if they are both null.Hosts are considered equal if the names are equal (case independent) or if host name lookups for them both succeed and they both reference the same IP address.
Note that URLName has no knowledge of default port numbers for particular protocols, so "imap://host" and "imap://host:143" would not compare as equal.
Note also that the password field is not included in the comparison, nor is any reference field appended to the filename.
-
hashCode
public int hashCode()Compute the hash code for this URLName.
-