public class Cidr
extends java.lang.Object
implements java.io.Serializable
Modifier and Type | Field and Description |
---|---|
static Cidr |
_10 |
static Cidr |
_127 |
static Cidr |
_169_254 |
static Cidr |
_172_16 |
static Cidr |
_192_168 |
static Cidr |
CLASS_A |
static Cidr |
CLASS_B |
static Cidr |
CLASS_C |
static Cidr |
LINK_LOCAL |
static Cidr |
LOOPBACK |
static java.util.List<Cidr> |
NON_PUBLIC_CIDRS |
static java.util.List<Cidr> |
PRIVATE_NETWORKS_RFC_1918 |
static Cidr |
UNIVERSAL
0.0.0.0/0 -- matches all addresses
|
Constructor and Description |
---|
Cidr(int... unsignedBytes)
allows creation as Cidr(192, 168) for 192.168.0.0/16;
zero bits or ints included are significant, i.e.
|
Cidr(int[] subnetBytes,
int length) |
Cidr(java.lang.String cidr) |
Modifier and Type | Method and Description |
---|---|
java.net.InetAddress |
addressAtOffset(int offset)
taking the addresses in the CIDR in order, returns the one in the offset^th position
(starting with the CIDR itself, even if final bits are 0)
|
BitList |
asBitList()
returns list of bits for the significant (length) bits of this CIDR
|
Cidr |
commonPrefix(Cidr other) |
int |
commonPrefixLength(Cidr other)
returns length of the prefix in common between the two cidrs
|
boolean |
contains(Cidr target) |
boolean |
equals(java.lang.Object obj) |
int[] |
getBytes() |
static java.net.InetAddress |
getInetAddressWithFixedName(byte[] ip)
Deprecated.
|
int |
getLength() |
int |
hashCode() |
static boolean |
isCanonical(java.lang.String cidr)
returns true iff this CIDR is well-formed and canonical,
i.e.
|
java.net.InetAddress |
netmask()
returns the netmask for this cidr; e.g.
|
Cidr |
subnet(int... extraUnsignedBytes) |
java.lang.String |
toString() |
public static final Cidr UNIVERSAL
public static final Cidr _10
public static final Cidr _172_16
public static final Cidr _192_168
public static final Cidr CLASS_A
public static final Cidr CLASS_B
public static final Cidr CLASS_C
public static final java.util.List<Cidr> PRIVATE_NETWORKS_RFC_1918
public static final Cidr _169_254
public static final Cidr LINK_LOCAL
public static final Cidr _127
public static final Cidr LOOPBACK
public static final java.util.List<Cidr> NON_PUBLIC_CIDRS
public Cidr(java.lang.String cidr)
public Cidr(int... unsignedBytes)
public Cidr(int[] subnetBytes, int length)
public static boolean isCanonical(java.lang.String cidr)
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public int[] getBytes()
public int getLength()
public Cidr subnet(int... extraUnsignedBytes)
public java.net.InetAddress netmask()
public java.net.InetAddress addressAtOffset(int offset)
public int commonPrefixLength(Cidr other)
public BitList asBitList()
public boolean contains(Cidr target)
@Deprecated public static java.net.InetAddress getInetAddressWithFixedName(byte[] ip)
Networking.getInetAddressWithFixedName(byte[])