public abstract class IPAddressSection extends IPAddressDivisionGrouping implements IPAddressSegmentSeries, AddressSection
IPAddressSection objects are immutable. Some of the derived state is created upon demand and cached. This also makes them thread-safe. Almost all operations that can be performed on IPAddress objects can also be performed on IPAddressSection objects and vice-versa.
Modifier and Type | Class and Description |
---|---|
static class |
IPAddressSection.IPStringBuilderOptions
This user-facing class is designed to be a clear way to create a collection of strings.
|
static class |
IPAddressSection.IPStringOptions
Represents a clear way to create a specific type of string.
|
static interface |
IPAddressSection.SegFunction<R,S> |
static interface |
IPAddressSection.SeriesCreator |
static interface |
IPAddressSection.TriFunction<R,S> |
static class |
IPAddressSection.WildcardOptions |
IPAddressDivisionGrouping.Range, IPAddressDivisionGrouping.RangeList
AddressDivisionGrouping.DivisionLengthProvider, AddressDivisionGrouping.DivisionValueProvider, AddressDivisionGrouping.StringOptions
Modifier and Type | Method and Description |
---|---|
abstract IPAddressSection |
adjustPrefixBySegment(boolean nextSegment)
Increases or decreases prefix length to the next segment boundary.
|
IPAddressSection |
adjustPrefixBySegment(boolean nextSegment,
boolean zeroed)
Increases or decreases prefix length to the next segment boundary.
|
abstract IPAddressSection |
adjustPrefixLength(int adjustment)
Increases or decreases prefix length by the given increment.
|
abstract IPAddressSection |
adjustPrefixLength(int adjustment,
boolean zeroed)
Increases or decreases prefix length by the given increment.
|
abstract IPAddressSection |
applyPrefixLength(int networkPrefixLength)
Deprecated.
|
IPAddressSection |
assignMinPrefixForBlock()
Constructs an equivalent address section with the smallest CIDR prefix possible (largest network),
such that the range of values are a set of subnet blocks for that prefix.
|
IPAddressSection |
assignPrefixForSingleBlock()
Returns the equivalent CIDR address section with a prefix length for which the subnet block for that prefix matches the range of values in this section.
|
static int |
bitsPerSegment(IPAddress.IPVersion version) |
abstract Iterator<? extends IPAddressSection> |
blockIterator(int segmentCount)
Iterates through series that can be obtained by iterating through all the upper segments up to the given segment count.
|
abstract AddressComponentSpliterator<? extends IPAddressSection> |
blockSpliterator(int segmentCount)
Partitions and traverses through the individual sequential blocks created from each of the individual values up to the given segment count.
|
abstract Stream<? extends IPAddressSection> |
blockStream(int segmentCount)
Returns a sequential stream of the individual blocks created from each of the individual values up to the given segment count.
|
static int |
bytesPerSegment(IPAddress.IPVersion version) |
boolean |
contains(AddressSection other)
Determines if one section contains another.
|
boolean |
containsNonZeroHosts(IPAddressSection other)
Returns whether this address contains the non-zero host addresses in other.
|
boolean |
containsPrefixBlock(int prefixLength)
Returns whether the values of this division grouping contain the prefix block for the given prefix length
|
abstract IPAddressSection |
coverWithPrefixBlock()
Returns the minimal-size prefix block that covers all the values in this series.
|
int |
getBitCount()
Provides the number of bits comprising this address item
|
BigInteger |
getBlockCount(int segmentCount)
Returns the count of values in the initial (higher) count of divisions.
|
Integer |
getBlockMaskPrefixLength(boolean network)
If this address section is equivalent to the mask for a CIDR prefix block, it returns that prefix length.
|
int |
getByteCount()
Provides the number of bytes required for this address item, rounding up if the bit count is not a multiple of 8
|
BigInteger |
getCountImpl() |
IPAddressSegment |
getDivision(int index) |
IPAddressSection |
getHostMask()
Returns the host mask associated with the CIDR network prefix length of this series.
|
abstract Iterable<? extends IPAddressSection> |
getIterable()
Useful for using an instance in a "for-each loop".
|
abstract IPAddressSection |
getLower()
If this represents a series with ranging values, returns a series representing the lower values of the range.
|
abstract IPAddressSection |
getLowerNonZeroHost()
Similar to
IPAddressSegmentSeries.getLower() , but will not return a series that has a prefix length and whose host value is zero. |
int |
getMaxSegmentValue()
Returns the maximum possible segment value for this type of address.
|
int |
getMinPrefixLengthForBlock()
Returns the smallest CIDR prefix length possible (largest network) for which this includes the block of address sections for that prefix.
|
IPAddressSection |
getNetworkMask()
Returns the network mask associated with the CIDR network prefix length of this series.
|
BigInteger |
getNonZeroHostCount()
Gets the count of single value series that this series may represent, but excluding series whose host is zero.
|
IPAddressStringDivisionSeries[] |
getParts(IPAddressSection.IPStringBuilderOptions options)
Get all representations of this address including this IPAddressSection.
|
Integer |
getPrefixLengthForSingleBlock()
Returns a prefix length for which the range of this address section matches the block of addresses for that prefix.
|
abstract IPAddressSection |
getSection(int index)
Gets the subsection from the series starting from the given index
The first segment is at index 0.
|
abstract 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.
|
int |
getSegmentCount()
Returns the number of segments in this series.
|
void |
getSegments(AddressSegment[] segs)
Copies the existing segments into the given array.
|
void |
getSegments(int start,
int end,
AddressSegment[] segs,
int destIndex)
get the segments from start to end and insert into the segs array at the given index
|
String[] |
getSegmentStrings()
Returns the an array with the values of each segment as they would appear in the normalized with wildcards string.
|
BigInteger |
getSequentialBlockCount()
provides the count of elements from the
IPAddressSegmentSeries.sequentialBlockIterator() , the minimal number of sequential sub-series that comprise this series |
void |
getStartsWithSQLClause(StringBuilder builder,
String expression)
This method gives you an SQL clause that allows you to search the database for the front part of an address or
addresses in a given network.
|
void |
getStartsWithSQLClause(StringBuilder builder,
String expression,
IPAddressSQLTranslator translator) |
abstract IPAddressSection |
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 networkPrefixLength)
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 networkPrefixLength)
Returns whether all bits past the given prefix length are zero.
|
abstract IPAddressSection |
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.
|
abstract IPAddressSection |
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. |
boolean |
isEntireAddress() |
boolean |
isFullRange()
whether this address item represents all possible values attainable by an address item of this type
|
boolean |
isIPv4() |
boolean |
isIPv6() |
boolean |
isSingleNetwork() |
boolean |
isSinglePrefixBlock()
Returns whether the division grouping range matches the block of values for its prefix length.
|
boolean |
isZeroHost()
Returns whether this section has a prefix length and if so,
whether the host section is zero for this section or all sections in this set of address sections.
|
boolean |
isZeroHost(int prefixLength)
Returns whether the host is zero for the given prefix length for this section or all sections in this set of address sections.
|
abstract Iterator<? extends IPAddressSection> |
iterator()
Iterates through the individual address components.
|
boolean |
matchesWithMask(IPAddressSection other,
IPAddressSection mask)
Applies the mask to this address section and then compares values with the given address section
|
abstract Iterator<? extends IPAddressSection> |
nonZeroHostIterator()
Similar to the iterator, but series with a host of zero are skipped.
|
abstract Iterator<? extends IPAddressSection> |
prefixBlockIterator()
Iterates through the individual prefix blocks.
|
abstract AddressComponentSpliterator<? extends IPAddressSection> |
prefixBlockSpliterator()
Partitions and traverses through the individual prefix blocks for the prefix length of this series.
|
abstract Stream<? extends IPAddressSection> |
prefixBlockStream()
Returns a sequential stream of the individual prefix blocks for the prefix length of this series.
|
abstract boolean |
prefixContains(IPAddressSection other)
Returns whether the prefix of this address contains all values of the same bits in the given address or subnet
|
abstract Iterator<? extends IPAddressSection> |
prefixIterator()
Iterates through the individual prefixes.
|
abstract AddressComponentSpliterator<? extends IPAddressSection> |
prefixSpliterator()
Partitions and traverses through the individual prefixes for the prefix length of this series.
|
abstract Stream<? extends IPAddressSection> |
prefixStream()
Returns a sequential stream of the individual prefixes for the prefix length of this series.
|
abstract IPAddressSection |
removePrefixLength()
Deprecated.
|
abstract IPAddressSection |
removePrefixLength(boolean zeroed)
Deprecated.
|
abstract IPAddressSection |
reverseBits(boolean perByte)
Returns a new series which has the bits reversed.
|
abstract IPAddressSection |
reverseBytes()
Returns a new segment series with the bytes reversed.
|
abstract IPAddressSection |
reverseBytesPerSegment()
Returns a new segment series with the bytes reversed within each segment.
|
abstract IPAddressSection |
reverseSegments()
Returns a new segment series with the segments reversed.
|
Iterator<? extends IPAddressSection> |
sequentialBlockIterator()
Iterates through the sequential series that make up this series.
|
AddressComponentSpliterator<? extends IPAddressSection> |
sequentialBlockSpliterator()
Partitions and traverses through the individual sequential blocks.
|
Stream<? extends IPAddressSection> |
sequentialBlockStream()
Returns a sequential stream of the individual sequential blocks.
|
abstract IPAddressSection |
setPrefixLength(int prefixLength)
Sets the prefix length.
|
abstract IPAddressSection |
setPrefixLength(int prefixLength,
boolean zeroed)
Sets the prefix length.
|
abstract IPAddressSection |
setPrefixLength(int prefixLength,
boolean zeroed,
boolean zeroHostIsBlock)
Sets the prefix length while allowing the caller to control whether bits moved in or out of the prefix become zero,
and whether a zero host for the new prefix bits can be translated into a prefix block.
|
abstract AddressComponentSpliterator<? extends IPAddressSection> |
spliterator()
Partitions and traverses through the individual address components.
|
abstract Stream<? extends IPAddressSection> |
stream()
Returns a sequential stream of the individual address components.
|
IPAddressPartStringCollection |
toAllStringCollection()
Use this method with care...
|
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.
|
IPAddressPartStringCollection |
toDatabaseSearchStringCollection()
Returns a set of strings for search the standard string representations in a database
-compress the largest compressible segments or no compression (a:0:0:c:d:0:e:f or a::c:d:0:e:f)
-upper/lowercase is not considered because many databases are case-insensitive
|
String |
toHexString(boolean with0xPrefix)
Writes this address component as a single hexadecimal value with always the exact same number of characters, with or without a preceding 0x prefix.
|
abstract IPAddressSection |
toMaxHost()
Returns the segment series with a host of all ones.
|
abstract IPAddressSection |
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.
|
static String |
toNormalizedString(IPAddressSection.IPStringOptions opts,
IPAddressStringDivisionSeries section) |
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.
|
abstract IPAddressSection |
toPrefixBlock()
If this series has a prefix length, returns the subnet block for that prefix.
|
abstract IPAddressSection |
toPrefixBlock(int networkPrefixLength)
Returns the segment series of the same length that spans all hosts.
|
IPAddressPartStringCollection |
toStandardStringCollection()
Returns at most a couple dozen string representations:
-mixed (1:2:3:4:5:6:1.2.3.4)
-upper and lower case
-full compressions or no compression (a:0:0:c:d:0:e:f or a::c:d:0:e:f or a:0:b:c:d::e:f)
-full leading zeros (000a:0000:000b:000c:000d:0000:000e:000f)
-combinations thereof
|
String |
toString() |
abstract IPAddressSection |
toZeroHost()
Returns the segment series with a host of zero, the host being the bits following the prefix length.
|
abstract IPAddressSection |
toZeroHost(int prefixLength)
Produces the series with host values of 0 for the given prefix length.
|
abstract IPAddressSection |
toZeroNetwork()
Returns the segment series with a network of zero, the network being the bits within the prefix length.
|
abstract IPAddressSection |
withoutPrefixLength()
Provides the same address with no prefix.
|
containsSinglePrefixBlock, equals, getLeadingBitCount, getNetwork, getNetworkPrefixLength, getPrefixLength, getTrailingBitCount, getZeroRangeSegments, getZeroSegments, isMore, isPrefixBlock
hashCode
getBytes, getBytes, getBytes, getCount, getDivisionCount, getDivisionStrings, getPrefixCount, getUpperBytes, getUpperBytes, getUpperBytes, getUpperValue, getValue, includesMax, includesZero, isMax, isMultiple, isPrefixed, isSequential, isZero
getHostSection, getHostSection, getIPVersion, getNetwork, getNetworkSection, getNetworkSection, getNetworkSection, getPrefixLenComparator, getSection, getSegments, segmentsIterator, segmentsNonZeroHostIterator, segmentsSpliterator, segmentsStream, spanWithPrefixBlocks, spanWithSequentialBlocks, toCanonicalWildcardString, toCompressedWildcardString, toFullString, toNormalizedWildcardString, toPrefixLengthString, toReverseDNSLookupString, toSegmentedBinaryString, toSQLWildcardString, toStringCollection, toSubnetString
getNetworkPrefixLength
getPrefixLength, isPrefixBlock, isPrefixed
enumerate, overlaps, prefixEquals
getBitsPerSegment, getBytesPerSegment, isOneBit, testBit, toCanonicalString, toCompressedString
getCount, getDivisionStrings, getPrefixCount, getPrefixCount, getPrefixLength, getSequentialBlockIndex, isMore, isPrefixBlock, isPrefixed, isSequential
getDivisionCount
toNormalizedString
stream, stream
public boolean isSinglePrefixBlock()
IPAddressDivisionGrouping
isSinglePrefixBlock
in interface AddressDivisionSeries
isSinglePrefixBlock
in class IPAddressDivisionGrouping
public int getBitCount()
AddressItem
getBitCount
in interface AddressDivisionSeries
getBitCount
in interface AddressItem
public int getByteCount()
AddressItem
getByteCount
in interface AddressItem
public static int bitsPerSegment(IPAddress.IPVersion version)
public static int bytesPerSegment(IPAddress.IPVersion version)
public BigInteger getNonZeroHostCount()
IPAddressSegmentSeries
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()
.
getNonZeroHostCount
in interface IPAddressSegmentSeries
public BigInteger getCountImpl()
public BigInteger getBlockCount(int segmentCount)
AddressDivisionSeries
getBlockCount
in interface AddressDivisionSeries
public boolean isIPv4()
public boolean isIPv6()
public int getMaxSegmentValue()
AddressSegmentSeries
getMaxSegmentValue
in interface AddressSegmentSeries
public Integer getBlockMaskPrefixLength(boolean network)
network
- whether to check for a network mask or a host maskpublic int getSegmentCount()
AddressSegmentSeries
getSegmentCount
in interface AddressSegmentSeries
public 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
getSegment
in interface IPAddressSegmentSeries
public IPAddressSegment getDivision(int index)
getDivision
in interface AddressDivisionSeries
getDivision
in interface IPAddressDivisionSeries
getDivision
in interface AddressStringDivisionSeries
getDivision
in interface IPAddressStringDivisionSeries
getDivision
in class IPAddressDivisionGrouping
public boolean containsPrefixBlock(int prefixLength)
AddressDivisionGrouping
containsPrefixBlock
in interface AddressItem
containsPrefixBlock
in class IPAddressDivisionGrouping
public boolean contains(AddressSection other)
AddressSection
Sections must have the same number of segments to be comparable.
For sections which are aware of their position in an address (IPv6 and MAC), their respective positions must match to be comparable.
contains
in interface AddressSection
other
- public boolean containsNonZeroHosts(IPAddressSection other)
other
- public abstract boolean prefixContains(IPAddressSection other)
other
- public boolean isFullRange()
AddressItem
isFullRange
in interface AddressItem
isFullRange
in class AddressDivisionGroupingBase
public abstract IPAddressSection toZeroHost()
IPAddressSegmentSeries
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
toZeroHost
in interface IPAddressSegmentSeries
IPAddressSegmentSeries.toZeroNetwork()
public abstract IPAddressSection toZeroHost(int prefixLength)
IPAddressSegmentSeries
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
toZeroHost
in interface IPAddressSegmentSeries
public abstract IPAddressSection toZeroNetwork()
IPAddressSegmentSeries
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
.
toZeroNetwork
in interface IPAddressSegmentSeries
IPAddressSegmentSeries.toZeroHost()
public abstract IPAddressSection toMaxHost()
IPAddressSegmentSeries
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
toMaxHost
in interface IPAddressSegmentSeries
public abstract IPAddressSection toMaxHost(int prefixLength)
IPAddressSegmentSeries
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
toMaxHost
in interface IPAddressSegmentSeries
@Deprecated public abstract IPAddressSection applyPrefixLength(int networkPrefixLength) throws PrefixLenException
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 AddressSection
applyPrefixLength
in interface AddressSegmentSeries
applyPrefixLength
in interface IPAddressSegmentSeries
PrefixLenException
AddressSegmentSeries.setPrefixLength(int)
public abstract IPAddressSection coverWithPrefixBlock()
IPAddressSegmentSeries
coverWithPrefixBlock
in interface IPAddressSegmentSeries
public abstract IPAddressSection toPrefixBlock()
IPAddressSegmentSeries
toPrefixBlock
in interface AddressSection
toPrefixBlock
in interface AddressSegmentSeries
toPrefixBlock
in interface IPAddressSegmentSeries
public abstract IPAddressSection toPrefixBlock(int networkPrefixLength)
IPAddressSegmentSeries
toPrefixBlock
in interface IPAddressSegmentSeries
public IPAddressSection getHostMask()
IPAddressSegmentSeries
getHostMask
in interface IPAddressSegmentSeries
public IPAddressSection getNetworkMask()
IPAddressSegmentSeries
getNetworkMask
in interface IPAddressSegmentSeries
public IPAddressSection assignPrefixForSingleBlock()
If no such prefix length exists, returns null.
If this address represents just a single address, "this" is returned.
assignPrefixForSingleBlock
in interface IPAddressSegmentSeries
IPAddressSegmentSeries.toPrefixBlock()
,
IPAddressSegmentSeries.assignMinPrefixForBlock()
public IPAddressSection assignMinPrefixForBlock()
assignMinPrefixForBlock
in interface IPAddressSegmentSeries
IPAddressSegmentSeries.toPrefixBlock()
,
IPAddressSegmentSeries.assignPrefixForSingleBlock()
public boolean includesZeroHost()
IPAddressSegmentSeries
includesZeroHost
in interface IPAddressSegmentSeries
includesZeroHost
in class IPAddressDivisionGrouping
public boolean includesZeroHost(int networkPrefixLength)
IPAddressSegmentSeries
includesZeroHost
in interface IPAddressSegmentSeries
public boolean includesMaxHost()
IPAddressSegmentSeries
includesMaxHost
in interface IPAddressSegmentSeries
public boolean includesMaxHost(int networkPrefixLength)
IPAddressSegmentSeries
includesMaxHost
in interface IPAddressSegmentSeries
public boolean isSingleNetwork()
public boolean matchesWithMask(IPAddressSection other, IPAddressSection mask)
mask
- other
- @Deprecated public abstract IPAddressSection removePrefixLength(boolean zeroed)
AddressSegmentSeries
AddressSegmentSeries.removePrefixLength()
removePrefixLength
in interface AddressSection
removePrefixLength
in interface AddressSegmentSeries
removePrefixLength
in interface IPAddressSegmentSeries
zeroed
- whether the bits outside the prefix become zero@Deprecated public abstract IPAddressSection 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 AddressSection
removePrefixLength
in interface AddressSegmentSeries
removePrefixLength
in interface IPAddressSegmentSeries
for an alternative which does not change the address series values.
public abstract IPAddressSection withoutPrefixLength()
AddressSegmentSeries
Use AddressSegmentSeries.removePrefixLength()
as an alternative that deletes the host at the same time by zeroing the host values.
withoutPrefixLength
in interface AddressSection
withoutPrefixLength
in interface AddressSegmentSeries
withoutPrefixLength
in interface IPAddressSegmentSeries
public IPAddressSection adjustPrefixBySegment(boolean nextSegment, boolean zeroed)
AddressSegmentSeries
adjustPrefixBySegment
in interface AddressSection
adjustPrefixBySegment
in interface AddressSegmentSeries
adjustPrefixBySegment
in interface IPAddressSegmentSeries
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 valuespublic abstract IPAddressSection 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 AddressSection
adjustPrefixBySegment
in interface AddressSegmentSeries
adjustPrefixBySegment
in interface IPAddressSegmentSeries
nextSegment
- whether to move prefix to previous or following segment boundarypublic abstract IPAddressSection 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 AddressSection
adjustPrefixLength
in interface AddressSegmentSeries
adjustPrefixLength
in interface IPAddressSegmentSeries
public abstract IPAddressSection adjustPrefixLength(int adjustment, boolean zeroed)
AddressSegmentSeries
adjustPrefixLength
in interface AddressSection
adjustPrefixLength
in interface AddressSegmentSeries
adjustPrefixLength
in interface IPAddressSegmentSeries
adjustment
- the incrementzeroed
- whether the bits that move from one side of the prefix to the other become zero or retain their original valuespublic abstract IPAddressSection 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 AddressSection
setPrefixLength
in interface AddressSegmentSeries
setPrefixLength
in interface IPAddressSegmentSeries
public abstract IPAddressSection setPrefixLength(int prefixLength, boolean zeroed)
AddressSegmentSeries
When the prefix is extended beyond the segment series boundary, it is removed.
setPrefixLength
in interface AddressSection
setPrefixLength
in interface AddressSegmentSeries
setPrefixLength
in interface IPAddressSegmentSeries
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.public abstract IPAddressSection setPrefixLength(int prefixLength, boolean zeroed, boolean zeroHostIsBlock)
setPrefixLength(int, boolean)
and setPrefixLength(int)
use a value of true for zeroed and for zeroHostIsBlock.
For example, when zeroHostIsBlock is true, applying to 1.2.0.0 the prefix length 16 results in 1.2.*.*/16
Or if you start with 1.2.0.0/24, setting the prefix length to 16 results in a zero host followed by the existing prefix block, which is then converted to a full prefix block, 1.2.*.*/16
When both zeroed and zeroHostIsBlock are true, applying the prefix length of 16 to 1.2.4.0/24 also results in a zero host followed by the existing prefix block, which is then converted to a full prefix block, 1.2.*.*/16.
When both zeroed and zeroHostIsBlock are false, the resulting address always encompasses the same set of addresses as the original, albeit with a different prefix length.
prefixLength
- zeroed
- zeroHostIsBlock
- public int getMinPrefixLengthForBlock()
getMinPrefixLengthForBlock
in interface AddressItem
getMinPrefixLengthForBlock
in class AddressDivisionGroupingBase
IPAddressDivision.getBlockMaskPrefixLength(boolean)
public Integer getPrefixLengthForSingleBlock()
If no such prefix exists, returns null
If this address section represents a single value, returns the bit length
getPrefixLengthForSingleBlock
in interface AddressItem
getPrefixLengthForSingleBlock
in class IPAddressDivisionGrouping
public abstract IPAddressSection getLowerNonZeroHost()
IPAddressSegmentSeries
IPAddressSegmentSeries.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 IPAddressSegmentSeries.getLower()
.getLowerNonZeroHost
in interface IPAddressSegmentSeries
public abstract IPAddressSection getLower()
AddressSegmentSeries
getLower
in interface AddressSection
getLower
in interface AddressSegmentSeries
getLower
in interface AddressComponentRange
getLower
in interface IPAddressSegmentSeries
public abstract IPAddressSection getUpper()
AddressSegmentSeries
getUpper
in interface AddressSection
getUpper
in interface AddressSegmentSeries
getUpper
in interface AddressComponentRange
getUpper
in interface IPAddressSegmentSeries
public abstract IPAddressSection reverseSegments()
AddressSegmentSeries
IncompatibleAddressException
since all address series can reverse their segments.reverseSegments
in interface AddressSection
reverseSegments
in interface AddressSegmentSeries
reverseSegments
in interface IPAddressSegmentSeries
public abstract IPAddressSection reverseBits(boolean perByte)
IPAddressSegmentSeries
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 IPAddressSegmentSeries.iterator()
, IPAddressSegmentSeries.getLower()
, IPAddressSegmentSeries.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 AddressSection
reverseBits
in interface AddressSegmentSeries
reverseBits
in interface IPAddressSegmentSeries
perByte
- if true, only the bits in each byte are reversed, if false, then all bits in the address are reversedpublic abstract IPAddressSection reverseBytes()
AddressSegmentSeries
reverseBytes
in interface AddressComponent
reverseBytes
in interface AddressSection
reverseBytes
in interface AddressSegmentSeries
reverseBytes
in interface IPAddressSegmentSeries
public abstract IPAddressSection reverseBytesPerSegment()
AddressSegmentSeries
reverseBytesPerSegment
in interface AddressSection
reverseBytesPerSegment
in interface AddressSegmentSeries
reverseBytesPerSegment
in interface IPAddressSegmentSeries
public abstract IPAddressSection getSection(int index)
AddressSegmentSeries
getSection
in interface AddressSegmentSeries
getSection
in interface IPAddressSegmentSeries
public abstract IPAddressSection getSection(int index, int endIndex)
AddressSegmentSeries
getSection
in interface AddressSegmentSeries
getSection
in interface IPAddressSegmentSeries
public void getSegments(AddressSegment[] segs)
AddressSegmentSeries
AddressSegmentSeries.getSegmentCount()
getSegments
in interface AddressSegmentSeries
public void getSegments(int start, int end, AddressSegment[] segs, int destIndex)
AddressSegmentSeries
getSegments
in interface AddressSegmentSeries
start
- the first segment index from this series to be includedend
- the first segment index to be excludedsegs
- the target arraydestIndex
- where to insert the segments in the segs arraypublic abstract Iterable<? extends IPAddressSection> getIterable()
AddressComponentRange
AddressComponentRange.iterator()
directly.getIterable
in interface AddressSection
getIterable
in interface AddressSegmentSeries
getIterable
in interface AddressComponentRange
getIterable
in interface IPAddressSegmentSeries
public abstract Iterator<? extends IPAddressSection> nonZeroHostIterator()
IPAddressSegmentSeries
nonZeroHostIterator
in interface IPAddressSegmentSeries
public abstract Iterator<? extends IPAddressSection> 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 AddressSection
iterator
in interface AddressSegmentSeries
iterator
in interface AddressComponentRange
iterator
in interface IPAddressSegmentSeries
public abstract AddressComponentSpliterator<? extends IPAddressSection> spliterator()
AddressComponentRange
spliterator
in interface AddressComponent
spliterator
in interface AddressSection
spliterator
in interface AddressSegmentSeries
spliterator
in interface AddressComponentRange
spliterator
in interface IPAddressSegmentSeries
public abstract Stream<? extends IPAddressSection> stream()
AddressComponentRange
BaseStream.parallel()
on the returned stream.stream
in interface AddressSection
stream
in interface AddressSegmentSeries
stream
in interface AddressComponentRange
stream
in interface IPAddressSegmentSeries
public abstract Iterator<? extends IPAddressSection> prefixIterator()
AddressSegmentSeries
If the series has no prefix length, then this is equivalent to AddressSegmentSeries.iterator()
prefixIterator
in interface AddressSection
prefixIterator
in interface AddressSegmentSeries
prefixIterator
in interface IPAddressSegmentSeries
public abstract AddressComponentSpliterator<? extends IPAddressSection> prefixSpliterator()
AddressSegmentSeries
prefixSpliterator
in interface AddressSection
prefixSpliterator
in interface AddressSegmentSeries
prefixSpliterator
in interface IPAddressSegmentSeries
public abstract Stream<? extends IPAddressSection> prefixStream()
AddressSegmentSeries
BaseStream.parallel()
on the returned stream.prefixStream
in interface AddressSection
prefixStream
in interface AddressSegmentSeries
prefixStream
in interface IPAddressSegmentSeries
public abstract Iterator<? extends IPAddressSection> prefixBlockIterator()
AddressSegmentSeries
If the series has no prefix length, then this is equivalent to AddressSegmentSeries.iterator()
prefixBlockIterator
in interface AddressSection
prefixBlockIterator
in interface AddressSegmentSeries
prefixBlockIterator
in interface IPAddressSegmentSeries
public abstract AddressComponentSpliterator<? extends IPAddressSection> prefixBlockSpliterator()
AddressSegmentSeries
prefixBlockSpliterator
in interface AddressSection
prefixBlockSpliterator
in interface AddressSegmentSeries
prefixBlockSpliterator
in interface IPAddressSegmentSeries
public abstract Stream<? extends IPAddressSection> prefixBlockStream()
AddressSegmentSeries
BaseStream.parallel()
on the returned stream.prefixBlockStream
in interface AddressSection
prefixBlockStream
in interface AddressSegmentSeries
prefixBlockStream
in interface IPAddressSegmentSeries
public abstract Iterator<? extends IPAddressSection> blockIterator(int segmentCount)
IPAddressSegmentSeries
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
blockIterator
in interface IPAddressSegmentSeries
public abstract AddressComponentSpliterator<? extends IPAddressSection> blockSpliterator(int segmentCount)
IPAddressSegmentSeries
blockSpliterator
in interface IPAddressSegmentSeries
public abstract Stream<? extends IPAddressSection> blockStream(int segmentCount)
IPAddressSegmentSeries
BaseStream.parallel()
on the returned stream.blockStream
in interface IPAddressSegmentSeries
public Iterator<? extends IPAddressSection> sequentialBlockIterator()
IPAddressSegmentSeries
IPAddressSegmentSeries.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 IPAddressSegmentSeries.getSequentialBlockCount()
to get the count of iterated elements.
sequentialBlockIterator
in interface IPAddressSegmentSeries
public AddressComponentSpliterator<? extends IPAddressSection> sequentialBlockSpliterator()
IPAddressSegmentSeries
sequentialBlockSpliterator
in interface IPAddressSegmentSeries
public Stream<? extends IPAddressSection> sequentialBlockStream()
IPAddressSegmentSeries
BaseStream.parallel()
on the returned stream.
Use IPAddressSegmentSeries.getSequentialBlockCount()
to get the count of streamed elements.
sequentialBlockStream
in interface IPAddressSegmentSeries
public BigInteger getSequentialBlockCount()
IPAddressSegmentSeries
IPAddressSegmentSeries.sequentialBlockIterator()
, the minimal number of sequential sub-series that comprise this seriesgetSequentialBlockCount
in interface IPAddressSegmentSeries
public abstract IPAddressSection 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 AddressSection
increment
in interface AddressSegmentSeries
increment
in interface IPAddressSegmentSeries
public abstract IPAddressSection 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 AddressSection
incrementBoundary
in interface AddressSegmentSeries
incrementBoundary
in interface IPAddressSegmentSeries
public boolean isEntireAddress()
public boolean isZeroHost()
public boolean isZeroHost(int prefixLength)
public String toString()
toString
in class AddressDivisionGroupingBase
public String[] getSegmentStrings()
AddressSegmentSeries
getSegmentStrings
in interface AddressSegmentSeries
public String toBinaryString() throws IncompatibleAddressException
IPAddressSegmentSeries
toBinaryString
in interface IPAddressSegmentSeries
IncompatibleAddressException
public String toOctalString(boolean with0Prefix) throws IncompatibleAddressException
IPAddressSegmentSeries
toOctalString
in interface IPAddressSegmentSeries
IncompatibleAddressException
public String toHexString(boolean with0xPrefix) throws IncompatibleAddressException
AddressComponent
If this component represents a range of values outside of the network prefix length, then this is printed as a range of two hex values.
For instance, for IPv4 addresses there are 8 hex characters, for IPv6 addresses there are 32 hex characters.
toHexString
in interface AddressComponent
IncompatibleAddressException
public String toNormalizedString(IPAddressSection.IPStringOptions stringOptions)
IPAddressSegmentSeries
toNormalizedString
in interface IPAddressSegmentSeries
public static String toNormalizedString(IPAddressSection.IPStringOptions opts, IPAddressStringDivisionSeries section)
public IPAddressPartStringCollection toStandardStringCollection()
public IPAddressPartStringCollection toAllStringCollection()
public IPAddressPartStringCollection toDatabaseSearchStringCollection()
public IPAddressStringDivisionSeries[] getParts(IPAddressSection.IPStringBuilderOptions options)
IPAddressDivisionGrouping
options
- public void getStartsWithSQLClause(StringBuilder builder, String expression)
getStartsWithSQLClause(StringBuilder, String, IPAddressSQLTranslator)
builder
- expression
- the expression that must match the condition, whether a column name or otherpublic void getStartsWithSQLClause(StringBuilder builder, String expression, IPAddressSQLTranslator translator)