public class IPAddressDivisionGrouping extends AddressDivisionGrouping implements IPAddressStringDivisionSeries
With the IPAddressSection subclass, each division is one segment (eg either groupings of 4 like 1.2.3.4 or groupings of 8 like 1:2:3:4:5:6:7:8).
For IPv6, a compressed segment still counts as one of the groupings, it is simply not printed as part of the text representation.
Alternative groupings include ipv4 groupings define by inet_aton (eg groupings of 1, 2, or 3 divisions like 1, 1.2, and 1.2.3) and the mixed ipv6/ipv4 representation of ipv6 addresses (eg a grouping of 10 divisions like a:b:c:d:e:f:1.2.3.4)
IPAddressDivisionGrouping objects are immutable. Some of the derived state is created upon demand and cached. This also makes them thread-safe.
IPAddressDivisionGrouping objects may be associated with a prefix length, in which case that number of bits in the upper-most portion of the object represent a prefix, while the remaining bits assume all possible values.
Modifier and Type | Class and Description |
---|---|
static class |
IPAddressDivisionGrouping.Range |
static class |
IPAddressDivisionGrouping.RangeList |
AddressDivisionGrouping.StringOptions
Constructor and Description |
---|
IPAddressDivisionGrouping(IPAddressDivision[] divisions,
IPAddressNetwork<?,?,?,?,?> network)
If the grouping is prefixed, then note that we allow both null:null:x:0:0 where is x is the division bit count and null:null:0:0:0 which essentially have the same overall prefix grouping prefix.
|
Modifier and Type | Method and Description |
---|---|
boolean |
containsPrefixBlock(int prefixLength)
Returns whether the values of this division grouping contain the prefix block for the given prefix length
|
boolean |
containsSinglePrefixBlock(int prefixLength)
Returns whether the values of this division grouping match the prefix block for the given prefix length
|
boolean |
equals(java.lang.Object o) |
IPAddressDivision |
getDivision(int index) |
IPAddressNetwork<?,?,?,?,?> |
getNetwork() |
java.lang.Integer |
getNetworkPrefixLength() |
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.
|
java.lang.Integer |
getPrefixLengthForSingleBlock()
Returns a prefix length for which the range of this segment grouping matches the the block of addresses for that prefix.
|
IPAddressDivisionGrouping.RangeList |
getZeroRangeSegments() |
IPAddressDivisionGrouping.RangeList |
getZeroSegments() |
boolean |
includesZeroHost() |
int |
isMore(AddressDivisionSeries other)
Use this method to compare the counts of two address series.
|
boolean |
isPrefixBlock()
Returns whether this address section represents a subnet block of addresses associated its prefix length.
|
boolean |
isPrefixed()
Whether there exists a prefix.
|
boolean |
isSinglePrefixBlock()
Returns whether the division grouping range matches the block of values for its prefix length.
|
compareTo, getBitCount, getBytes, getBytes, getCount, getDivisionCount, getDivisionStrings, getMinPrefixLengthForBlock, getPrefixCount, getUpperBytes, getUpperBytes, getUpperValue, getValue, hashCode, includesMax, includesZero, isFullRange, isMax, isMultiple, isZero, toString
getDivisionCount
public IPAddressDivisionGrouping(IPAddressDivision[] divisions, IPAddressNetwork<?,?,?,?,?> network) throws AddressValueException
AddressDivisionGrouping.normalizePrefixBoundary(int, IPAddressSegment[], int, int, java.util.function.BiFunction)
divisions
- network
- java.lang.NullPointerException
- if network is null or a division is nullAddressValueException
public IPAddressNetwork<?,?,?,?,?> getNetwork()
getNetwork
in interface IPAddressStringDivisionSeries
public IPAddressDivision getDivision(int index)
getDivision
in interface AddressDivisionSeries
getDivision
in interface AddressStringDivisionSeries
getDivision
in interface IPAddressStringDivisionSeries
getDivision
in class AddressDivisionGrouping
public int isMore(AddressDivisionSeries other)
AddressDivisionSeries
isMore
in interface AddressDivisionSeries
isMore
in class AddressDivisionGrouping
public boolean isPrefixed()
AddressDivisionSeries
isPrefixed
in interface AddressDivisionSeries
isPrefixed
in interface IPAddressStringDivisionSeries
isPrefixed
in class AddressDivisionGrouping
public java.lang.Integer getPrefixLength()
AddressDivisionSeries
Typically this is the largest number of bits in the upper-most portion of the section for which the remaining bits assume all possible values.
For IP addresses, this must be explicitly defined when the address is created. For example, 1.2.0.0/16 has a prefix length of 16, while 1.2.*.* has no prefix length, even though they both represent the same set of addresses and are considered equal. Prefixes can be considered variable for any given IP addresses and can depend on the routing table.
The methods AddressDivisionSeries.getMinPrefixLengthForBlock()
and AddressDivisionSeries.getPrefixLengthForSingleBlock()
can help you to obtain or define a prefix length if one does not exist already.
1.2.0.0/16 and 1.2.*.* both the same equivalent and minimum prefix length of 16.
For MAC addresses, the prefix is initially defined by the range, so 1:2:3:*:*:* has a prefix length of 24 by definition. Addresses derived from the original may retain the original prefix length regardless of their range.
getPrefixLength
in interface AddressDivisionSeries
getPrefixLength
in interface IPAddressStringDivisionSeries
getPrefixLength
in class AddressDivisionGrouping
public java.lang.Integer getNetworkPrefixLength()
public boolean isPrefixBlock()
AddressNetwork.getPrefixConfiguration()
is set to consider all prefixes as subnets, this returns true for any grouping with prefix length.isPrefixBlock
in interface AddressDivisionSeries
isPrefixBlock
in interface IPAddressStringDivisionSeries
isPrefixBlock
in class AddressDivisionGrouping
public boolean containsPrefixBlock(int prefixLength)
AddressDivisionGrouping
containsPrefixBlock
in interface AddressDivisionSeries
containsPrefixBlock
in class AddressDivisionGrouping
public boolean containsSinglePrefixBlock(int prefixLength)
AddressDivisionGrouping
containsSinglePrefixBlock
in interface AddressDivisionSeries
containsSinglePrefixBlock
in class AddressDivisionGrouping
public boolean isSinglePrefixBlock()
isSinglePrefixBlock
in interface AddressDivisionSeries
isSinglePrefixBlock
in class AddressDivisionGrouping
public java.lang.Integer getPrefixLengthForSingleBlock()
AddressDivisionGrouping
getPrefixLengthForSingleBlock
in interface AddressDivisionSeries
getPrefixLengthForSingleBlock
in class AddressDivisionGrouping
public boolean includesZeroHost()
public boolean equals(java.lang.Object o)
equals
in class AddressDivisionGrouping
public IPAddressDivisionGrouping.RangeList getZeroSegments()
public IPAddressDivisionGrouping.RangeList getZeroRangeSegments()