|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.alibaba.druid.support.http.util.IPAddress
public class IPAddress
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 -->
| Constructor Summary | |
|---|---|
IPAddress(int address)
Constructor. |
|
IPAddress(String ipAddressStr)
Constructor. |
|
| Method Summary | |
|---|---|
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. |
| Methods inherited from class java.lang.Object |
|---|
getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public IPAddress(String ipAddressStr)
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.public IPAddress(int address)
ip - Binary representation of the IP address.| Method Detail |
|---|
public final int getIPAddress()
public String toString()
toString in class Objectpublic final boolean isClassA()
true if the encapsulated IP address belongs to a class A IP address, otherwise
returne false.public final boolean isClassB()
true if the encapsulated IP address belongs to a class B IP address, otherwise
returne false.public final boolean isClassC()
true if the encapsulated IP address belongs to a class C IP address, otherwise
returne false.public int hashCode()
hashCode in class Objectpublic boolean equals(Object another)
equals in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||