com.alibaba.druid.support.http.util
类 IPAddress

java.lang.Object
  继承者 com.alibaba.druid.support.http.util.IPAddress
所有已实现的接口:
Cloneable

public class IPAddress
extends Object
implements Cloneable

This class represents an IP address represented by an 32 bits integer value. Dotted-decimal notation divides the 32-bit Internet address into four 8-bit (byte) fields and specifies the value of each field independently as a decimal number with the fields separated by dots :

    10010001 . 00001010 . 00100010 . 00000011
       145        10         34          3

                -> 145.10.34.3


IP address are classified into three classes :

class A:

    bit#   0  1                 7 8                           31
          +--+-------------------+------------------------------+
          |0 |                   |                              |
          +--+-------------------+------------------------------+
           <-- network number --> <------- host number -------->


class B:

    bit#   0  2                      15 16                    31
          +--+-------------------------+------------------------+
          |10|                         |                        |
          +--+-------------------------+------------------------+
           <----- network number -----> <---- host number ----->


class C:

    bit#   0   3                          23 24               31
          +---+-----------------------------+-------------------+
          |110|                             |                   |
          +---+-----------------------------+-------------------+
           <------- network number --------> <-- host number -->


版本:
1.0
作者:
Marcel Dullaart

构造方法摘要
IPAddress(int address)
          Constructor.
IPAddress(String ipAddressStr)
          Constructor.
 
方法摘要
 boolean equals(Object another)
           
 int getIPAddress()
          Return the integer representation of the IP address.
 int hashCode()
           
 boolean isClassA()
          Check if the IP address is belongs to a Class A IP address.
 boolean isClassB()
          Check if the IP address is belongs to a Class B IP address.
 boolean isClassC()
          Check if the IP address is belongs to a Class C IP address.
 String toString()
          Return the string representation of the IP Address following the common decimal-dotted notation xxx.xxx.xxx.xxx.
 
从类 java.lang.Object 继承的方法
getClass, notify, notifyAll, wait, wait, wait
 

构造方法详细信息

IPAddress

public IPAddress(String ipAddressStr)
Constructor.

参数:
ip - String representation of the IP address. The format of the ip's string representation must follow the decimal-dotted notation xxx.xxx.xxx.xxx.
抛出:
InvalidIPAddressException - Throws this exception when the specified string doesn't represent a valid IP address.

IPAddress

public IPAddress(int address)
Constructor.

参数:
ip - Binary representation of the IP address.
方法详细信息

getIPAddress

public final int getIPAddress()
Return the integer representation of the IP address.

返回:
The IP address.

toString

public String toString()
Return the string representation of the IP Address following the common decimal-dotted notation xxx.xxx.xxx.xxx.

覆盖:
Object 中的 toString
返回:
Return the string representation of the IP address.

isClassA

public final boolean isClassA()
Check if the IP address is belongs to a Class A IP address.

返回:
Return true if the encapsulated IP address belongs to a class A IP address, otherwise returne false.

isClassB

public final boolean isClassB()
Check if the IP address is belongs to a Class B IP address.

返回:
Return true if the encapsulated IP address belongs to a class B IP address, otherwise returne false.

isClassC

public final boolean isClassC()
Check if the IP address is belongs to a Class C IP address.

返回:
Return true if the encapsulated IP address belongs to a class C IP address, otherwise returne false.

hashCode

public int hashCode()
覆盖:
Object 中的 hashCode

equals

public boolean equals(Object another)
覆盖:
Object 中的 equals


Copyright © 2013-2014 Alibaba Group. All Rights Reserved.