public interface AddressItem extends Comparable<AddressItem>, Serializable
The basic difference between the AddressComponent hierarchy and the AddressDivision hierarchy is that
AddressComponent hierarchy uses
AddressDivision allows alternative arrangements, such as inet_aton style of presenting ipv4 in fewer divisions, or base 85 for ipv6 which does not even use a base that is a power of 2 (and hence so subdivisions possibly using bit boundaries), or the aaa-bbb-ccc-ddd mac format with which segments are not divided along byte boundaries
Parsing creates objects in the AddressComponent hierarchy, which can then be used to create alternative arrangements using AddressDivisionGrouping
or AddressStringDivisionSeries
Modifier and Type | Method and Description |
---|---|
default int |
compareTo(AddressItem other)
Uses
Address.DEFAULT_ADDRESS_COMPARATOR , an instance of AddressComparator.CountComparator , to compare any two address items. |
default boolean |
containsPrefixBlock(int divisionPrefixLen)
Returns whether the values of this series contains the prefix block for the given prefix length.
|
default boolean |
containsSinglePrefixBlock(int divisionPrefixLen)
Returns whether the values of this series contains a single prefix block for the given prefix length.
|
int |
getBitCount()
Provides the number of bits comprising this address item
|
static Integer |
getBitsForCount(long count)
BitsForCount returns the number of bits required outside the prefix length
for a single prefix block to span at least as many addresses as the given count.
|
static BigInteger |
getBlockSize(int bitCount)
Returns the total number of values when ranging across the given number of host bits.
|
default int |
getByteCount()
Provides the number of bytes required for this address item, rounding up if the bit count is not a multiple of 8
|
byte[] |
getBytes() |
byte[] |
getBytes(byte[] bytes)
Copies the bytes of the lowest address item represented by this address item into the supplied array,
and returns that array.
|
byte[] |
getBytes(byte[] bytes,
int index)
Copies the bytes of the lowest address item represented by this address item into the supplied array starting at the given index,
and returns that array.
|
default BigInteger |
getCount()
The count of possible distinct values for this AddressComponent.
|
default int |
getMinPrefixLengthForBlock()
Returns the smallest prefix length possible such that this item includes the block of all values for that prefix length.
|
default BigInteger |
getPrefixCount(int prefixLength)
The count of the number of distinct values within the prefix part of the address item, the bits that appear within the prefix length.
|
default Integer |
getPrefixLengthForSingleBlock()
Returns a prefix length for which the range of this item matches the block of all values for that prefix length.
|
byte[] |
getUpperBytes() |
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.
|
byte[] |
getUpperBytes(byte[] bytes,
int index)
Copies the bytes of the largest address item represented by this address item into the supplied array at the given index,
and returns that array.
|
BigInteger |
getUpperValue()
Returns the highest value represented by this address item, the highest value included in the range of values
|
BigInteger |
getValue()
Returns the lowest value represented by this address item, the lowest value included in the range of values
|
boolean |
includesMax()
Returns whether this item includes the maximum possible value for the address type or version within its range
|
boolean |
includesZero()
Returns whether this item includes the value of zero within its range
|
default boolean |
isFullRange()
whether this address item represents all possible values attainable by an address item of this type
|
boolean |
isMax()
Returns whether this item matches the maximum possible value for the address type or version
|
default boolean |
isMultiple()
Whether this represents multiple potential values (eg a prefixed address or a segment representing a range of values)
|
boolean |
isZero()
Returns whether this item matches the value of zero
|
default int compareTo(AddressItem other)
Address.DEFAULT_ADDRESS_COMPARATOR
, an instance of AddressComparator.CountComparator
, to compare any two address items.compareTo
in interface Comparable<AddressItem>
default BigInteger getCount()
default BigInteger getPrefixCount(int prefixLength)
prefixLength
- int getBitCount()
default int getByteCount()
default boolean isMultiple()
byte[] getBytes()
byte[] getBytes(byte[] bytes)
byte[] getBytes(byte[] bytes, int index)
byte[] getUpperBytes()
byte[] getUpperBytes(byte[] bytes)
byte[] getUpperBytes(byte[] bytes, int index)
BigInteger getValue()
BigInteger getUpperValue()
boolean isZero()
boolean includesZero()
boolean isMax()
boolean includesMax()
default boolean isFullRange()
default boolean containsPrefixBlock(int divisionPrefixLen)
Use getMinPrefixLengthForBlock()
to determine the smallest prefix length for which this method returns true.
divisionPrefixLen
- PrefixLenException
- if prefixLength exceeds the bit count or is negativedefault boolean containsSinglePrefixBlock(int divisionPrefixLen)
Use getPrefixLengthForSingleBlock()
to determine whether there is a prefix length for which this method returns true.
divisionPrefixLen
- PrefixLenException
- if prefixLength exceeds the bit count or is negativedefault int getMinPrefixLengthForBlock()
If the entire range can be dictated this way, then this method returns the same value as getPrefixLengthForSingleBlock()
.
Otherwise, this method will return the minimal possible prefix that can be paired with this address, while getPrefixLengthForSingleBlock()
will return null.
In cases where the final bit is constant so there is no such block, this returns the bit count.
default Integer getPrefixLengthForSingleBlock()
If the range can be dictated this way, then this method returns the same value as getMinPrefixLengthForBlock()
.
If no such prefix length exists, returns null.
If this item represents a single value, this returns the bit count.
static BigInteger getBlockSize(int bitCount)
getBitsForCount(long)
.
A bitCount of zero or less returns zero.bitCount
- static Integer getBitsForCount(long count)
getBlockSize(int)
for the reverse direction.count
-