public class AddressDivisionGrouping extends java.lang.Object implements AddressDivisionSeries, java.lang.Comparable<AddressDivisionGrouping>
AddressDivisionGrouping objects are immutable. This also makes them thread-safe.
Modifier and Type | Class and Description |
---|---|
static class |
AddressDivisionGrouping.StringOptions
Represents a clear way to create a specific type of string.
|
Constructor and Description |
---|
AddressDivisionGrouping(AddressDivision[] divisions) |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(AddressDivisionGrouping other) |
boolean |
equals(java.lang.Object o) |
int |
getBitCount() |
byte[] |
getBytes()
Gets the bytes for the lowest address in the range represented by this address.
|
byte[] |
getBytes(byte[] bytes)
Gets the value for the lowest address in the range represented by this address division.
|
java.math.BigInteger |
getCount()
gets the count of addresses that this address may represent
If this address is not a CIDR and it has no range, then there is only one such address.
|
AddressDivision |
getDivision(int index) |
int |
getDivisionCount() |
java.lang.Integer |
getEquivalentPrefix()
Returns a prefix length for which the range of this segment grouping can be specified only using the section's lower value and the prefix length
If no such prefix exists, returns null
If this segment grouping represents a single value, returns the bit length
|
int |
getMinPrefix()
Returns the smallest prefix length possible
such that this address paired with that prefix length represents the exact same range of addresses.
|
java.lang.Integer |
getPrefixLength()
The bit-length of the portion of the address that is not specific to an individual address but common amongst a group of addresses.
|
byte[] |
getUpperBytes()
Gets the bytes for the highest address in the range represented by this address.
|
byte[] |
getUpperBytes(byte[] bytes)
Copies the bytes of the largest address item represented by this address item into the supplied array,
and returns that array.
|
int |
hashCode() |
boolean |
isFullRange() |
int |
isMore(AddressDivisionSeries other)
Use this method to compare the counts of two address series.
|
boolean |
isMultiple()
Whether this represents multiple potential values (eg a prefixed address or a segment representing a range of values)
|
boolean |
isMultipleByPrefix()
whether there is a prefix and it is less than the bit-count
|
boolean |
isPrefixed()
Whether there exists a prefix.
|
boolean |
isRangeEquivalent(int prefix) |
boolean |
isRangeEquivalentToPrefix()
whether there is a prefix and the range of values is dictated entirely by the prefix.
|
boolean |
isZero() |
java.lang.String |
toString() |
public AddressDivisionGrouping(AddressDivision[] divisions)
public AddressDivision getDivision(int index)
getDivision
in interface AddressDivisionSeries
getDivision
in interface AddressStringDivisionSeries
public int getDivisionCount()
getDivisionCount
in interface AddressStringDivisionSeries
public int getBitCount()
getBitCount
in interface AddressItem
public byte[] getBytes()
getBytes
in interface AddressItem
public byte[] getBytes(byte[] bytes)
getBitCount()
to determine the required array length for the bytes.
Since bytes are signed values while addresses are unsigned, values greater than 127 are
represented as the (negative) two's complement value of the actual value.
You can get the unsigned integer value i from byte b using i = 0xff & b.getBytes
in interface AddressItem
public byte[] getUpperBytes()
getUpperBytes
in interface AddressItem
public byte[] getUpperBytes(byte[] bytes)
AddressItem
getUpperBytes
in interface AddressItem
public boolean isPrefixed()
AddressDivisionSeries
isPrefixed
in interface AddressDivisionSeries
public java.lang.Integer getPrefixLength()
AddressDivisionSeries
getPrefixLength
in interface AddressDivisionSeries
public int getMinPrefix()
getMinPrefix
in interface AddressDivisionSeries
public java.lang.Integer getEquivalentPrefix()
getEquivalentPrefix
in interface AddressDivisionSeries
public java.math.BigInteger getCount()
getCount
in interface AddressItem
public int isMore(AddressDivisionSeries other)
AddressDivisionSeries
isMore
in interface AddressDivisionSeries
public boolean isMultiple()
AddressItem
isMultiple
in interface AddressItem
public boolean isMultipleByPrefix()
AddressDivisionSeries
isMultipleByPrefix
in interface AddressDivisionSeries
public boolean isRangeEquivalentToPrefix()
AddressDivisionSeries
isRangeEquivalentToPrefix
in interface AddressDivisionSeries
public boolean isRangeEquivalent(int prefix)
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int compareTo(AddressDivisionGrouping other)
compareTo
in interface java.lang.Comparable<AddressDivisionGrouping>
public java.lang.String toString()
toString
in class java.lang.Object
public boolean isZero()
isZero
in interface AddressItem
public boolean isFullRange()
isFullRange
in interface AddressItem