public class IPv4Address extends IPAddress implements java.lang.Comparable<IPv4Address>
| Modifier and Type | Class and Description |
|---|---|
protected static class |
IPv4Address.Ip4Octet |
static class |
IPv4Address.IPv4KnownRange |
| Modifier and Type | Field and Description |
|---|---|
static int |
ADDRESS_BITS |
static int |
ADDRESS_BYTES |
protected int |
ip |
| Constructor and Description |
|---|
IPv4Address(int intIp)
IPv4Address int constructor
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(IPv4Address o) |
boolean |
equals(java.lang.Object obj) |
int |
hashCode() |
boolean |
is6To4()
Checks whether the given address is a 6to4 address
|
boolean |
isBroadcast()
Is this the broadcast address?
|
boolean |
isLinkLocal()
Checks whether the address is link-local
|
boolean |
isLoopback()
Checks whether the address is a loopback address
|
boolean |
isMartian()
Martian addresses are reserved and private addresses that should not
appear on the public internet
|
boolean |
isMulticast()
Checks whether the address is part of a range reserved for multicast
|
boolean |
isPrivate()
Checks whether the address is private
|
boolean |
isReserved()
Checks whether the address part of a reserved range
|
boolean |
isUnspecified()
Checks whether the address is "unspecified"
|
IPv4Address |
minus(int n)
Return an address smaller than the current one by n, with wraparound
|
IPv4Address |
next()
Returns the following address, with wraparound
|
static IPv4Address |
of(byte[] bigEndianByteArr)
Build an IPv4Address from a 4 byte long big-endian (highest byte first)
byte array
|
static IPv4Address |
of(java.net.Inet4Address address)
Build an IPv4Address from an java.net.Inet4Address
|
static IPv4Address |
of(int intIp)
Build an IPv4Address from an int (32 bit)
|
static IPv4Address |
of(java.lang.String ip)
Build an IPv4Address from a literal String representations such as
"192.168.1.1"
|
IPv4Address |
plus(int n)
Return an address larger than the current one by n, with wraparound
|
IPv4Address |
previous()
Returns the previous address, with wraparound
|
protected static int |
shiftToInt(byte a,
byte b,
byte c,
byte d) |
protected static int |
shiftToInt(int a,
int b,
int c,
int d) |
byte[] |
toBigEndianArray()
The address as an array of bytes, with the highest byte first
|
java.net.Inet4Address |
toInet4Address()
Return a copy of this address, in Inet4Address form
|
int |
toInt()
Return a copy of this address in int form
|
byte[] |
toLittleEndianArray()
The address as an array of bytes, with the highest byte last
|
long |
toLong()
Return a copy of this address in long form
|
java.lang.String |
toString() |
int |
version()
Returns the version of the IP address
|
of, toArray, toBigInteger, toInetAddress, toSignedBigIntegerpublic static final int ADDRESS_BITS
public static final int ADDRESS_BYTES
protected final int ip
public IPv4Address(int intIp)
intIp - public static IPv4Address of(byte[] bigEndianByteArr)
bigEndianByteArr - 4 byte big-endian byte arraypublic static IPv4Address of(int intIp)
intIp - public static IPv4Address of(java.lang.String ip)
ip - literal IP address Stringpublic static IPv4Address of(java.net.Inet4Address address)
address - protected static int shiftToInt(int a,
int b,
int c,
int d)
protected static int shiftToInt(byte a,
byte b,
byte c,
byte d)
public int version()
IPAddresspublic int compareTo(IPv4Address o)
compareTo in interface java.lang.Comparable<IPv4Address>public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean is6To4()
IPAddresspublic boolean isBroadcast()
public boolean isMartian()
IPAddresspublic boolean isLinkLocal()
IPAddressisLinkLocal in class IPAddresspublic boolean isLoopback()
IPAddressisLoopback in class IPAddresspublic boolean isMulticast()
IPAddressisMulticast in class IPAddresspublic boolean isPrivate()
IPAddresspublic boolean isReserved()
IPAddressisReserved in class IPAddresspublic boolean isUnspecified()
IPAddressisUnspecified in class IPAddresspublic IPv4Address next()
IPAddresspublic IPv4Address plus(int n)
IPAddresspublic IPv4Address previous()
IPAddresspublic IPv4Address minus(int n)
IPAddresspublic byte[] toBigEndianArray()
IPAddresstoBigEndianArray in class IPAddresspublic java.net.Inet4Address toInet4Address()
public byte[] toLittleEndianArray()
IPAddresstoLittleEndianArray in class IPAddresspublic java.lang.String toString()
toString in class java.lang.Objectpublic int toInt()
public long toLong()