- All Implemented Interfaces:
Serializable
,Comparable<IpAddress>
,java.lang.constant.Constable
Metrics of an IP-Address as of IPv4 or IPv6.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int[]
fromAnyCidrNotation
(String aCidrNotation) Creates an IP-Address as of an integer array for the first of the enumeration elements being able to successfully parse the providedString
in CIDR notation.int[]
fromCidrNotation
(String aCidrNotation) Creates an IP-Address as of an integer array for the current enumeration from the providedString
in CIDR notation.int[]
The byte representation of the "broadcast" address (if the protocol supports a broadcast).char
The delimiter used by the CIDR notation.Returns the CIDR notation of the localhost IP-Address.Returns the CIDR notation of the unspecified IP-Address.int
Returns the length in bytes of the IP-Address.int[]
The byte representation of the "localhost".The commonly used alias for the "localhost".int[]
The byte representation of the "unspecified".static boolean
isAnyCidrNotation
(String aCidrNotation) Determines whether the givenString
represents a valid IP-Address.static boolean
isBroadcast
(int[] aIpAddress) Determines whether the given IP-Address is the broadcast address.boolean
isCidrNotation
(String aCidrNotation) Determines whether the givenString
represents a valid CIDR notation.static boolean
isLocalhost
(int[] aIpAddress) Determines whether the given IP-Address represents the IP-Address of the "localhost" as ofgetLocalhost()
.static boolean
isLoopback
(int[] aIpAddress) Determines whether the given IP-Address is in the scope of the the loopback interfaces.toCidrNotation
(int[] theIpAddress) static int[]
Tries to determine a no-localhost IP-Address for this machine.static String
toString
(int[] aIpAddress) Creates aString
as of the CIDR notation from the provided IP-Address bytes.Tries to determine the known IP-Addresses from the accessible network segment.static IpAddress
Returns the enum constant of this type with the specified name.static IpAddress[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
IPV4
IPv4: -
IPV6
IPv6:
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
getLength
public int getLength()Returns the length in bytes of the IP-Address.- Returns:
- The IP-Address' length in bytes.
-
getUnspecified
public int[] getUnspecified()The byte representation of the "unspecified".- Returns:
- The byte representation of the "unspecified".
-
getCidrUnspecified
Returns the CIDR notation of the unspecified IP-Address. See also "https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing#CIDR_notation".- Returns:
- The CIDR notation for "unspecified".
-
getLocalhost
public int[] getLocalhost()The byte representation of the "localhost".- Returns:
- The byte representation of the "localhost".
-
getBroadcast
public int[] getBroadcast()The byte representation of the "broadcast" address (if the protocol supports a broadcast).- Returns:
- The byte representation of the "broadcast" address or null if the protocol does not support a broadcast address.
-
getCidrLocalhost
Returns the CIDR notation of the localhost IP-Address. See also "https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing#CIDR_notation".- Returns:
- The CIDR notation for "localhost".
-
getLocalhostAlias
The commonly used alias for the "localhost".- Returns:
- The "localhost" alias.
-
getCidrDelimiter
public char getCidrDelimiter()The delimiter used by the CIDR notation. See also "https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing#CIDR_notation".- Returns:
- The CIDR delimiter.
-
toCidrNotation
-
fromCidrNotation
Creates an IP-Address as of an integer array for the current enumeration from the providedString
in CIDR notation.- Parameters:
aCidrNotation
- The String in CIDR notation to be parsed.- Returns:
- The IP-Address as an array of integer values.
- Throws:
IllegalArgumentException
- Thrown in case the providedString
is not of any known CIDR notation.
-
toString
Creates aString
as of the CIDR notation from the provided IP-Address bytes. See also "https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing#CIDR_notation". -
isLocalhost
public static boolean isLocalhost(int[] aIpAddress) Determines whether the given IP-Address represents the IP-Address of the "localhost" as ofgetLocalhost()
.- Parameters:
aIpAddress
- The IP-Address to be tested.- Returns:
- True in case we have an IP-Address representing the localhost, else false.
-
isLoopback
public static boolean isLoopback(int[] aIpAddress) Determines whether the given IP-Address is in the scope of the the loopback interfaces.- Parameters:
aIpAddress
- The IP-Address to be tested.- Returns:
- True in case we have an IP-Address belonging to the loopback IP-Address block, else false.
-
isBroadcast
public static boolean isBroadcast(int[] aIpAddress) Determines whether the given IP-Address is the broadcast address.- Parameters:
aIpAddress
- The IP-Address to be tested.- Returns:
- True in case we have an IP-Address being the broadcast address, else false.
-
fromAnyCidrNotation
Creates an IP-Address as of an integer array for the first of the enumeration elements being able to successfully parse the providedString
in CIDR notation.- Parameters:
aCidrNotation
- The String in CIDR notation to be parsed.- Returns:
- The IP-Address as an array of integer values.
- Throws:
IllegalArgumentException
- Thrown in case the providedString
is not of any known CIDR notation.
-
toHostIpAddress
Tries to determine a no-localhost IP-Address for this machine. The best guess is returned. If none no-localhost address is found, then the localhost's IP-Address may be returned (as ofgetLocalhost()
).- Returns:
- The best guest for a no-localhost IP-Address or as a fall back
the localhost's IP-Address (as of
getLocalhost()
) may be returned. - Throws:
IOException
- Thrown to indicate that the IP address of a host could not be determined.
-
isAnyCidrNotation
Determines whether the givenString
represents a valid IP-Address.- Parameters:
aCidrNotation
- The Text in CIDR notation to be tested.- Returns:
- True in case of being an IP-Address, else false.
-
isCidrNotation
Determines whether the givenString
represents a valid CIDR notation.- Parameters:
aCidrNotation
- The Text in CIDR notation to be tested.- Returns:
- True in case of being an IP-Address, else false.
-
toVisibleIpAddresses
Tries to determine the known IP-Addresses from the accessible network segment. It tries to invoke "arp -a" and also tries to manually detect the visible IP-Addresses.- Returns:
- A set containing the visible IP-Addresses in CIDR notation.
-