public interface IPAddressSegmentSeries extends IPAddressDivisionSeries, AddressSegmentSeries
Provides methods relevant to IP addresses and IP address sections in addition to the more general methods pertaining to address and address sections in AddressSegmentSeries.
Modifier and Type | Method and Description |
---|---|
IPAddressSegmentSeries |
adjustPrefixBySegment(boolean nextSegment)
Increases or decreases prefix length to the next segment boundary.
|
IPAddressSegmentSeries |
adjustPrefixBySegment(boolean nextSegment,
boolean zeroed)
Increases or decreases prefix length to the next segment boundary.
|
IPAddressSegmentSeries |
adjustPrefixLength(int adjustment)
Increases or decreases prefix length by the given increment.
|
IPAddressSegmentSeries |
adjustPrefixLength(int adjustment,
boolean zeroed)
Increases or decreases prefix length by the given increment.
|
IPAddressSegmentSeries |
applyPrefixLength(int networkPrefixLength)
Deprecated.
|
IPAddressSegmentSeries |
assignMinPrefixForBlock()
Returns the equivalent address series with the smallest CIDR prefix possible (largest network),
such that the range of values of this address includes the subnet prefix block for that prefix.
|
IPAddressSegmentSeries |
assignPrefixForSingleBlock()
Returns the equivalent CIDR address series with a prefix length for which the subnet block for that prefix matches the range of values in this series.
|
Iterator<? extends IPAddressSegmentSeries> |
blockIterator(int segmentCount)
Iterates through series that can be obtained by iterating through all the upper segments up to the given segment count.
|
AddressComponentSpliterator<? extends IPAddressSegmentSeries> |
blockSpliterator(int segmentCount)
Partitions and traverses through the individual sequential blocks created from each of the individual values up to the given segment count.
|
Stream<? extends IPAddressSegmentSeries> |
blockStream(int segmentCount)
Returns a sequential stream of the individual blocks created from each of the individual values up to the given segment count.
|
IPAddressSegmentSeries |
coverWithPrefixBlock()
Returns the minimal-size prefix block that covers all the values in this series.
|
IPAddressSegmentSeries |
getHostMask()
Returns the host mask associated with the CIDR network prefix length of this series.
|
IPAddressSection |
getHostSection()
Returns the host section of the series.
|
IPAddressSection |
getHostSection(int networkPrefixLength)
Returns the host section of the address as indicated by the network prefix length provided.
|
IPAddress.IPVersion |
getIPVersion()
Returns the version of this segment series
|
Iterable<? extends IPAddressSegmentSeries> |
getIterable()
Useful for using an instance in a "for-each loop".
|
IPAddressSegmentSeries |
getLower()
If this represents a series with ranging values, returns a series representing the lower values of the range.
|
IPAddressSegmentSeries |
getLowerNonZeroHost()
Similar to
getLower() , but will not return a series that has a prefix length and whose host value is zero. |
IPAddressNetwork<?,?,?,?,?> |
getNetwork()
Returns the network object for components of the same version (eg IPv4, IPv6 and MAC each have their own network object)
|
IPAddressSegmentSeries |
getNetworkMask()
Returns the network mask associated with the CIDR network prefix length of this series.
|
IPAddressSection |
getNetworkSection()
Returns the network section of the series if the series has a CIDR network prefix length,
otherwise it returns the entire series as a prefixed series with prefix matching the address bit length.
|
IPAddressSection |
getNetworkSection(int networkPrefixLength)
Returns the network section of the series.
|
IPAddressSection |
getNetworkSection(int networkPrefixLength,
boolean withPrefixLength)
Returns the network section of the series.
|
BigInteger |
getNonZeroHostCount()
Gets the count of single value series that this series may represent, but excluding series whose host is zero.
|
static Comparator<? super IPAddressSegmentSeries> |
getPrefixLenComparator()
Returns a comparator to sort series by prefix length.
|
IPAddressSection |
getSection()
Gets the subsection from the series that comprises all segments
|
IPAddressSection |
getSection(int index)
Gets the subsection from the series starting from the given index
The first segment is at index 0.
|
IPAddressSection |
getSection(int index,
int endIndex)
Gets the subsection from the series starting from the given index and ending just before the give endIndex
The first segment is at index 0.
|
IPAddressSegment |
getSegment(int index)
Returns the segment from this series at the given index.
|
IPAddressSegment[] |
getSegments()
Returns the segments of this series of segments as an array.
|
BigInteger |
getSequentialBlockCount()
provides the count of elements from the
sequentialBlockIterator() , the minimal number of sequential sub-series that comprise this series |
IPAddressSegmentSeries |
getUpper()
If this represents a series with ranging values, returns a series representing the upper values of the range.
|
boolean |
includesMaxHost()
Returns whether the series has a host of all ones.
|
boolean |
includesMaxHost(int prefixLength)
Returns whether all bits past the given prefix length are all ones.
|
boolean |
includesZeroHost()
Returns whether the series has a host of zero.
|
boolean |
includesZeroHost(int prefixLength)
Returns whether all bits past the given prefix length are zero.
|
IPAddressSegmentSeries |
increment(long increment)
Returns the series from the subnet that is the given increment upwards into the subnet range, with the increment of 0
returning the first address in the range.
|
IPAddressSegmentSeries |
incrementBoundary(long increment)
If the given increment is positive, adds the value to the upper series (
AddressSegmentSeries.getUpper() ) in the subnet range to produce a new series. |
Iterator<? extends IPAddressSegmentSeries> |
iterator()
Iterates through the individual address components.
|
Iterator<? extends IPAddressSegmentSeries> |
nonZeroHostIterator()
Similar to the iterator, but series with a host of zero are skipped.
|
Iterator<? extends IPAddressSegmentSeries> |
prefixBlockIterator()
Iterates through the individual prefix blocks.
|
AddressComponentSpliterator<? extends IPAddressSegmentSeries> |
prefixBlockSpliterator()
Partitions and traverses through the individual prefix blocks for the prefix length of this series.
|
Stream<? extends IPAddressSegmentSeries> |
prefixBlockStream()
Returns a sequential stream of the individual prefix blocks for the prefix length of this series.
|
Iterator<? extends IPAddressSegmentSeries> |
prefixIterator()
Iterates through the individual prefixes.
|
AddressComponentSpliterator<? extends IPAddressSegmentSeries> |
prefixSpliterator()
Partitions and traverses through the individual prefixes for the prefix length of this series.
|
Stream<? extends IPAddressSegmentSeries> |
prefixStream()
Returns a sequential stream of the individual prefixes for the prefix length of this series.
|
IPAddressSegmentSeries |
removePrefixLength()
Deprecated.
|
IPAddressSegmentSeries |
removePrefixLength(boolean zeroed)
Deprecated.
|
IPAddressSegmentSeries |
reverseBits(boolean perByte)
Returns a new series which has the bits reversed.
|
IPAddressSegmentSeries |
reverseBytes()
Returns a new segment series with the bytes reversed.
|
IPAddressSegmentSeries |
reverseBytesPerSegment()
Returns a new segment series with the bytes reversed within each segment.
|
IPAddressSegmentSeries |
reverseSegments()
Returns a new segment series with the segments reversed.
|
Iterator<? extends IPAddressSegment[]> |
segmentsIterator()
Iterates through the individual segments.
|
Iterator<? extends IPAddressSegment[]> |
segmentsNonZeroHostIterator()
Similar to the segments iterator, but series with a host of zero are skipped.
|
AddressComponentRangeSpliterator<? extends IPAddressSegmentSeries,? extends IPAddressSegment[]> |
segmentsSpliterator()
Partitions and traverses through the individual segment arrays.
|
Stream<? extends IPAddressSegment[]> |
segmentsStream()
Returns a sequential stream of the individual segment arrays.
|
Iterator<? extends IPAddressSegmentSeries> |
sequentialBlockIterator()
Iterates through the sequential series that make up this series.
|
AddressComponentSpliterator<? extends IPAddressSegmentSeries> |
sequentialBlockSpliterator()
Partitions and traverses through the individual sequential blocks.
|
Stream<? extends IPAddressSegmentSeries> |
sequentialBlockStream()
Returns a sequential stream of the individual sequential blocks.
|
IPAddressSegmentSeries |
setPrefixLength(int prefixLength)
Sets the prefix length.
|
IPAddressSegmentSeries |
setPrefixLength(int prefixLength,
boolean zeroed)
Sets the prefix length.
|
IPAddressSegmentSeries[] |
spanWithPrefixBlocks()
Produces an array of prefix blocks that spans the same set of values.
|
IPAddressSegmentSeries[] |
spanWithSequentialBlocks()
Produces an array of blocks that are sequential that cover the same set of values.
|
AddressComponentSpliterator<? extends IPAddressSegmentSeries> |
spliterator()
Partitions and traverses through the individual address components.
|
Stream<? extends IPAddressSegmentSeries> |
stream()
Returns a sequential stream of the individual address components.
|
String |
toBinaryString()
Writes this IP address segment series as a single binary value with always the exact same number of characters
If this section represents a range of values outside of the network prefix length, then this is printed as a range of two binary values.
|
String |
toCanonicalWildcardString()
This produces a string similar to the canonical string and avoids the CIDR prefix.
|
String |
toCompressedWildcardString()
This is similar to toNormalizedWildcardString, avoiding the CIDR prefix, but with compression as well.
|
String |
toFullString()
This produces a string with no compressed segments and all segments of full length,
which is 4 characters for IPv6 segments and 3 characters for IPv4 segments.
|
IPAddressSegmentSeries |
toMaxHost()
Returns the segment series with a host of all ones.
|
IPAddressSegmentSeries |
toMaxHost(int prefixLength)
Produces the series with host values of all one bits for the given prefix length.
|
String |
toNormalizedString(IPAddressSection.IPStringOptions stringOptions)
Creates a customized string from this series.
|
String |
toNormalizedWildcardString()
This produces a string similar to the normalized string and avoids the CIDR prefix.
|
String |
toOctalString(boolean with0Prefix)
Writes this IP address segment series as a single octal value with always the exact same number of characters, with or without a preceding 0 prefix.
|
IPAddressSegmentSeries |
toPrefixBlock()
If this series has a prefix length, returns the subnet block for that prefix.
|
IPAddressSegmentSeries |
toPrefixBlock(int networkPrefixLength)
Returns the segment series of the same length that spans all hosts.
|
String |
toPrefixLengthString()
Returns a string with a CIDR prefix length if this section has a network prefix length.
|
String |
toReverseDNSLookupString()
Generates the reverse DNS lookup string
For 8.255.4.4 it is 4.4.255.8.in-addr.arpa
For 2001:db8::567:89ab it is b.a.9.8.7.6.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa
|
String |
toSegmentedBinaryString()
Writes this IP address segment series as a segments of binary values preceded by the "0b" prefix.
|
String |
toSQLWildcardString()
This is the same as the string from toNormalizedWildcardString except that
it uses
Address.SEGMENT_SQL_WILDCARD instead of Address.SEGMENT_WILDCARD and also uses Address.SEGMENT_SQL_SINGLE_WILDCARD |
IPAddressPartStringCollection |
toStringCollection(IPAddressSection.IPStringBuilderOptions options) |
String |
toSubnetString()
Produces a consistent subnet string.
|
IPAddressSegmentSeries |
toZeroHost()
Returns the segment series with a host of zero, the host being the bits following the prefix length.
|
IPAddressSegmentSeries |
toZeroHost(int prefixLength)
Produces the series with host values of 0 for the given prefix length.
|
IPAddressSegmentSeries |
toZeroNetwork()
Returns the segment series with a network of zero, the network being the bits within the prefix length.
|
IPAddressSegmentSeries |
withoutPrefixLength()
Provides the same address with no prefix.
|
getDivision, getNetworkPrefixLength
getPrefixLength, isPrefixBlock, isPrefixed
getBitsPerSegment, getBytesPerSegment, getMaxSegmentValue, getSegmentCount, getSegments, getSegments, getSegmentStrings, isOneBit, testBit, toCanonicalString, toCompressedString
getBitCount, getBlockCount, getCount, getDivisionStrings, getPrefixCount, getPrefixCount, getPrefixLength, getSequentialBlockIndex, isMore, isPrefixBlock, isPrefixed, isSequential, isSinglePrefixBlock
getDivisionCount
toHexString, toNormalizedString
stream, stream
compareTo, containsPrefixBlock, containsSinglePrefixBlock, getBitsForCount, getBlockSize, getByteCount, getBytes, getBytes, getBytes, getMinPrefixLengthForBlock, getPrefixLengthForSingleBlock, getUpperBytes, getUpperBytes, getUpperBytes, getUpperValue, getValue, includesMax, includesZero, isFullRange, isMax, isMultiple, isZero
static Comparator<? super IPAddressSegmentSeries> getPrefixLenComparator()
IPAddress.IPVersion getIPVersion()
IPAddressSegmentSeries assignMinPrefixForBlock()
toPrefixBlock()
,
assignPrefixForSingleBlock()
IPAddressSegmentSeries assignPrefixForSingleBlock()
If no such prefix length exists, returns null.
If this address represents just a single address, "this" is returned.
The methods assignMinPrefixForBlock()
, assignPrefixForSingleBlock()
can be compared as follows.
assignMinPrefixForBlock()
finds the smallest prefix length possible for this subnet and returns that subnet.
assignPrefixForSingleBlock()
finds the smallest prefix length possible for this subnet that results in just a single prefix and returns that subnet.
For example, given the address 1-2.2.3.* /16
assignMinPrefixForBlock()
returns 1-2.2.3.* /24 if the prefix configuration is the default or is not ALL_PREFIXES_ARE_SUBNETS, otherwise 1-2.2.*.* /16, in order to return the subnet with the smallest prefix length
assignPrefixForSingleBlock()
returns null because any prefix length will end up with at least two prefixes due to the first segment spanning two values: 1-2.
For another example, for the address 1.2.*.* /16 or the address 1.2.*.* both methods return 1.2.*.* /16.
toPrefixBlock()
,
assignMinPrefixForBlock()
IPAddressSegmentSeries coverWithPrefixBlock()
IPAddressSegmentSeries[] spanWithPrefixBlocks()
IPAddressSegmentSeries[] spanWithSequentialBlocks()
spanWithPrefixBlocks()
and is never longer.IPAddressSegmentSeries toPrefixBlock()
toPrefixBlock
in interface AddressSegmentSeries
IPAddressSegmentSeries toPrefixBlock(int networkPrefixLength) throws PrefixLenException
networkPrefixLength
- PrefixLenException
IPAddressSegmentSeries getHostMask()
IPAddressSegmentSeries getNetworkMask()
IPAddressSection getHostSection()
IPAddressSection getHostSection(int networkPrefixLength)
networkPrefixLength
- IPAddressSection getNetworkSection()
IPAddressSection getNetworkSection(int networkPrefixLength)
networkPrefixLength
- IPAddressSection getNetworkSection(int networkPrefixLength, boolean withPrefixLength)
networkPrefixLength
- withPrefixLength
- whether the resulting section will have networkPrefixLength as the associated prefix length or notString toFullString()
String toPrefixLengthString()
String toSubnetString()
String toNormalizedWildcardString()
String toCanonicalWildcardString()
String toCompressedWildcardString()
String toSQLWildcardString()
Address.SEGMENT_SQL_WILDCARD
instead of Address.SEGMENT_WILDCARD
and also uses Address.SEGMENT_SQL_SINGLE_WILDCARD
String toReverseDNSLookupString()
IncompatibleAddressException
- if this address is a subnetString toBinaryString() throws IncompatibleAddressException
IncompatibleAddressException
String toSegmentedBinaryString()
String toOctalString(boolean with0Prefix) throws IncompatibleAddressException
IncompatibleAddressException
IPAddressPartStringCollection toStringCollection(IPAddressSection.IPStringBuilderOptions options)
String toNormalizedString(IPAddressSection.IPStringOptions stringOptions)
stringOptions
- IPAddressNetwork<?,?,?,?,?> getNetwork()
AddressComponent
getNetwork
in interface AddressComponent
getNetwork
in interface IPAddressStringDivisionSeries
IPAddressSection getSection()
AddressSegmentSeries
getSection
in interface AddressSegmentSeries
IPAddressSection getSection(int index)
AddressSegmentSeries
getSection
in interface AddressSegmentSeries
IPAddressSection getSection(int index, int endIndex)
AddressSegmentSeries
getSection
in interface AddressSegmentSeries
IPAddressSegment getSegment(int index)
AddressSegmentSeries
AddressDivisionSeries.getDivision(int)
, the difference being that all segments in a given series are the same bit count, while divisions can have variable length.getSegment
in interface AddressSegmentSeries
IPAddressSegment[] getSegments()
AddressSegmentSeries
AddressSegmentSeries.getSegment(int)
and AddressSegmentSeries.getSegmentCount()
instead when feasible.getSegments
in interface AddressSegmentSeries
BigInteger getNonZeroHostCount()
If this address series has no range of values, then there is only one such address, or none if it has a zero host.
If this has no CIDR network prefix length, then it is equivalent to AddressDivisionSeries.getCount()
.
IPAddressSegmentSeries getLowerNonZeroHost()
getLower()
, but will not return a series that has a prefix length and whose host value is zero.
If this series has no prefix length, returns the same series as getLower()
.IPAddressSegmentSeries getLower()
AddressSegmentSeries
getLower
in interface AddressComponentRange
getLower
in interface AddressSegmentSeries
IPAddressSegmentSeries getUpper()
AddressSegmentSeries
getUpper
in interface AddressComponentRange
getUpper
in interface AddressSegmentSeries
Iterable<? extends IPAddressSegmentSeries> getIterable()
AddressComponentRange
AddressComponentRange.iterator()
directly.getIterable
in interface AddressComponentRange
getIterable
in interface AddressSegmentSeries
Iterator<? extends IPAddressSegmentSeries> iterator()
AddressComponentRange
An address component can represent an individual segment, address, or section, or it can represent multiple, typically a subnet of addresses or a range of segment or section values.
Call AddressItem.isMultiple()
to determine if this instance represents multiple, or AddressItem.getCount()
for the count.
iterator
in interface AddressComponentRange
iterator
in interface AddressSegmentSeries
AddressComponentSpliterator<? extends IPAddressSegmentSeries> spliterator()
AddressComponentRange
spliterator
in interface AddressComponent
spliterator
in interface AddressComponentRange
spliterator
in interface AddressSegmentSeries
Stream<? extends IPAddressSegmentSeries> stream()
AddressComponentRange
BaseStream.parallel()
on the returned stream.stream
in interface AddressComponentRange
stream
in interface AddressSegmentSeries
Iterator<? extends IPAddressSegmentSeries> prefixIterator()
AddressSegmentSeries
If the series has no prefix length, then this is equivalent to AddressSegmentSeries.iterator()
prefixIterator
in interface AddressSegmentSeries
AddressComponentSpliterator<? extends IPAddressSegmentSeries> prefixSpliterator()
AddressSegmentSeries
prefixSpliterator
in interface AddressSegmentSeries
Stream<? extends IPAddressSegmentSeries> prefixStream()
AddressSegmentSeries
BaseStream.parallel()
on the returned stream.prefixStream
in interface AddressSegmentSeries
Iterator<? extends IPAddressSegmentSeries> prefixBlockIterator()
AddressSegmentSeries
If the series has no prefix length, then this is equivalent to AddressSegmentSeries.iterator()
prefixBlockIterator
in interface AddressSegmentSeries
AddressComponentSpliterator<? extends IPAddressSegmentSeries> prefixBlockSpliterator()
AddressSegmentSeries
prefixBlockSpliterator
in interface AddressSegmentSeries
Stream<? extends IPAddressSegmentSeries> prefixBlockStream()
AddressSegmentSeries
BaseStream.parallel()
on the returned stream.prefixBlockStream
in interface AddressSegmentSeries
Iterator<? extends IPAddressSegmentSeries> nonZeroHostIterator()
Iterator<? extends IPAddressSegmentSeries> blockIterator(int segmentCount)
For instance, given the IPv4 subnet 1-2.3-4.5-6.7, given the count argument 2, it will iterate through 1.3.5-6.7, 1.4.5-6.7, 2.3.5-6.7, 2.4.5-6.7
segmentCount
- AddressComponentSpliterator<? extends IPAddressSegmentSeries> blockSpliterator(int segmentCount)
Stream<? extends IPAddressSegmentSeries> blockStream(int segmentCount)
BaseStream.parallel()
on the returned stream.Iterator<? extends IPAddressSegmentSeries> sequentialBlockIterator()
blockIterator(int)
with that segment count.
For instance, given the IPv4 subnet 1-2.3-4.5-6.7-8, it will iterate through 1.3.5.7-8, 1.3.6.7-8, 1.4.5.7-8, 1.4.6.7-8, 2.3.5.7-8, 2.3.6.7-8, 2.4.6.7-8, 2.4.6.7-8.
Use getSequentialBlockCount()
to get the count of iterated elements.
AddressComponentSpliterator<? extends IPAddressSegmentSeries> sequentialBlockSpliterator()
Stream<? extends IPAddressSegmentSeries> sequentialBlockStream()
BaseStream.parallel()
on the returned stream.
Use getSequentialBlockCount()
to get the count of streamed elements.
BigInteger getSequentialBlockCount()
sequentialBlockIterator()
, the minimal number of sequential sub-series that comprise this seriesIterator<? extends IPAddressSegment[]> segmentsIterator()
AddressSegmentSeries
segmentsIterator
in interface AddressSegmentSeries
AddressComponentRangeSpliterator<? extends IPAddressSegmentSeries,? extends IPAddressSegment[]> segmentsSpliterator()
AddressSegmentSeries
segmentsSpliterator
in interface AddressSegmentSeries
Stream<? extends IPAddressSegment[]> segmentsStream()
AddressSegmentSeries
BaseStream.parallel()
on the returned stream.segmentsStream
in interface AddressSegmentSeries
Iterator<? extends IPAddressSegment[]> segmentsNonZeroHostIterator()
IPAddressSegmentSeries increment(long increment)
AddressSegmentSeries
If the subnet has multiple values and the increment exceeds the subnet size, then the amount by which it exceeds the size - 1 is added to the upper series of the range (the final iterator value).
If the increment is negative, it is added to the lower series of the range (the first iterator value).
If the subnet is just a single address values, the series is simply incremented by the given value, positive or negative.
If a subnet has multiple values, a positive increment value is equivalent to the same number of values from the AddressSegmentSeries.iterator()
For instance, a increment of 0 is the first value from the iterator, an increment of 1 is the second value from the iterator, and so on.
A negative increment added to the subnet count is equivalent to the same number of values preceding the upper bound of the iterator.
For instance, an increment of count - 1 is the last value from the iterator, an increment of count - 2 is the second last value, and so on.
An increment of size count gives you the series just above the highest series of the subnet. To get the series just below the lowest series of the subnet, use the increment -1.
increment
in interface AddressSegmentSeries
IPAddressSegmentSeries incrementBoundary(long increment)
AddressSegmentSeries
AddressSegmentSeries.getUpper()
) in the subnet range to produce a new series.
If the given increment is negative, adds the value to the lower series (AddressSegmentSeries.getLower()
) in the subnet range to produce a new series.
If the increment is zero, returns this.
In the case where the series is a single value, this simply returns the address produced by adding the given increment to this address series.
incrementBoundary
in interface AddressSegmentSeries
IPAddressSegmentSeries toZeroHost()
The default behaviour is that the resultant series will have the same prefix length.
The resultant series will not have a prefix length if AddressNetwork.getPrefixConfiguration()
is AddressNetwork.PrefixConfiguration.ALL_PREFIXED_ADDRESSES_ARE_SUBNETS
.
For instance, you can get the network address for a subnet as follows:
String addrStr = "1.2.3.4/16";
IPAddress address = new IPAddressString(addrStr).getAddress();
IPAddress networkAddress = address.toZeroHost(); //1.2.0.0
toZeroNetwork()
IPAddressSegmentSeries toZeroHost(int prefixLength)
If this series has the same prefix length, then the resulting series will too, otherwise the resulting series will have no prefix length.
This is nearly equivalent to doing the mask (bitwise conjunction) of this address series with the network mask for the given prefix length, but without the possibility of IncompatibleAddressException that can occur when applying a mask to a range of values. Instead, in this case, if the resulting series has a range of values, then the resulting series range boundaries will have host values of 0, but not necessarily the intervening values.
For instance, you can get the network address for a subnet of prefix length 16 as follows:
String addrStr = "1.2.3.4";
IPAddress address = new IPAddressString(addrStr).getAddress();
IPAddress networkAddress = address.toZeroHost(16); //1.2.0.0
prefixLength
- IPAddressSegmentSeries toZeroNetwork()
The default behaviour is that the resultant series will have the same prefix length.
The resultant series will not have a prefix length if AddressNetwork.getPrefixConfiguration()
is AddressNetwork.PrefixConfiguration.ALL_PREFIXED_ADDRESSES_ARE_SUBNETS
.
toZeroHost()
boolean includesZeroHost()
boolean includesZeroHost(int prefixLength)
IPAddressSegmentSeries toMaxHost(int prefixLength)
If this series has the same prefix length, then the resulting series will too, otherwise the resulting series will have no prefix length.
This is nearly equivalent to doing the bitwise or (bitwise disjunction) of this address series with the network mask for the given prefix length, but without the possibility of IncompatibleAddressException that can occur when applying a mask to a range of values. Instead, in this case, if the resulting series has a range of values, then the resulting series range boundaries will have host values of all ones, but not necessarily the intervening values.
For instance, you can get the broadcast address for a subnet of prefix length 16 as follows:
String addrStr = "1.2.3.4";
IPAddress address = new IPAddressString(addrStr).getAddress();
IPAddress broadcastAddress = address.toMaxHost(16); //1.2.255.255
prefixLength
- IPAddressSegmentSeries toMaxHost()
The resultant series will have the same prefix length if AddressNetwork.getPrefixConfiguration()
is not AddressNetwork.PrefixConfiguration.ALL_PREFIXED_ADDRESSES_ARE_SUBNETS
,
otherwise it will no longer have a prefix length.
For instance, you can get the broadcast address for a subnet as follows:
String addrStr = "1.2.3.4/16";
IPAddress address = new IPAddressString(addrStr).getAddress();
IPAddress broadcastAddress = address.toMaxHost(); //1.2.255.255
boolean includesMaxHost()
boolean includesMaxHost(int prefixLength)
IPAddressSegmentSeries reverseSegments()
AddressSegmentSeries
IncompatibleAddressException
since all address series can reverse their segments.reverseSegments
in interface AddressSegmentSeries
IPAddressSegmentSeries reverseBits(boolean perByte)
If this has an associated prefix length, then the prefix length is dropped in the reversed series.
If this represents a range of values that cannot be reversed,
because reversing the range results in a set of addresses that cannot be described by a range, then this throws IncompatibleAddressException
.
In such cases you can call iterator()
, getLower()
, getUpper()
or some other method to transform the address
into an address representing a single value before reversing.
reverseBits
in interface AddressComponent
reverseBits
in interface AddressSegmentSeries
perByte
- if true, only the bits in each byte are reversed, if false, then all bits in the address are reversedIncompatibleAddressException
- if this is a subnet that cannot be reversedIPAddressSegmentSeries reverseBytes()
AddressSegmentSeries
reverseBytes
in interface AddressComponent
reverseBytes
in interface AddressSegmentSeries
IPAddressSegmentSeries reverseBytesPerSegment()
AddressSegmentSeries
reverseBytesPerSegment
in interface AddressSegmentSeries
@Deprecated IPAddressSegmentSeries removePrefixLength()
AddressSegmentSeries
If the series already has a prefix length, the bits outside the prefix become zero.
Use AddressSegmentSeries.withoutPrefixLength()
to remove the prefix length without changing the series values.
Equivalent to calling removePrefixLength(true)
removePrefixLength
in interface AddressSegmentSeries
for an alternative which does not change the address series values.
IPAddressSegmentSeries withoutPrefixLength()
AddressSegmentSeries
Use AddressSegmentSeries.removePrefixLength()
as an alternative that deletes the host at the same time by zeroing the host values.
withoutPrefixLength
in interface AddressSegmentSeries
@Deprecated IPAddressSegmentSeries removePrefixLength(boolean zeroed)
AddressSegmentSeries
AddressSegmentSeries.removePrefixLength()
removePrefixLength
in interface AddressSegmentSeries
zeroed
- whether the bits outside the prefix become zeroIPAddressSegmentSeries adjustPrefixBySegment(boolean nextSegment)
AddressSegmentSeries
Follows the same rules as AddressSegmentSeries.adjustPrefixLength(int)
:
When prefix length is increased, the bits moved within the prefix become zero.
When a prefix length is decreased, the bits moved outside the prefix become zero.
To avoid the zeroing behaviour, use AddressSegmentSeries.adjustPrefixBySegment(boolean, boolean)
with second arg false.
adjustPrefixBySegment
in interface AddressSegmentSeries
nextSegment
- whether to move prefix to previous or following segment boundaryIPAddressSegmentSeries adjustPrefixBySegment(boolean nextSegment, boolean zeroed)
AddressSegmentSeries
adjustPrefixBySegment
in interface AddressSegmentSeries
nextSegment
- whether to move prefix to previous or following segment boundaryzeroed
- whether the bits that move from one side of the prefix to the other become zero or retain their original valuesIPAddressSegmentSeries adjustPrefixLength(int adjustment)
AddressSegmentSeries
When prefix length is increased, the bits moved within the prefix become zero.
When the prefix is extended beyond the segment series boundary, it is removed.
When a prefix length is decreased, the bits moved outside the prefix become zero.
To avoid the zeroing behaviour, use AddressSegmentSeries.adjustPrefixLength(int, boolean)
with second arg false.
adjustPrefixLength
in interface AddressSegmentSeries
IPAddressSegmentSeries adjustPrefixLength(int adjustment, boolean zeroed)
AddressSegmentSeries
adjustPrefixLength
in interface AddressSegmentSeries
adjustment
- the incrementzeroed
- whether the bits that move from one side of the prefix to the other become zero or retain their original valuesIPAddressSegmentSeries setPrefixLength(int prefixLength)
AddressSegmentSeries
If this series has a prefix length, and the prefix length is increased, the bits moved within the prefix become zero.
For an alternative that does not set bits to zero, use AddressSegmentSeries.setPrefixLength(int, boolean)
with the second argument as false.
When the prefix is extended beyond the segment series boundary, it is removed.
The bits that move from one side of the prefix length to the other (ie bits moved into the prefix or outside the prefix) are zeroed.
setPrefixLength
in interface AddressSegmentSeries
IPAddressSegmentSeries setPrefixLength(int prefixLength, boolean zeroed)
AddressSegmentSeries
When the prefix is extended beyond the segment series boundary, it is removed.
setPrefixLength
in interface AddressSegmentSeries
zeroed
- whether the bits that move from one side of the prefix length to the other (ie bits moved into the prefix or outside the prefix) are zeroed.@Deprecated IPAddressSegmentSeries applyPrefixLength(int networkPrefixLength)
AddressSegmentSeries
Similar to AddressSegmentSeries.setPrefixLength(int)
except that prefix lengths are never increased.
When this series already has a prefix length that is less than or equal to the requested prefix length, this series is returned.
Otherwise the returned series has the given prefix length.
The bits moved outside the prefix will become zero in the returned series.
applyPrefixLength
in interface AddressSegmentSeries
AddressSegmentSeries.setPrefixLength(int)