|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.dhcp4java.InetCidr
public class InetCidr
Constructor Summary | |
---|---|
InetCidr(java.net.InetAddress addr,
java.net.InetAddress netMask)
Constructs a InetCidr provided an ip address and an ip mask. |
|
InetCidr(java.net.InetAddress addr,
int mask)
Constructor for InetCidr. |
Method Summary | |
---|---|
static InetCidr[] |
addr2Cidr(java.net.InetAddress addr)
Returns an array of all cidr combinations with the provided ip address. |
static void |
checkNoOverlap(java.util.List<InetCidr> list)
Checks whether the list does not contain any overlapping cidr(s). |
int |
compareTo(InetCidr o)
Compare two InetCidr by its addr as main criterion, mask as second. |
boolean |
equals(java.lang.Object obj)
|
static InetCidr |
fromLong(long l)
Creates a new InetCidr from its long representation. |
java.net.InetAddress |
getAddr()
|
long |
getAddrLong()
|
int |
getMask()
|
int |
hashCode()
|
static boolean |
isSorted(java.util.List<InetCidr> list)
Checks whether a list of InetCidr is strictly sorted (no 2 equal objects). |
long |
toLong()
Returns a long representation of Cidr. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public InetCidr(java.net.InetAddress addr, int mask)
Takes a network address (IPv4) and a mask length
addr
- IPv4 addressmask
- mask lentgh (between 1 and 32)
java.lang.NullPointerException
- if addr is null
java.lang.IllegalArgumentException
- if addr is not IPv4public InetCidr(java.net.InetAddress addr, java.net.InetAddress netMask)
If the mask is not valid, an exception is raised.
addr
- the ip address (IPv4)netMask
- the ip mask
java.lang.IllegalArgumentException
- if addr or netMask is null.
java.lang.IllegalArgumentException
- if the netMask is not a valid one.Method Detail |
---|
public java.lang.String toString()
toString
in class java.lang.Object
public java.net.InetAddress getAddr()
public long getAddrLong()
public int getMask()
public final long toLong()
The high 32 bits contain the mask, the low 32 bits the network address.
public static final InetCidr fromLong(long l)
l
- the Cidr in its "long" format
java.lang.IllegalArgumentException
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public static InetCidr[] addr2Cidr(java.net.InetAddress addr)
The array is ordered from the most specific to the most general mask.
addr
-
public int compareTo(InetCidr o)
Note: this class has a natural ordering that is inconsistent with equals.
compareTo
in interface java.lang.Comparable<InetCidr>
o
-
public static boolean isSorted(java.util.List<InetCidr> list)
list
- list of potentially sorted InetCidr
java.lang.NullPointerException
- if one or more elements of the list are nullpublic static void checkNoOverlap(java.util.List<InetCidr> list)
Pre-requisite: list must be already sorted.
list
- sorted list of InetCidr
java.lang.NullPointerException
- if a list element is null
java.lang.IllegalStateException
- if overlapping cidr are detected
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |