Class CIDRUtil
- java.lang.Object
-
- com.github.toolarium.enumeration.configuration.util.CIDRUtil
-
public final class CIDRUtil extends java.lang.Object
CIDR utility
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
CIDRUtil.CIDR
CIDR
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
IPV4_EXPRESSION
Regular expression: ipv4 address patternstatic java.lang.String
IPV4_RANGE_EXPRESSION
Regular expression: ipv4 address range patternstatic java.lang.String
IPV6_EXPRESSION
Regular expression: ipv6 address patternstatic java.lang.String
IPV6_EXPRESSION_HEX_COMPRESSED
Regular expression: ipv6 address patternstatic java.lang.String
IPV6_EXPRESSION_STD
Regular expression: ipv6 address patternstatic java.lang.String
IPV6_RANGE_EXPRESSION
Regular expression: ipv6 address range pattern
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static CIDRUtil
getInstance()
Get the instanceboolean
isInRange(java.lang.String hostRange, java.lang.String host)
Check if the address is an ip address or an ip address range.boolean
isIPv4Address(java.lang.String host)
Validate if the given host is an instance of ipv4boolean
isIPv4Range(java.lang.String host)
Check if the host string is instance of IPv4 range (cidr notation)boolean
isIPv6Address(java.lang.String host)
Validate if the given host is an instance of ipv6 addressboolean
isIPv6Range(java.lang.String host)
Check if the host string is instance of IPv6 range (cidr notation)boolean
isValidAddress(java.lang.String host)
Validate if the host string is instance of ipv4 or ipv6 addressboolean
isValidAddressRange(java.lang.String host)
Validate if the given host is an instance of ipv4 or ipv6 addressboolean
isValidRange(java.lang.String host)
Check if the host string is a valid IP address (cidr notation)CIDRUtil.CIDR
parse(java.lang.String cidrExpression)
Parse CIDR expression
-
-
-
Field Detail
-
IPV4_EXPRESSION
public static final java.lang.String IPV4_EXPRESSION
Regular expression: ipv4 address pattern- See Also:
- Constant Field Values
-
IPV6_EXPRESSION_STD
public static final java.lang.String IPV6_EXPRESSION_STD
Regular expression: ipv6 address pattern- See Also:
- Constant Field Values
-
IPV6_EXPRESSION_HEX_COMPRESSED
public static final java.lang.String IPV6_EXPRESSION_HEX_COMPRESSED
Regular expression: ipv6 address pattern- See Also:
- Constant Field Values
-
IPV6_EXPRESSION
public static final java.lang.String IPV6_EXPRESSION
Regular expression: ipv6 address pattern- See Also:
- Constant Field Values
-
IPV4_RANGE_EXPRESSION
public static final java.lang.String IPV4_RANGE_EXPRESSION
Regular expression: ipv4 address range pattern- See Also:
- Constant Field Values
-
IPV6_RANGE_EXPRESSION
public static final java.lang.String IPV6_RANGE_EXPRESSION
Regular expression: ipv6 address range pattern- See Also:
- Constant Field Values
-
-
Method Detail
-
getInstance
public static CIDRUtil getInstance()
Get the instance- Returns:
- the instance
-
isValidAddress
public boolean isValidAddress(java.lang.String host)
Validate if the host string is instance of ipv4 or ipv6 address- Parameters:
host
- the host- Returns:
- true if it is valid otherwise false
-
isValidAddressRange
public boolean isValidAddressRange(java.lang.String host)
Validate if the given host is an instance of ipv4 or ipv6 address- Parameters:
host
- the host- Returns:
- true if it is valid otherwise false
-
isIPv4Address
public boolean isIPv4Address(java.lang.String host)
Validate if the given host is an instance of ipv4- Parameters:
host
- the host- Returns:
- true if it is valid otherwise false
-
isIPv6Address
public boolean isIPv6Address(java.lang.String host)
Validate if the given host is an instance of ipv6 address- Parameters:
host
- the host- Returns:
- true if it is valid otherwise false
-
isValidRange
public boolean isValidRange(java.lang.String host)
Check if the host string is a valid IP address (cidr notation)- Parameters:
host
- the host- Returns:
- true if it is
-
isIPv4Range
public boolean isIPv4Range(java.lang.String host)
Check if the host string is instance of IPv4 range (cidr notation)- Parameters:
host
- the host- Returns:
- true if it is
-
isIPv6Range
public boolean isIPv6Range(java.lang.String host)
Check if the host string is instance of IPv6 range (cidr notation)- Parameters:
host
- the host- Returns:
- true if it is
-
isInRange
public boolean isInRange(java.lang.String hostRange, java.lang.String host)
Check if the address is an ip address or an ip address range. IPv4 and IPv6 are supported.- Parameters:
hostRange
- the host rangehost
- the host to check- Returns:
- true if the host name is belong to given range
-
parse
public CIDRUtil.CIDR parse(java.lang.String cidrExpression) throws java.net.UnknownHostException
Parse CIDR expression- Parameters:
cidrExpression
- the CIDR expression- Returns:
- the processed CIDR
- Throws:
java.net.UnknownHostException
- In case of invalid address
-
-