com.alibaba.druid.support.http.util
类 IPRange
java.lang.Object
com.alibaba.druid.support.http.util.IPRange
public class IPRange
- extends Object
This class represents an IP Range, which are represented by an IP address and and a subnet mask. The standards
describing modern routing protocols often refer to the extended-network-prefix-length rather than the subnet mask.
The prefix length is equal to the number of contiguous one-bits in the traditional subnet mask. This means that
specifying the network address 130.5.5.25 with a subnet mask of 255.255.255.0 can also be expressed as 130.5.5.25/24.
The / notation is more compact and easier to understand than writing out the mask in its traditional
dotted-decimal format.
130.5.5.25
10000010 . 00000101 . 00000101 . 00011001
255.255.255.0
11111111 . 11111111 . 11111111 . 00000000
<--extended-network-prefix -->
or
130.5.5.25/24
10000010 . 00000101 . 00000101 . 00011001
This class supports both standards : the extended network prefix and the subnet mask.
- 版本:
- 1.0
- 作者:
- Marcel Dullaart
- 另请参见:
IPAddress
IPRange
public IPRange(String range)
- Constructor.
- 参数:
ip - String representation of the IP address. The two following formats are supported :
xxx.xxx.xxx.xxx/xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx/xx <- extended network prefix
- 抛出:
InvalidIPRangeException - Throws this exception when the specified string doesn't represent a valid IP
address.
getIPAddress
public final IPAddress getIPAddress()
- Return the encapsulated IP address.
- 返回:
- The IP address.
getIPSubnetMask
public final IPAddress getIPSubnetMask()
- Return the encapsulated subnet mask
- 返回:
- The IP range's subnet mask.
getExtendedNetworkPrefix
public final int getExtendedNetworkPrefix()
- Return the extended extended network prefix.
- 返回:
- Return the extended network prefix.
toString
public String toString()
- Convert the IP Range into a string representation.
- 覆盖:
- 类
Object 中的 toString
- 返回:
- Return the string representation of the IP Address following the common format xxx.xxx.xxx.xxx/xx (IP
address/extended network prefixs).
toDecimalString
public static String toDecimalString(String inBinaryIpAddress)
isIPAddressInRange
public boolean isIPAddressInRange(IPAddress address)
- Check if the specified IP address is in the encapsulated range.
- 参数:
address - The IP address to be tested.
- 返回:
- Return
true if the specified IP address is in the encapsulated IP range, otherwise return
false.
Copyright © 2013-2014 Alibaba Group. All Rights Reserved.