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(String range)
          Constructor.
 
方法摘要
 int getExtendedNetworkPrefix()
          Return the extended extended network prefix.
 IPAddress getIPAddress()
          Return the encapsulated IP address.
 IPAddress getIPSubnetMask()
          Return the encapsulated subnet mask
 boolean isIPAddressInRange(IPAddress address)
          Check if the specified IP address is in the encapsulated range.
static String toDecimalString(String inBinaryIpAddress)
           
 String toString()
          Convert the IP Range into a string representation.
 
从类 java.lang.Object 继承的方法
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

构造方法详细信息

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 Alibaba Group. All Rights Reserved.