Class IPv4AddressSeqRange
- All Implemented Interfaces:
AddressComponentRange, AddressItem, AddressItemRange, IPAddressRange, Serializable, Comparable<AddressItem>, Iterable<IPv4Address>
IPAddressSeqRange for more details.- Author:
- sfoley
- See Also:
-
Field Summary
Fields inherited from class IPAddressSeqRange
DEFAULT_RANGE_SEPARATOR -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the minimal-size prefix block that covers all the addresses in this range.longEquivalent toIPAddressSeqRange.getCount()but returns a longlonggetIPv4PrefixCount(int prefixLength) Equivalent togetPrefixCount(int)but returns a longUseful for using an instance in a "for-each loop", as infor(addr : address.getIterable()) { ...getLower()Returns the lowest address in the sequential range, the one with the lowest numeric valueintReturns the smallest prefix length possible such that this item includes the block of all values for that prefix length.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.Returns a prefix length for which the range of this item matches the block of all values for that prefix length.getUpper()Returns the highest address in the sequential range, the one with the highest numeric valueintersect(IPAddressSeqRange other) Returns the intersection of this range with the given range, a range which includes those addresses in both this and the given range.iterator()Iterates through the individual addresses of this address or subnet.join(IPAddressSeqRange other) Joins two ranges if they are contiguous ranges.prefixBlockIterator(int prefLength) Iterates through the range of prefix blocks in this range instance using the given prefix length.prefixBlockSpliterator(int prefLength) Partitions and traverses through the individual prefix blocks for the given prefix length.prefixBlockStream(int prefLength) Returns a sequential stream of the prefix blocks for the given prefix length.prefixIterator(int prefixLength) Iterates through the range of prefixes in this range instance using the given prefix length.prefixSpliterator(int prefLength) Partitions and traverses through the individual prefixes for the given prefix length.prefixStream(int prefLength) Returns a sequential stream of the individual prefixes for the given prefix length.Produces an array of prefix blocks that spans the same set of addresses.Produces an array of blocks that are sequential that cover the same set of addresses.Partitions and traverses through the individual addresses.stream()Returns a sequential stream of the individual address components.subtract(IPAddressSeqRange other) Subtracts the given range from this range, to produce either zero, one, or two address ranges that contain the addresses in this range and not in the given range.toIPv4String(Function<IPv4Address, String> lowerStringer, String separator, Function<IPv4Address, String> upperStringer) Converts to a sequential range from the lowest and highest addresses in this range, returns "this" if one alreadyMethods inherited from class IPAddressSeqRange
contains, contains, containsPrefixBlock, containsSinglePrefixBlock, enumerate, equals, extend, getBitCount, getBytes, getBytes, getBytes, getCount, getUpperBytes, getUpperBytes, getUpperBytes, getUpperValue, getValue, hashCode, includesMax, includesZero, isMax, isMore, isMultiple, isSequential, isZero, join, overlaps, overlaps, toCanonicalString, toCanonicalString, toNormalizedString, toNormalizedString, toString, toStringMethods inherited from interface AddressItem
compareTo, getByteCount, isFullRange
-
Constructor Details
-
IPv4AddressSeqRange
-
-
Method Details
-
getLower
Description copied from class:IPAddressSeqRangeReturns the lowest address in the sequential range, the one with the lowest numeric value- Specified by:
getLowerin interfaceAddressComponentRange- Specified by:
getLowerin interfaceIPAddressRange- Overrides:
getLowerin classIPAddressSeqRange- Returns:
-
getUpper
Description copied from class:IPAddressSeqRangeReturns the highest address in the sequential range, the one with the highest numeric value- Specified by:
getUpperin interfaceAddressComponentRange- Specified by:
getUpperin interfaceIPAddressRange- Overrides:
getUpperin classIPAddressSeqRange- Returns:
-
getIPv4Count
-
getIPv4PrefixCount
public long getIPv4PrefixCount(int prefixLength) Equivalent togetPrefixCount(int)but returns a long- Returns:
-
getPrefixCount
Description copied from interface:AddressItemThe count of the number of distinct values within the prefix part of the address item, the bits that appear within the prefix length.- Specified by:
getPrefixCountin interfaceAddressItem- Parameters:
prefixLength-- Returns:
-
getIterable
Description copied from interface:IPAddressRangeUseful for using an instance in a "for-each loop", as infor(addr : address.getIterable()) { ... }Otherwise just call
IPAddressRange.iterator()directly.- Specified by:
getIterablein interfaceAddressComponentRange- Specified by:
getIterablein interfaceIPAddressRange- Specified by:
getIterablein classIPAddressSeqRange- Returns:
-
iterator
Description copied from interface:IPAddressRangeIterates through the individual addresses of this address or subnet.Call
AddressItem.isMultiple()to determine if this instance represents multiple, orAddressItem.getCount()for the count.- Specified by:
iteratorin interfaceAddressComponentRange- Specified by:
iteratorin interfaceIPAddressRange- Specified by:
iteratorin interfaceIterable<IPv4Address>- Specified by:
iteratorin classIPAddressSeqRange- Returns:
-
spliterator
Description copied from interface:IPAddressRangePartitions and traverses through the individual addresses.- Specified by:
spliteratorin interfaceAddressComponentRange- Specified by:
spliteratorin interfaceIPAddressRange- Specified by:
spliteratorin interfaceIterable<IPv4Address>- Specified by:
spliteratorin classIPAddressSeqRange- Returns:
-
stream
Description copied from interface:AddressComponentRangeReturns a sequential stream of the individual address components. For a parallel stream, callBaseStream.parallel()on the returned stream.- Specified by:
streamin interfaceAddressComponentRange- Specified by:
streamin classIPAddressSeqRange- Returns:
-
prefixBlockIterator
Description copied from class:IPAddressSeqRangeIterates through the range of prefix blocks in this range instance using the given prefix length.- Specified by:
prefixBlockIteratorin interfaceIPAddressRange- Specified by:
prefixBlockIteratorin classIPAddressSeqRange- Parameters:
prefLength-- Returns:
-
prefixBlockSpliterator
public AddressComponentRangeSpliterator<IPv4AddressSeqRange, IPv4Address> prefixBlockSpliterator(int prefLength) Description copied from interface:IPAddressRangePartitions and traverses through the individual prefix blocks for the given prefix length.- Specified by:
prefixBlockSpliteratorin interfaceIPAddressRange- Specified by:
prefixBlockSpliteratorin classIPAddressSeqRange- Returns:
-
prefixBlockStream
Description copied from interface:IPAddressRangeReturns a sequential stream of the prefix blocks for the given prefix length. For a parallel stream, callBaseStream.parallel()on the returned stream.- Specified by:
prefixBlockStreamin interfaceIPAddressRange- Specified by:
prefixBlockStreamin classIPAddressSeqRange- Returns:
-
prefixIterator
Description copied from class:IPAddressSeqRangeIterates through the range of prefixes in this range instance using the given prefix length.Since a range between two arbitrary addresses cannot always be represented with a single IPAddress instance, the returned iterator iterates through
IPAddressSeqRangeinstances.For instance, if iterating from 1.2.3.4 to 1.2.4.5 with prefix 8, the range shares the same prefix 1, but the range cannot be represented by the address 1.2.3-4.4-5 which does not include 1.2.3.255 or 1.2.4.0 both of which are in the original range. Nor can the range be represented by 1.2.3-4.0-255 which includes 1.2.4.6 and 1.2.3.3, both of which were not in the original range. An IPAddressSeqRange is thus required to represent that prefixed range.
- Specified by:
prefixIteratorin interfaceIPAddressRange- Overrides:
prefixIteratorin classIPAddressSeqRange- Parameters:
prefixLength-- Returns:
-
prefixStream
Description copied from interface:IPAddressRangeReturns a sequential stream of the individual prefixes for the given prefix length. For a parallel stream, callBaseStream.parallel()on the returned stream.- Specified by:
prefixStreamin interfaceIPAddressRange- Specified by:
prefixStreamin classIPAddressSeqRange- Returns:
-
prefixSpliterator
Description copied from interface:IPAddressRangePartitions and traverses through the individual prefixes for the given prefix length.- Specified by:
prefixSpliteratorin interfaceIPAddressRange- Specified by:
prefixSpliteratorin classIPAddressSeqRange- Returns:
-
coverWithPrefixBlock
Description copied from class:IPAddressSeqRangeReturns the minimal-size prefix block that covers all the addresses in this range. The resulting block will have a larger count than this, unless this range already directly corresponds to a prefix block.- Specified by:
coverWithPrefixBlockin interfaceIPAddressRange- Specified by:
coverWithPrefixBlockin classIPAddressSeqRange
-
spanWithPrefixBlocks
Description copied from interface:IPAddressRangeProduces an array of prefix blocks that spans the same set of addresses.- Specified by:
spanWithPrefixBlocksin interfaceIPAddressRange- Specified by:
spanWithPrefixBlocksin classIPAddressSeqRange
-
spanWithSequentialBlocks
Description copied from interface:IPAddressRangeProduces an array of blocks that are sequential that cover the same set of addresses. This array can be shorter than that produced byIPAddressRange.spanWithPrefixBlocks()and is never longer.- Specified by:
spanWithSequentialBlocksin interfaceIPAddressRange- Specified by:
spanWithSequentialBlocksin classIPAddressSeqRange
-
getMinPrefixLengthForBlock
public int getMinPrefixLengthForBlock()Description copied from interface:AddressItemReturns the smallest prefix length possible such that this item includes the block of all values for that prefix length.If the entire range can be dictated this way, then this method returns the same value as
AddressItem.getPrefixLengthForSingleBlock(). Otherwise, this method will return the minimal possible prefix that can be paired with this address, whileAddressItem.getPrefixLengthForSingleBlock()will return null.In cases where the final bit is constant so there is no such block, this returns the bit count.
- Specified by:
getMinPrefixLengthForBlockin interfaceAddressItem- Returns:
- the prefix length
-
getPrefixLengthForSingleBlock
Description copied from interface:AddressItemReturns a prefix length for which the range of this item matches the block of all values for that prefix length.If the range can be dictated this way, then this method returns the same value as
AddressItem.getMinPrefixLengthForBlock().If no such prefix length exists, returns null.
If this item represents a single value, this returns the bit count.
- Specified by:
getPrefixLengthForSingleBlockin interfaceAddressItem- Returns:
- the prefix length or null
-
toIPv4String
public String toIPv4String(Function<IPv4Address, String> lowerStringer, String separator, Function<IPv4Address, String> upperStringer) -
intersect
Description copied from class:IPAddressSeqRangeReturns the intersection of this range with the given range, a range which includes those addresses in both this and the given range.- Overrides:
intersectin classIPAddressSeqRange- Parameters:
other-- Returns:
-
join
Description copied from class:IPAddressSeqRangeJoins two ranges if they are contiguous ranges. If this range overlaps the given range, or if the highest value of the lower range is one below the lowest value of the higher range, then the two are joined into a new larger range that is returned.Otherwise, null is returned.
- Overrides:
joinin classIPAddressSeqRange- Parameters:
other-- Returns:
-
subtract
Description copied from class:IPAddressSeqRangeSubtracts the given range from this range, to produce either zero, one, or two address ranges that contain the addresses in this range and not in the given range. If the result has length 2, the two ranges are ordered by ascending lowest range value.- Overrides:
subtractin classIPAddressSeqRange- Parameters:
other-- Returns:
-
toSequentialRange
Description copied from interface:IPAddressRangeConverts to a sequential range from the lowest and highest addresses in this range, returns "this" if one alreadyThe result will represent the same set of addresses if and only if
IPAddressRange.isSequential()is true- Specified by:
toSequentialRangein interfaceIPAddressRange
-