- java.lang.Object
-
- net.sourceforge.urin.Host
-
public abstract class Host extends java.lang.ObjectA host component of a URI.RFC 3986 specifies four forms of host - registered name, IP version 4 address, IP version 6 address, and a future IP version address. Note that as pointed out in the RFC, there is an overlap between what is considered a valid IP version 4 address, and what is considered a valid registered name - for example,
Host.registeredName("127.0.0.1")renders identically in a URI toipV4Address(octet(127), octet(0), octet(0), octet(1)). In keeping with the RFC, such a registered name is considered to be an equivalent IP version 4 address.Immutable and thread safe.
- See Also:
- RFC 3986 - Host
-
-
Field Summary
Fields Modifier and Type Field Description static HostLOCAL_HOSTThe registered name "localhost".static HostLOOPBACK_ADDRESS_IP_V4The loopback address in IP v4 format, in other words 127.0.0.1static HostLOOPBACK_ADDRESS_IP_V6The loopback address in IP v6 format, in other words ::1static HostUNSPECIFIED_ADDRESS_IP_V6
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static HostipV4Address(int firstOctet, int secondOctet, int thirdOctet, int fourthOctet)Factory method for creating IP version 4 typeHosts.static HostipV4Address(Octet firstOctet, Octet secondOctet, Octet thirdOctet, Octet fourthOctet)Factory method for creating IP version 4 typeHosts.static HostipV6Address(Hexadectet firstHexadectet, Hexadectet secondHexadectet, Hexadectet thirdHexadectet, Hexadectet fourthHexadectet, Hexadectet fifthHexadectet, Hexadectet sixthHexadectet, Hexadectet seventhHexadectet, Hexadectet eighthHexadectet)Factory method for creating IP version 6 typeHosts with all parts specified asHexadectets.static HostipV6Address(Hexadectet firstHexadectet, Hexadectet secondHexadectet, Hexadectet thirdHexadectet, Hexadectet fourthHexadectet, Hexadectet fifthHexadectet, Hexadectet sixthHexadectet, Octet firstOctet, Octet secondOctet, Octet thirdOctet, Octet fourthOctet)Factory method for creating IP version 6 typeHosts with the least significant 32 bits specified as in IP version 4 address format.static HostipVFutureAddress(java.lang.String version, java.lang.String address)Factory method for creating IP version future typeHosts.static HostregisteredName(java.lang.String registeredName)Factory method for creating registered name typeHosts.
-
-
-
Field Detail
-
LOCAL_HOST
public static final Host LOCAL_HOST
The registered name "localhost".
-
LOOPBACK_ADDRESS_IP_V4
public static final Host LOOPBACK_ADDRESS_IP_V4
The loopback address in IP v4 format, in other words 127.0.0.1
-
LOOPBACK_ADDRESS_IP_V6
public static final Host LOOPBACK_ADDRESS_IP_V6
The loopback address in IP v6 format, in other words ::1
-
UNSPECIFIED_ADDRESS_IP_V6
public static final Host UNSPECIFIED_ADDRESS_IP_V6
-
-
Method Detail
-
registeredName
public static Host registeredName(java.lang.String registeredName)
Factory method for creating registered name typeHosts.- Parameters:
registeredName- anyStringto represent as aHost.- Returns:
- a
Hostrepresenting the givenStringas a registered name.
-
ipV4Address
public static Host ipV4Address(Octet firstOctet, Octet secondOctet, Octet thirdOctet, Octet fourthOctet)
Factory method for creating IP version 4 typeHosts. IP version 4Hosts are made up of fourOctets.- Parameters:
firstOctet- the first octetsecondOctet- the second octetthirdOctet- the third octetfourthOctet- the fourth octet- Returns:
- a
Hostrepresenting the givenOctets as an IP version 4 address.
-
ipV4Address
public static Host ipV4Address(int firstOctet, int secondOctet, int thirdOctet, int fourthOctet)
Factory method for creating IP version 4 typeHosts. IP version 4Hosts are made up of fourOctets, which are created from the givenints.- Parameters:
firstOctet- the first octetsecondOctet- the second octetthirdOctet- the third octetfourthOctet- the fourth octet- Returns:
- a
Hostrepresenting the givenints as an IP version 4 address.
-
ipV6Address
public static Host ipV6Address(Hexadectet firstHexadectet, Hexadectet secondHexadectet, Hexadectet thirdHexadectet, Hexadectet fourthHexadectet, Hexadectet fifthHexadectet, Hexadectet sixthHexadectet, Hexadectet seventhHexadectet, Hexadectet eighthHexadectet)
Factory method for creating IP version 6 typeHosts with all parts specified asHexadectets.- Parameters:
firstHexadectet- the first hexadectetsecondHexadectet- the second hexadectetthirdHexadectet- the third hexadectetfourthHexadectet- the fourth hexadectetfifthHexadectet- the fifth hexadectetsixthHexadectet- the sixth hexadectetseventhHexadectet- the seventh hexadecteteighthHexadectet- the eighth hexadectet- Returns:
- a
Hostrepresenting the givenHexadectets as an IP version 6 address.
-
ipV6Address
public static Host ipV6Address(Hexadectet firstHexadectet, Hexadectet secondHexadectet, Hexadectet thirdHexadectet, Hexadectet fourthHexadectet, Hexadectet fifthHexadectet, Hexadectet sixthHexadectet, Octet firstOctet, Octet secondOctet, Octet thirdOctet, Octet fourthOctet)
Factory method for creating IP version 6 typeHosts with the least significant 32 bits specified as in IP version 4 address format.- Parameters:
firstHexadectet- the first hexadectetsecondHexadectet- the second hexadectetthirdHexadectet- the third hexadectetfourthHexadectet- the fourth hexadectetfifthHexadectet- the fifth hexadectetsixthHexadectet- the sixth hexadectetfirstOctet- the first octetsecondOctet- the second octetthirdOctet- the third octetfourthOctet- the fourth octet- Returns:
- a
Hostrepresenting the givenHexadectets andOctets as an IP version 6 address.
-
ipVFutureAddress
public static Host ipVFutureAddress(java.lang.String version, java.lang.String address)
Factory method for creating IP version future typeHosts.- Parameters:
version- aStringconsisting of at least one character, made up solely of hexadecimal digits, namely 0-9 and A-F.address- aStringconsisting of at least one character, made up solely of characters from the Latin alphabet, the digits, and any of '-', '.', '_' , '~' , '!' , '$' , '&' , ''' , '(' , ')' , '*' , '+' , ',' , ';' , '=' , ':'.- Returns:
- a
Hostrepresenting the givenHexadectets andOctets as an IP version 6 address. - Throws:
java.lang.IllegalArgumentException- if the given version or address are empty of contain characters outside the valid set.
-
-