- java.lang.Object
-
- net.sourceforge.urin.Host
-
public abstract class Host extends java.lang.Object
A 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 Host
LOCAL_HOST
The registered name "localhost".static Host
LOOPBACK_ADDRESS_IP_V4
The loopback address in IP v4 format, in other words 127.0.0.1static Host
LOOPBACK_ADDRESS_IP_V6
The loopback address in IP v6 format, in other words ::1static Host
UNSPECIFIED_ADDRESS_IP_V6
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Host
ipV4Address(int firstOctet, int secondOctet, int thirdOctet, int fourthOctet)
Factory method for creating IP version 4 typeHost
s.static Host
ipV4Address(Octet firstOctet, Octet secondOctet, Octet thirdOctet, Octet fourthOctet)
Factory method for creating IP version 4 typeHost
s.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 typeHost
s with all parts specified asHexadectet
s.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 typeHost
s with the least significant 32 bits specified as in IP version 4 address format.static Host
ipVFutureAddress(java.lang.String version, java.lang.String address)
Factory method for creating IP version future typeHost
s.static Host
registeredName(java.lang.String registeredName)
Factory method for creating registered name typeHost
s.
-
-
-
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 typeHost
s.- Parameters:
registeredName
- anyString
to represent as aHost
.- Returns:
- a
Host
representing the givenString
as a registered name.
-
ipV4Address
public static Host ipV4Address(Octet firstOctet, Octet secondOctet, Octet thirdOctet, Octet fourthOctet)
Factory method for creating IP version 4 typeHost
s. IP version 4Host
s are made up of fourOctet
s.- Parameters:
firstOctet
- the first octetsecondOctet
- the second octetthirdOctet
- the third octetfourthOctet
- the fourth octet- Returns:
- a
Host
representing the givenOctet
s 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 typeHost
s. IP version 4Host
s are made up of fourOctet
s, which are created from the givenint
s.- Parameters:
firstOctet
- the first octetsecondOctet
- the second octetthirdOctet
- the third octetfourthOctet
- the fourth octet- Returns:
- a
Host
representing the givenint
s 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 typeHost
s with all parts specified asHexadectet
s.- 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
Host
representing the givenHexadectet
s 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 typeHost
s 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
Host
representing the givenHexadectet
s andOctet
s 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 typeHost
s.- Parameters:
version
- aString
consisting of at least one character, made up solely of hexadecimal digits, namely 0-9 and A-F.address
- aString
consisting of at least one character, made up solely of characters from the Latin alphabet, the digits, and any of '-', '.', '_' , '~' , '!' , '$' , '&' , ''' , '(' , ')' , '*' , '+' , ',' , ';' , '=' , ':'.- Returns:
- a
Host
representing the givenHexadectet
s andOctet
s 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.
-
-