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.RangeListAddressDivisionGrouping.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, isPrefixBlockhashCodegetBytes, getBytes, getBytes, getCount, getDivisionCount, getDivisionStrings, getPrefixCount, getUpperBytes, getUpperBytes, getUpperBytes, getUpperValue, getValue, includesMax, includesZero, isMax, isMultiple, isPrefixed, isSequential, isZerogetHostSection, getHostSection, getIPVersion, getNetwork, getNetworkSection, getNetworkSection, getNetworkSection, getPrefixLenComparator, getSection, getSegments, segmentsIterator, segmentsNonZeroHostIterator, segmentsSpliterator, segmentsStream, spanWithPrefixBlocks, spanWithSequentialBlocks, toCanonicalWildcardString, toCompressedWildcardString, toFullString, toNormalizedWildcardString, toPrefixLengthString, toReverseDNSLookupString, toSegmentedBinaryString, toSQLWildcardString, toStringCollection, toSubnetStringgetNetworkPrefixLengthgetPrefixLength, isPrefixBlock, isPrefixedenumerate, overlaps, prefixEqualsgetBitsPerSegment, getBytesPerSegment, isOneBit, testBit, toCanonicalString, toCompressedStringgetCount, getDivisionStrings, getPrefixCount, getPrefixCount, getPrefixLength, getSequentialBlockIndex, isMore, isPrefixBlock, isPrefixed, isSequentialgetDivisionCounttoNormalizedStringstream, streampublic boolean isSinglePrefixBlock()
IPAddressDivisionGroupingisSinglePrefixBlock in interface AddressDivisionSeriesisSinglePrefixBlock in class IPAddressDivisionGroupingpublic int getBitCount()
AddressItemgetBitCount in interface AddressDivisionSeriesgetBitCount in interface AddressItempublic int getByteCount()
AddressItemgetByteCount in interface AddressItempublic static int bitsPerSegment(IPAddress.IPVersion version)
public static int bytesPerSegment(IPAddress.IPVersion version)
public BigInteger getNonZeroHostCount()
IPAddressSegmentSeriesIf 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 IPAddressSegmentSeriespublic BigInteger getCountImpl()
public BigInteger getBlockCount(int segmentCount)
AddressDivisionSeriesgetBlockCount in interface AddressDivisionSeriespublic boolean isIPv4()
public boolean isIPv6()
public int getMaxSegmentValue()
AddressSegmentSeriesgetMaxSegmentValue in interface AddressSegmentSeriespublic Integer getBlockMaskPrefixLength(boolean network)
network - whether to check for a network mask or a host maskpublic int getSegmentCount()
AddressSegmentSeriesgetSegmentCount in interface AddressSegmentSeriespublic IPAddressSegment getSegment(int index)
AddressSegmentSeriesAddressDivisionSeries.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 AddressSegmentSeriesgetSegment in interface IPAddressSegmentSeriespublic IPAddressSegment getDivision(int index)
getDivision in interface AddressDivisionSeriesgetDivision in interface IPAddressDivisionSeriesgetDivision in interface AddressStringDivisionSeriesgetDivision in interface IPAddressStringDivisionSeriesgetDivision in class IPAddressDivisionGroupingpublic boolean containsPrefixBlock(int prefixLength)
AddressDivisionGroupingcontainsPrefixBlock in interface AddressItemcontainsPrefixBlock in class IPAddressDivisionGroupingpublic boolean contains(AddressSection other)
AddressSectionSections 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 AddressSectionother - public boolean containsNonZeroHosts(IPAddressSection other)
other - public abstract boolean prefixContains(IPAddressSection other)
other - public boolean isFullRange()
AddressItemisFullRange in interface AddressItemisFullRange in class AddressDivisionGroupingBasepublic 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 IPAddressSegmentSeriesIPAddressSegmentSeries.toZeroNetwork()public abstract IPAddressSection toZeroHost(int prefixLength)
IPAddressSegmentSeriesIf 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 IPAddressSegmentSeriespublic 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 IPAddressSegmentSeriesIPAddressSegmentSeries.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 IPAddressSegmentSeriespublic abstract IPAddressSection toMaxHost(int prefixLength)
IPAddressSegmentSeriesIf 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 AddressSectionapplyPrefixLength in interface AddressSegmentSeriesapplyPrefixLength in interface IPAddressSegmentSeriesPrefixLenExceptionAddressSegmentSeries.setPrefixLength(int)public abstract IPAddressSection coverWithPrefixBlock()
IPAddressSegmentSeriescoverWithPrefixBlock in interface IPAddressSegmentSeriespublic abstract IPAddressSection toPrefixBlock()
IPAddressSegmentSeriestoPrefixBlock in interface AddressSectiontoPrefixBlock in interface AddressSegmentSeriestoPrefixBlock in interface IPAddressSegmentSeriespublic abstract IPAddressSection toPrefixBlock(int networkPrefixLength)
IPAddressSegmentSeriestoPrefixBlock in interface IPAddressSegmentSeriespublic IPAddressSection getHostMask()
IPAddressSegmentSeriesgetHostMask in interface IPAddressSegmentSeriespublic IPAddressSection getNetworkMask()
IPAddressSegmentSeriesgetNetworkMask in interface IPAddressSegmentSeriespublic IPAddressSection assignPrefixForSingleBlock()
If no such prefix length exists, returns null.
If this address represents just a single address, "this" is returned.
assignPrefixForSingleBlock in interface IPAddressSegmentSeriesIPAddressSegmentSeries.toPrefixBlock(),
IPAddressSegmentSeries.assignMinPrefixForBlock()public IPAddressSection assignMinPrefixForBlock()
assignMinPrefixForBlock in interface IPAddressSegmentSeriesIPAddressSegmentSeries.toPrefixBlock(),
IPAddressSegmentSeries.assignPrefixForSingleBlock()public boolean includesZeroHost()
IPAddressSegmentSeriesincludesZeroHost in interface IPAddressSegmentSeriesincludesZeroHost in class IPAddressDivisionGroupingpublic boolean includesZeroHost(int networkPrefixLength)
IPAddressSegmentSeriesincludesZeroHost in interface IPAddressSegmentSeriespublic boolean includesMaxHost()
IPAddressSegmentSeriesincludesMaxHost in interface IPAddressSegmentSeriespublic boolean includesMaxHost(int networkPrefixLength)
IPAddressSegmentSeriesincludesMaxHost in interface IPAddressSegmentSeriespublic boolean isSingleNetwork()
public boolean matchesWithMask(IPAddressSection other, IPAddressSection mask)
mask - other - @Deprecated public abstract IPAddressSection removePrefixLength(boolean zeroed)
AddressSegmentSeriesAddressSegmentSeries.removePrefixLength()removePrefixLength in interface AddressSectionremovePrefixLength in interface AddressSegmentSeriesremovePrefixLength in interface IPAddressSegmentSerieszeroed - 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 AddressSectionremovePrefixLength in interface AddressSegmentSeriesremovePrefixLength in interface IPAddressSegmentSeriesfor 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 AddressSectionwithoutPrefixLength in interface AddressSegmentSerieswithoutPrefixLength in interface IPAddressSegmentSeriespublic IPAddressSection adjustPrefixBySegment(boolean nextSegment, boolean zeroed)
AddressSegmentSeriesadjustPrefixBySegment in interface AddressSectionadjustPrefixBySegment in interface AddressSegmentSeriesadjustPrefixBySegment in interface IPAddressSegmentSeriesnextSegment - 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 AddressSectionadjustPrefixBySegment in interface AddressSegmentSeriesadjustPrefixBySegment in interface IPAddressSegmentSeriesnextSegment - 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 AddressSectionadjustPrefixLength in interface AddressSegmentSeriesadjustPrefixLength in interface IPAddressSegmentSeriespublic abstract IPAddressSection adjustPrefixLength(int adjustment, boolean zeroed)
AddressSegmentSeriesadjustPrefixLength in interface AddressSectionadjustPrefixLength in interface AddressSegmentSeriesadjustPrefixLength in interface IPAddressSegmentSeriesadjustment - 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 AddressSectionsetPrefixLength in interface AddressSegmentSeriessetPrefixLength in interface IPAddressSegmentSeriespublic abstract IPAddressSection setPrefixLength(int prefixLength, boolean zeroed)
AddressSegmentSeriesWhen the prefix is extended beyond the segment series boundary, it is removed.
setPrefixLength in interface AddressSectionsetPrefixLength in interface AddressSegmentSeriessetPrefixLength in interface IPAddressSegmentSerieszeroed - 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 AddressItemgetMinPrefixLengthForBlock in class AddressDivisionGroupingBaseIPAddressDivision.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 AddressItemgetPrefixLengthForSingleBlock in class IPAddressDivisionGroupingpublic abstract IPAddressSection getLowerNonZeroHost()
IPAddressSegmentSeriesIPAddressSegmentSeries.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 IPAddressSegmentSeriespublic abstract IPAddressSection getLower()
AddressSegmentSeriesgetLower in interface AddressSectiongetLower in interface AddressSegmentSeriesgetLower in interface AddressComponentRangegetLower in interface IPAddressSegmentSeriespublic abstract IPAddressSection getUpper()
AddressSegmentSeriesgetUpper in interface AddressSectiongetUpper in interface AddressSegmentSeriesgetUpper in interface AddressComponentRangegetUpper in interface IPAddressSegmentSeriespublic abstract IPAddressSection reverseSegments()
AddressSegmentSeriesIncompatibleAddressException since all address series can reverse their segments.reverseSegments in interface AddressSectionreverseSegments in interface AddressSegmentSeriesreverseSegments in interface IPAddressSegmentSeriespublic abstract IPAddressSection reverseBits(boolean perByte)
IPAddressSegmentSeriesIf 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 AddressComponentreverseBits in interface AddressSectionreverseBits in interface AddressSegmentSeriesreverseBits in interface IPAddressSegmentSeriesperByte - if true, only the bits in each byte are reversed, if false, then all bits in the address are reversedpublic abstract IPAddressSection reverseBytes()
AddressSegmentSeriesreverseBytes in interface AddressComponentreverseBytes in interface AddressSectionreverseBytes in interface AddressSegmentSeriesreverseBytes in interface IPAddressSegmentSeriespublic abstract IPAddressSection reverseBytesPerSegment()
AddressSegmentSeriesreverseBytesPerSegment in interface AddressSectionreverseBytesPerSegment in interface AddressSegmentSeriesreverseBytesPerSegment in interface IPAddressSegmentSeriespublic abstract IPAddressSection getSection(int index)
AddressSegmentSeriesgetSection in interface AddressSegmentSeriesgetSection in interface IPAddressSegmentSeriespublic abstract IPAddressSection getSection(int index, int endIndex)
AddressSegmentSeriesgetSection in interface AddressSegmentSeriesgetSection in interface IPAddressSegmentSeriespublic void getSegments(AddressSegment[] segs)
AddressSegmentSeriesAddressSegmentSeries.getSegmentCount()getSegments in interface AddressSegmentSeriespublic void getSegments(int start,
int end,
AddressSegment[] segs,
int destIndex)
AddressSegmentSeriesgetSegments in interface AddressSegmentSeriesstart - 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()
AddressComponentRangeAddressComponentRange.iterator() directly.getIterable in interface AddressSectiongetIterable in interface AddressSegmentSeriesgetIterable in interface AddressComponentRangegetIterable in interface IPAddressSegmentSeriespublic abstract Iterator<? extends IPAddressSection> nonZeroHostIterator()
IPAddressSegmentSeriesnonZeroHostIterator in interface IPAddressSegmentSeriespublic abstract Iterator<? extends IPAddressSection> iterator()
AddressComponentRangeAn 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 AddressSectioniterator in interface AddressSegmentSeriesiterator in interface AddressComponentRangeiterator in interface IPAddressSegmentSeriespublic abstract AddressComponentSpliterator<? extends IPAddressSection> spliterator()
AddressComponentRangespliterator in interface AddressComponentspliterator in interface AddressSectionspliterator in interface AddressSegmentSeriesspliterator in interface AddressComponentRangespliterator in interface IPAddressSegmentSeriespublic abstract Stream<? extends IPAddressSection> stream()
AddressComponentRangeBaseStream.parallel() on the returned stream.stream in interface AddressSectionstream in interface AddressSegmentSeriesstream in interface AddressComponentRangestream in interface IPAddressSegmentSeriespublic abstract Iterator<? extends IPAddressSection> prefixIterator()
AddressSegmentSeries
If the series has no prefix length, then this is equivalent to AddressSegmentSeries.iterator()
prefixIterator in interface AddressSectionprefixIterator in interface AddressSegmentSeriesprefixIterator in interface IPAddressSegmentSeriespublic abstract AddressComponentSpliterator<? extends IPAddressSection> prefixSpliterator()
AddressSegmentSeriesprefixSpliterator in interface AddressSectionprefixSpliterator in interface AddressSegmentSeriesprefixSpliterator in interface IPAddressSegmentSeriespublic abstract Stream<? extends IPAddressSection> prefixStream()
AddressSegmentSeriesBaseStream.parallel() on the returned stream.prefixStream in interface AddressSectionprefixStream in interface AddressSegmentSeriesprefixStream in interface IPAddressSegmentSeriespublic abstract Iterator<? extends IPAddressSection> prefixBlockIterator()
AddressSegmentSeries
If the series has no prefix length, then this is equivalent to AddressSegmentSeries.iterator()
prefixBlockIterator in interface AddressSectionprefixBlockIterator in interface AddressSegmentSeriesprefixBlockIterator in interface IPAddressSegmentSeriespublic abstract AddressComponentSpliterator<? extends IPAddressSection> prefixBlockSpliterator()
AddressSegmentSeriesprefixBlockSpliterator in interface AddressSectionprefixBlockSpliterator in interface AddressSegmentSeriesprefixBlockSpliterator in interface IPAddressSegmentSeriespublic abstract Stream<? extends IPAddressSection> prefixBlockStream()
AddressSegmentSeriesBaseStream.parallel() on the returned stream.prefixBlockStream in interface AddressSectionprefixBlockStream in interface AddressSegmentSeriesprefixBlockStream in interface IPAddressSegmentSeriespublic abstract Iterator<? extends IPAddressSection> blockIterator(int segmentCount)
IPAddressSegmentSeriesFor 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 IPAddressSegmentSeriespublic abstract AddressComponentSpliterator<? extends IPAddressSection> blockSpliterator(int segmentCount)
IPAddressSegmentSeriesblockSpliterator in interface IPAddressSegmentSeriespublic abstract Stream<? extends IPAddressSection> blockStream(int segmentCount)
IPAddressSegmentSeriesBaseStream.parallel() on the returned stream.blockStream in interface IPAddressSegmentSeriespublic Iterator<? extends IPAddressSection> sequentialBlockIterator()
IPAddressSegmentSeriesIPAddressSegmentSeries.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 IPAddressSegmentSeriespublic AddressComponentSpliterator<? extends IPAddressSection> sequentialBlockSpliterator()
IPAddressSegmentSeriessequentialBlockSpliterator in interface IPAddressSegmentSeriespublic Stream<? extends IPAddressSection> sequentialBlockStream()
IPAddressSegmentSeriesBaseStream.parallel() on the returned stream.
Use IPAddressSegmentSeries.getSequentialBlockCount() to get the count of streamed elements.
sequentialBlockStream in interface IPAddressSegmentSeriespublic BigInteger getSequentialBlockCount()
IPAddressSegmentSeriesIPAddressSegmentSeries.sequentialBlockIterator(), the minimal number of sequential sub-series that comprise this seriesgetSequentialBlockCount in interface IPAddressSegmentSeriespublic abstract IPAddressSection increment(long increment)
AddressSegmentSeriesIf 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 AddressSectionincrement in interface AddressSegmentSeriesincrement in interface IPAddressSegmentSeriespublic abstract IPAddressSection incrementBoundary(long increment)
AddressSegmentSeriesAddressSegmentSeries.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 AddressSectionincrementBoundary in interface AddressSegmentSeriesincrementBoundary in interface IPAddressSegmentSeriespublic boolean isEntireAddress()
public boolean isZeroHost()
public boolean isZeroHost(int prefixLength)
public String toString()
toString in class AddressDivisionGroupingBasepublic String[] getSegmentStrings()
AddressSegmentSeriesgetSegmentStrings in interface AddressSegmentSeriespublic String toBinaryString() throws IncompatibleAddressException
IPAddressSegmentSeriestoBinaryString in interface IPAddressSegmentSeriesIncompatibleAddressExceptionpublic String toOctalString(boolean with0Prefix) throws IncompatibleAddressException
IPAddressSegmentSeriestoOctalString in interface IPAddressSegmentSeriesIncompatibleAddressExceptionpublic String toHexString(boolean with0xPrefix) throws IncompatibleAddressException
AddressComponentIf 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 AddressComponentIncompatibleAddressExceptionpublic String toNormalizedString(IPAddressSection.IPStringOptions stringOptions)
IPAddressSegmentSeriestoNormalizedString in interface IPAddressSegmentSeriespublic static String toNormalizedString(IPAddressSection.IPStringOptions opts, IPAddressStringDivisionSeries section)
public IPAddressPartStringCollection toStandardStringCollection()
public IPAddressPartStringCollection toAllStringCollection()
public IPAddressPartStringCollection toDatabaseSearchStringCollection()
public IPAddressStringDivisionSeries[] getParts(IPAddressSection.IPStringBuilderOptions options)
IPAddressDivisionGroupingoptions - 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)