public class IPv4AddressSeqRange extends IPAddressSeqRange implements Iterable<IPv4Address>
IPAddressSeqRange
for more details.DEFAULT_RANGE_SEPARATOR
Constructor and Description |
---|
IPv4AddressSeqRange(IPv4Address first,
IPv4Address second) |
Modifier and Type | Method and Description |
---|---|
IPv4Address |
coverWithPrefixBlock()
Returns the minimal-size prefix block that covers all the addresses in this range.
|
long |
getIPv4Count()
Equivalent to
IPAddressSeqRange.getCount() but returns a long |
long |
getIPv4PrefixCount(int prefixLength)
Equivalent to
getPrefixCount(int) but returns a long |
Iterable<IPv4Address> |
getIterable()
Useful for using an instance in a "for-each loop", as in
for(addr : address.getIterable()) { ... |
IPv4Address |
getLower()
Returns the lowest address in the sequential range, the one with the lowest numeric value
|
int |
getMinPrefixLengthForBlock()
Returns the smallest prefix length possible such that this item includes the block of all values for that prefix length.
|
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.
|
Integer |
getPrefixLengthForSingleBlock()
Returns a prefix length for which the range of this item matches the block of all values for that prefix length.
|
IPv4Address |
getUpper()
Returns the highest address in the sequential range, the one with the highest numeric value
|
IPv4AddressSeqRange |
intersect(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<IPv4Address> |
iterator()
Iterates through the individual addresses of this address or subnet.
|
IPv4AddressSeqRange |
join(IPAddressSeqRange other)
Joins two ranges if they are contiguous ranges.
|
Iterator<IPv4Address> |
prefixBlockIterator(int prefLength)
Iterates through the range of prefix blocks in this range instance using the given prefix length.
|
AddressComponentRangeSpliterator<IPv4AddressSeqRange,IPv4Address> |
prefixBlockSpliterator(int prefLength)
Partitions and traverses through the individual prefix blocks for the given prefix length.
|
Stream<IPv4Address> |
prefixBlockStream(int prefLength)
Returns a sequential stream of the prefix blocks for the given prefix length.
|
Iterator<IPv4AddressSeqRange> |
prefixIterator(int prefixLength)
Iterates through the range of prefixes in this range instance using the given prefix length.
|
AddressComponentSpliterator<IPv4AddressSeqRange> |
prefixSpliterator(int prefLength)
Partitions and traverses through the individual prefixes for the given prefix length.
|
Stream<IPv4AddressSeqRange> |
prefixStream(int prefLength)
Returns a sequential stream of the individual prefixes for the given prefix length.
|
IPv4Address[] |
spanWithPrefixBlocks()
Produces an array of prefix blocks that spans the same set of addresses.
|
IPv4Address[] |
spanWithSequentialBlocks()
Produces an array of blocks that are sequential that cover the same set of addresses.
|
AddressComponentRangeSpliterator<IPv4AddressSeqRange,IPv4Address> |
spliterator()
Partitions and traverses through the individual addresses.
|
Stream<IPv4Address> |
stream()
Returns a sequential stream of the individual address components.
|
IPv4AddressSeqRange[] |
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.
|
String |
toIPv4String(Function<IPv4Address,String> lowerStringer,
String separator,
Function<IPv4Address,String> upperStringer) |
IPv4AddressSeqRange |
toSequentialRange()
Converts to a sequential range from the lowest and highest addresses in this range, returns "this" if one already
|
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, toString
stream, stream
compareTo, getBitsForCount, getBlockSize, getByteCount, isFullRange
public IPv4AddressSeqRange(IPv4Address first, IPv4Address second)
public IPv4Address getLower()
IPAddressSeqRange
getLower
in interface AddressComponentRange
getLower
in interface IPAddressRange
getLower
in class IPAddressSeqRange
public IPv4Address getUpper()
IPAddressSeqRange
getUpper
in interface AddressComponentRange
getUpper
in interface IPAddressRange
getUpper
in class IPAddressSeqRange
public long getIPv4Count()
IPAddressSeqRange.getCount()
but returns a longpublic long getIPv4PrefixCount(int prefixLength)
getPrefixCount(int)
but returns a longpublic BigInteger getPrefixCount(int prefixLength)
AddressItem
getPrefixCount
in interface AddressItem
public Iterable<IPv4Address> getIterable()
IPAddressRange
for(addr : address.getIterable()) { ... }
Otherwise just call IPAddressRange.iterator()
directly.
getIterable
in interface AddressComponentRange
getIterable
in interface IPAddressRange
getIterable
in class IPAddressSeqRange
public Iterator<IPv4Address> iterator()
IPAddressRange
Call AddressItem.isMultiple()
to determine if this instance represents multiple, or AddressItem.getCount()
for the count.
iterator
in interface AddressComponentRange
iterator
in interface IPAddressRange
iterator
in interface Iterable<IPv4Address>
iterator
in class IPAddressSeqRange
public AddressComponentRangeSpliterator<IPv4AddressSeqRange,IPv4Address> spliterator()
IPAddressRange
spliterator
in interface AddressComponentRange
spliterator
in interface IPAddressRange
spliterator
in interface Iterable<IPv4Address>
spliterator
in class IPAddressSeqRange
public Stream<IPv4Address> stream()
AddressComponentRange
BaseStream.parallel()
on the returned stream.stream
in interface AddressComponentRange
stream
in class IPAddressSeqRange
public Iterator<IPv4Address> prefixBlockIterator(int prefLength)
IPAddressSeqRange
prefixBlockIterator
in interface IPAddressRange
prefixBlockIterator
in class IPAddressSeqRange
public AddressComponentRangeSpliterator<IPv4AddressSeqRange,IPv4Address> prefixBlockSpliterator(int prefLength)
IPAddressRange
prefixBlockSpliterator
in interface IPAddressRange
prefixBlockSpliterator
in class IPAddressSeqRange
public Stream<IPv4Address> prefixBlockStream(int prefLength)
IPAddressRange
BaseStream.parallel()
on the returned stream.prefixBlockStream
in interface IPAddressRange
prefixBlockStream
in class IPAddressSeqRange
public Iterator<IPv4AddressSeqRange> prefixIterator(int prefixLength)
IPAddressSeqRange
Since a range between two arbitrary addresses cannot always be represented with a single IPAddress instance,
the returned iterator iterates through IPAddressSeqRange
instances.
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.
prefixIterator
in interface IPAddressRange
prefixIterator
in class IPAddressSeqRange
public Stream<IPv4AddressSeqRange> prefixStream(int prefLength)
IPAddressRange
BaseStream.parallel()
on the returned stream.prefixStream
in interface IPAddressRange
prefixStream
in class IPAddressSeqRange
public AddressComponentSpliterator<IPv4AddressSeqRange> prefixSpliterator(int prefLength)
IPAddressRange
prefixSpliterator
in interface IPAddressRange
prefixSpliterator
in class IPAddressSeqRange
public IPv4Address coverWithPrefixBlock()
IPAddressSeqRange
coverWithPrefixBlock
in interface IPAddressRange
coverWithPrefixBlock
in class IPAddressSeqRange
public IPv4Address[] spanWithPrefixBlocks()
IPAddressRange
spanWithPrefixBlocks
in interface IPAddressRange
spanWithPrefixBlocks
in class IPAddressSeqRange
public IPv4Address[] spanWithSequentialBlocks()
IPAddressRange
IPAddressRange.spanWithPrefixBlocks()
and is never longer.spanWithSequentialBlocks
in interface IPAddressRange
spanWithSequentialBlocks
in class IPAddressSeqRange
public int getMinPrefixLengthForBlock()
AddressItem
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, while AddressItem.getPrefixLengthForSingleBlock()
will return null.
In cases where the final bit is constant so there is no such block, this returns the bit count.
getMinPrefixLengthForBlock
in interface AddressItem
public Integer getPrefixLengthForSingleBlock()
AddressItem
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.
getPrefixLengthForSingleBlock
in interface AddressItem
public String toIPv4String(Function<IPv4Address,String> lowerStringer, String separator, Function<IPv4Address,String> upperStringer)
public IPv4AddressSeqRange intersect(IPAddressSeqRange other)
IPAddressSeqRange
intersect
in class IPAddressSeqRange
public IPv4AddressSeqRange join(IPAddressSeqRange other)
IPAddressSeqRange
Otherwise, null is returned.
join
in class IPAddressSeqRange
public IPv4AddressSeqRange[] subtract(IPAddressSeqRange other)
IPAddressSeqRange
subtract
in class IPAddressSeqRange
public IPv4AddressSeqRange toSequentialRange()
IPAddressRange
The result will represent the same set of addresses if and only if IPAddressRange.isSequential()
is true
toSequentialRange
in interface IPAddressRange