Methods Summary |
---|
public java.lang.Object | clone()Makes a copy of the current instance.
Host retval = new Host();
retval.addressType = this.addressType;
retval.hostname = new String(this.hostname);
return retval;
|
public java.lang.String | encode()Return the host name in encoded form.
if (addressType == IPV6ADDRESS &&
'[" != hostname.charAt(0))
return "[" + hostname + "]";
return hostname;
|
public boolean | equals(java.lang.Object obj)Compares for equality of hosts.
Host names are compared by textual equality. No dns lookup
is performed.
if (!this.getClass().equals(obj.getClass())) {
return false;
}
Host otherHost = (Host) obj;
return otherHost.hostname.equals(hostname);
|
public java.lang.String | getAddress()Gets the Address field.
return hostname;
|
public java.lang.String | getHostname()Gets the HostName field.
return hostname;
|
public boolean | isHostname()Returns true if the address is a DNS host name
(and not an IPV4 address).
return addressType == HOSTNAME;
|
public boolean | isIPAddress()Returns true if the address is a DNS host name
(and not an IPV4 address).
return addressType != HOSTNAME;
|
public void | setAddress(java.lang.String address)Sets the address member.
setHostname(address);
|
public void | setHostname(java.lang.String h)Sets the hostname member.
if (h == null) {
throw new IllegalArgumentException("Null address");
}
h = h.trim().toLowerCase();
// IPv4 has stronger restriction than hostname
if (Lexer.isValidIpv4Address(h)) {
addressType = IPV4ADDRESS;
} else if (Lexer.isValidHostname(h)) {
addressType = HOSTNAME;
} else {
String addr = h;
// IPv6 reference?
if (h.charAt(0) == '[" &&
h.charAt(h.length()-1) == ']") {
addr = h.substring(1, h.length()-1);
}
if (!Lexer.isValidIpv6Address(addr)) {
throw new IllegalArgumentException(
"Illegal hostname " + addr);
}
}
hostname = h;
|