java.lang.Object
uk.ipfreely.Family<A>
-
Method Summary
Modifier and TypeMethodDescriptionmax()Maximum IP value.min()Zero.abstract Aparse(byte... address) Argument must bebitWidth() / 8bytes in length.abstract Aparse(int unsigned) Convenience method for creatingAddrfrom number.abstract Aparse(long high, long low) IP address instantiation from primitives.abstract Aparse(CharSequence candidate) Parses an IP address string.abstract Aparse(BigInteger address) Enables the conversion fromBigIntegerto theAddress type.subnets()Subnet utilities.abstract StringtoString()Informational.type()IP address type.static Addr<?> unknown(byte... address) Uses array length to detect IP address family and callsparse(byte...).static Addr<?> unknown(CharSequence candidate) Uses heuristics to detect IP address family and callsparse(CharSequence).v4()IPv4.v6()IPv6.abstract intwidth()Width of the IP address type in bits.
-
Method Details
-
v4
IPv4.// EXAMPLE V4 localhost = Family.v4().parse("127.0.0.1");- Returns:
- IPv4 family of addresses
-
v6
IPv6.- Returns:
- IPv6 family of addresses
-
toString
Informational. -
parse
IP address instantiation from primitives.
Only values up to
(0L, 0xffffffffL)are valid for IPv4.All values are valid for IPv6. Arguments are treated as unsigned.
- Parameters:
high- high bits of the IP addresslow- low bits of the IP address- Returns:
- the address
- Throws:
ParseException- on invalid values
-
parse
Parses an IP address string.- Parameters:
candidate- valid IP address in this family- Returns:
- parsed address
- Throws:
ParseException- on invalid address
-
parse
Argument must bebitWidth() / 8bytes in length.- Parameters:
address- the address as bytes- Returns:
- parsed address
- Throws:
ParseException- if the array is not the expected length
-
parse
Enables the conversion fromBigIntegerto theAddress type. The largest acceptable value ismax().toBigInteger().- Parameters:
address- must be between zero and the maximum value inclusive- Returns:
- the new address
- Throws:
ParseException- when the argument is out of range- See Also:
-
parse
Convenience method for creatingAddrfrom number. All values ofintare valid for this method. Every value in the IPv4 range can be created with this method.- Parameters:
unsigned- integer treated as unsigned value- Returns:
- IP address
-
width
public abstract int width()Width of the IP address type in bits.- Returns:
- 32 (V4) or 128 (V6)
-
type
IP address type. -
subnets
Subnet utilities.- Returns:
- subnet methods for this family
-
min
Zero.- Returns:
- "0.0.0.0" (V4) or "::" (V6)
-
max
Maximum IP value.- Returns:
- "255.255.255.255" (V4) or "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff" (V6)
-
unknown
Uses heuristics to detect IP address family and callsparse(CharSequence).- Parameters:
candidate- IP address- Returns:
- instance of
V4orV6 - Throws:
ParseException- on invalid address- See Also:
-
unknown
Uses array length to detect IP address family and callsparse(byte...).- Parameters:
address- an IPv4 or IPv6 address in byte form- Returns:
- parsed address
- Throws:
ParseException- if array is not 4 (V4) or 16 (V6) bytes in length- See Also:
-