public interface AddressItem extends java.lang.Comparable<AddressItem>, java.io.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
|
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 java.math.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 java.math.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 java.lang.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.
|
java.math.BigInteger |
getUpperValue()
Returns the highest value represented by this address item, the highest value included in the range of values
|
java.math.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() |
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
|
static boolean |
testRange(java.math.BigInteger lowerValue,
java.math.BigInteger upperValue,
java.math.BigInteger finalUpperValue,
java.math.BigInteger networkMask,
java.math.BigInteger hostMask) |
static boolean |
testRange(java.math.BigInteger lowerValue,
java.math.BigInteger upperValue,
java.math.BigInteger finalUpperValue,
int bitCount,
int divisionPrefixLen) |
default int compareTo(AddressItem other)
Address.DEFAULT_ADDRESS_COMPARATOR
, an instance of AddressComparator.CountComparator
, to compare any two address items.compareTo
in interface java.lang.Comparable<AddressItem>
default java.math.BigInteger getCount()
default java.math.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)
java.math.BigInteger getValue()
java.math.BigInteger getUpperValue()
boolean isZero()
boolean includesZero()
boolean isMax()
boolean includesMax()
default boolean isFullRange()
static boolean testRange(java.math.BigInteger lowerValue, java.math.BigInteger upperValue, java.math.BigInteger finalUpperValue, java.math.BigInteger networkMask, java.math.BigInteger hostMask)
static boolean testRange(java.math.BigInteger lowerValue, java.math.BigInteger upperValue, java.math.BigInteger finalUpperValue, int bitCount, int divisionPrefixLen)
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 java.lang.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.