public class IPAddress extends Object implements Comparable<IPAddress>
| Modifier and Type | Field and Description |
|---|---|
static int |
IPV4_BIT_SIZE |
static int |
IPV4_BYTE_SIZE |
static int |
IPV6_BIT_SIZE |
static int |
IPV6_BYTE_SIZE |
| Constructor and Description |
|---|
IPAddress(byte[] address)
Creates a new
IPAddress from an four element byte array. |
IPAddress(InetAddress address)
Creates a new
IPAddress from an InetAddress. |
IPAddress(int address)
Creates a new
IPAddress from an 32-Bit integer. |
IPAddress(long upperBits,
long lowerBits)
Creates a new
IPAddress from two 64-Bit integers. |
IPAddress(String address)
Creates a new
IPAddress from its string representation. |
| Modifier and Type | Method and Description |
|---|---|
(package private) static int |
compareLittleEndianUnsignedByte(byte[] a,
byte[] b)
Compares to
byte arrays. |
int |
compareTo(IPAddress o) |
boolean |
equals(Object obj) |
int |
getBitSize()
Get the number of bits the address contains.
|
byte[] |
getBytes() |
int |
getByteSize()
Get the number of bytes the address contains.
|
InetAddress |
getInetAddress() |
static Pattern |
getV4Pattern()
Get the regular expression matching an IPv4.
|
static Pattern |
getV6Pattern()
Get the regular expression matching an IPv6.
|
int |
hashCode() |
boolean |
isIPv4()
Checks if this address is IPv4.
|
boolean |
isIPv6()
Checks if this address is IPv6.
|
String |
toString() |
public static final int IPV6_BYTE_SIZE
public static final int IPV4_BYTE_SIZE
public static final int IPV6_BIT_SIZE
public static final int IPV4_BIT_SIZE
public IPAddress(int address)
IPAddress from an 32-Bit integer.address - the addresspublic IPAddress(long upperBits,
long lowerBits)
IPAddress from two 64-Bit integers.upperBits - the 64 upper bits of the addresslowerBits - the 64 lower bits of the addresspublic IPAddress(byte[] address)
IPAddress from an four element byte array.address - the addresspublic IPAddress(String address)
IPAddress from its string representation.address - the addresspublic IPAddress(InetAddress address)
IPAddress from an InetAddress.address - the addresspublic boolean isIPv4()
public int getBitSize()
public int getByteSize()
public boolean isIPv6()
public InetAddress getInetAddress()
Inet4Addresspublic byte[] getBytes()
public int compareTo(IPAddress o)
compareTo in interface Comparable<IPAddress>static int compareLittleEndianUnsignedByte(byte[] a,
byte[] b)
byte arrays. Each element is compared with the corresponding element in the other array. If
the array sizes differ the shorter array is treated as it would contain leading zeros.a - the first byte arrayb - the second byte array0 if a == b; a value less than 0 if a < b; and a value greater
than 0 if a > bpublic static Pattern getV4Pattern()
public static Pattern getV6Pattern()
Copyright © 2015–2021 52North Initiative for Geospatial Open Source Software GmbH. All rights reserved.