Class IPv4AddressSection
- All Implemented Interfaces:
AddressComponent, AddressSection, AddressSegmentSeries, AddressComponentRange, AddressDivisionSeries, AddressItem, AddressItemRange, IPAddressDivisionSeries, AddressStringDivisionSeries, IPAddressStringDivisionSeries, IPAddressSegmentSeries, Serializable, Comparable<AddressItem>, Iterable<IPv4AddressSection>
- Author:
- sfoley
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classRepresents a clear way to create a specific type of string.Nested classes/interfaces inherited from class IPAddressSection
IPAddressSection.IPStringBuilderOptions, IPAddressSection.IPStringOptions, IPAddressSection.SegFunction<R,S>, IPAddressSection.SeriesCreator, IPAddressSection.TriFunction<R, S>, IPAddressSection.WildcardOptions Nested classes/interfaces inherited from class IPAddressDivisionGrouping
IPAddressDivisionGrouping.Range, IPAddressDivisionGrouping.RangeListNested classes/interfaces inherited from class AddressDivisionGrouping
AddressDivisionGrouping.DivisionLengthProvider, AddressDivisionGrouping.DivisionValueProvider, AddressDivisionGrouping.StringOptions -
Constructor Summary
ConstructorsConstructorDescriptionIPv4AddressSection(byte[] bytes) IPv4AddressSection(byte[] bytes, int byteStartIndex, int byteEndIndex) IPv4AddressSection(byte[] bytes, int byteStartIndex, int byteEndIndex, Integer prefix) IPv4AddressSection(byte[] bytes, Integer prefix) IPv4AddressSection(int value) IPv4AddressSection(int value, Integer networkPrefixLength) IPv4AddressSection(Address.SegmentValueProvider valueProvider, int segmentCount) IPv4AddressSection(Address.SegmentValueProvider valueProvider, int segmentCount, Integer networkPrefixLength) IPv4AddressSection(Address.SegmentValueProvider lowerValueProvider, Address.SegmentValueProvider upperValueProvider, int segmentCount) IPv4AddressSection(Address.SegmentValueProvider lowerValueProvider, Address.SegmentValueProvider upperValueProvider, int segmentCount, Integer networkPrefixLength) IPv4AddressSection(IPv4AddressSegment segment) Constructs a single segment section.IPv4AddressSection(IPv4AddressSegment[] segments) IPv4AddressSection(IPv4AddressSegment[] segments, Integer networkPrefixLength) -
Method Summary
Modifier and TypeMethodDescriptionadjustPrefixBySegment(boolean nextSegment) Increases or decreases prefix length to the next segment boundary.adjustPrefixBySegment(boolean nextSegment, boolean zeroed) Increases or decreases prefix length to the next segment boundary.adjustPrefixLength(int adjustment) Increases or decreases prefix length by the given increment.adjustPrefixLength(int adjustment, boolean zeroed) Increases or decreases prefix length by the given increment.append(IPv4AddressSection other) applyPrefixLength(int networkPrefixLength) Deprecated.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.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.bitwiseOr(IPv4AddressSection mask) Equivalent tobitwiseOr(IPv4AddressSection, boolean)with the second argument as false.bitwiseOr(IPv4AddressSection mask, boolean retainPrefix) Does the bitwise disjunction with this address section.bitwiseOrNetwork(IPv4AddressSection mask, int networkPrefixLength) Does the bitwise disjunction with this address section.blockIterator(int segmentCount) Iterates through series that can be obtained by iterating through all the upper segments up to the given segment count.blockSpliterator(int segmentCount) Partitions and traverses through the individual sequential blocks created from each of the individual values up to the given segment count.blockStream(int segmentCount) Returns a sequential stream of the individual blocks created from each of the individual values up to the given segment count.booleancontains(AddressSection other) Determines if one section contains another.Returns the minimal-size prefix block that covers all the values in this series.enumerate(AddressSection other) Indicates where an address section sits relative to the ordering of individual address sections within this section.enumerateIPv4(IPv4AddressSection other) Indicates where an address section sits relative to the ordering of individual address sections within this section.booleanTwo groupings are equal if: - they match type/version (ipv4, ipv6, mac, or a specific grouping class) - they match division counts - each division matches bit counts - each division matches their specific grouping class - each division matches values Prefix lengths, for those groupings and/or divisionsS that have them, are ignored.intProvides the number of bits comprising this address itemintReturns the number of bits comprising each segment in this series.intProvides the number of bytes required for this address item, rounding up if the bit count is not a multiple of 8intReturns the number of bytes comprising each segment in this series.getDivision(int index) Returns the host mask associated with the CIDR network prefix length of this series.Returns the host section of the series.getHostSection(int networkPrefixLength) Returns the host section of the address as indicated by the network prefix length provided.longgetIPv4Count(boolean excludeZeroHosts) longlonggetIPv4PrefixCount(int prefixLength) Returns the version of this segment seriesUseful for using an instance in a "for-each loop".getLower()If this represents a series with ranging values, returns a series representing the lower values of the range.Similar toIPAddressSegmentSeries.getLower(), but will not return a series that has a prefix length and whose host value is zero.Returns the network object for components of the same version (eg IPv4, IPv6 and MAC each have their own network object)Returns the network mask associated with the CIDR network prefix length of this series.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.getNetworkSection(int networkPrefixLength) Returns the network section of the series.getNetworkSection(int networkPrefixLength, boolean withPrefixLength) Returns the network section of the series.Get all representations of this address including this IPAddressSection.getPrefixCount(int prefixLength) The count of the number of distinct values within the prefix part of the address item, the bits that appear within the prefix length.Gets the subsection from the series that comprises all segmentsgetSection(int index) Gets the subsection from the series starting from the given index The first segment is at index 0.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.getSegment(int index) Returns the segment from this series at the given index.Returns the segments of this series of segments as an array.voidgetSegments(int start, int end, Collection<? super IPv4AddressSegment> segs) voidgetSegments(Collection<? super IPv4AddressSegment> segs) getUpper()If this represents a series with ranging values, returns a series representing the upper values of the range.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.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.insert(int index, IPv4AddressSection other) intersect(IPv4AddressSection other) Produces the subnet sections whose individual sections are found in both this and the given argument.intintValue()booleanisIPv4()iterator()Iterates through the individual address components.longmask(IPv4AddressSection mask) Equivalent tomask(IPv4AddressSection, boolean)with the second argument as false.mask(IPv4AddressSection mask, boolean retainPrefix) Does the bitwise conjunction with this address.maskNetwork(IPv4AddressSection mask, int networkPrefixLength) Produces the bitwise conjunction of the given mask with the network section of the address as indicated by the given prefix length.booleanmatchesWithMask(IPAddressSection other, IPAddressSection mask) Applies the mask to this address section and then compares values with the given address sectionmergePrefixBlocks(IPv4AddressSection... sections) Deprecated.mergeToPrefixBlocks(IPv4AddressSection... sections) Merges this with the list of sections to produce the smallest array of prefix blocks.mergeToSequentialBlocks(IPv4AddressSection... sections) Merges this with the list of sections to produce the smallest array of sequential block subnets.Similar to the iterator, but series with a host of zero are skipped.booleanoverlaps(AddressSection other) Determines if one section overlaps another.Iterates through the individual prefix blocks.Partitions and traverses through the individual prefix blocks for the prefix length of this series.Returns a sequential stream of the individual prefix blocks for the prefix length of this series.booleanprefixContains(IPAddressSection other) Returns whether the prefix of this address contains all values of the same bits in the given address or subnetbooleanprefixEquals(AddressSection other) Determines if the argument section matches this section up to the prefix length of this section.Iterates through the individual prefixes.Partitions and traverses through the individual prefixes for the prefix length of this series.Returns a sequential stream of the individual prefixes for the prefix length of this series.Deprecated.removePrefixLength(boolean zeroed) Deprecated.replace(int startIndex, int endIndex, IPv4AddressSection replacement, int replacementStartIndex, int replacementEndIndex) Replaces segments starting from startIndex and ending before endIndex with the segments starting at replacementStartIndex and ending before replacementEndIndex from the replacement sectionreplace(int index, IPv4AddressSection other) Replace the segments of this section starting at the given index with the given replacement segmentsreverseBits(boolean perByte) Returns a new series which has the bits reversed.Returns a new segment series with the bytes reversed.Returns a new segment series with the bytes reversed within each segment.Returns a new segment series with the segments reversed.Iterates through the individual segments.Similar to the segments iterator, but series with a host of zero are skipped.Partitions and traverses through the individual segment arrays.Returns a sequential stream of the individual segment arrays.Iterates through the sequential series that make up this series.Partitions and traverses through the individual sequential blocks.Returns a sequential stream of the individual sequential blocks.setPrefixLength(int networkPrefixLength) Sets the prefix length.setPrefixLength(int networkPrefixLength, boolean withZeros) Sets the prefix length.setPrefixLength(int networkPrefixLength, boolean withZeros, 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.Produces an array of prefix blocks that spans the same set of values.Produces the list of prefix block subnets that span from this series to the given series.Deprecated.Produces an array of blocks that are sequential that cover the same set of sections as this.Produces a list of range subnets that span from this series to the given series.Partitions and traverses through the individual address components.stream()Returns a sequential stream of the individual address components.subtract(IPv4AddressSection other) Subtract the given subnet from this subnet, returning an array of sections for the result (the subnets will not be contiguous so an array is required).Use this method with care...This produces a canonical string.This produces a string similar to the canonical string and avoids the CIDR prefix.The shortest string for IPv4 addresses is the same as the canonical string.This is similar to toNormalizedWildcardString, avoiding the CIDR prefix, but with compression as well.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-insensitiveThis produces a string with no compressed segments and all segments of full length, which is 3 characters for IPv4 segments.toInetAtonString(IPv4Address.inet_aton_radix radix, int joinedCount) toJoinedSegments(int joinCount) Returns the segment series with a host of all ones.toMaxHost(int prefixLength) Produces the series with host values of all one bits for the given prefix length.The normalized string returned by this method is consistent with java.net.Inet4Address, and is the same astoCanonicalString().toNormalizedString(IPAddressSection.IPStringOptions stringParams, int joinCount) This produces a string similar to the normalized string and avoids the CIDR prefix.If this series has a prefix length, returns the subnet block for that prefix.toPrefixBlock(int networkPrefixLength) Returns the segment series of the same length that spans all hosts.Returns a string with a CIDR prefix length if this section has a network prefix length.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.arpaWrites this IP address segment series as a segments of binary values preceded by the "0b" prefix.This is the same as the string from toNormalizedWildcardString except that it usesAddress.SEGMENT_SQL_WILDCARDinstead ofAddress.SEGMENT_WILDCARDand also usesAddress.SEGMENT_SQL_SINGLE_WILDCARDReturns 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 thereofProduces a consistent subnet string.Returns the segment series with a host of zero, the host being the bits following the prefix length.toZeroHost(int prefixLength) Produces the series with host values of 0 for the given prefix length.Returns the segment series with a network of zero, the network being the bits within the prefix length.intlongProvides the same address with no prefix.Methods inherited from class IPAddressSection
bitsPerSegment, bytesPerSegment, containsNonZeroHosts, containsPrefixBlock, getBlockCount, getBlockMaskPrefixLength, getCountImpl, getMaxSegmentValue, getMinPrefixLengthForBlock, getNonZeroHostCount, getPrefixLengthForSingleBlock, getSegmentCount, getSegments, getSegments, getSegmentStrings, getSequentialBlockCount, getStartsWithSQLClause, getStartsWithSQLClause, includesMaxHost, includesMaxHost, includesZeroHost, includesZeroHost, isEntireAddress, isFullRange, isIPv6, isSingleNetwork, isSinglePrefixBlock, isZeroHost, isZeroHost, toBinaryString, toHexString, toNormalizedString, toNormalizedString, toOctalString, toStringMethods inherited from class IPAddressDivisionGrouping
containsSinglePrefixBlock, getLeadingBitCount, getNetworkPrefixLength, getPrefixLength, getTrailingBitCount, getZeroRangeSegments, getZeroSegments, isMore, isPrefixBlockMethods inherited from class AddressDivisionGrouping
hashCodeMethods inherited from class AddressDivisionGroupingBase
getBytes, getBytes, getBytes, getCount, getDivisionCount, getDivisionStrings, getPrefixCount, getUpperBytes, getUpperBytes, getUpperBytes, getUpperValue, getValue, includesMax, includesZero, isMax, isMultiple, isPrefixed, isSequential, isZeroMethods inherited from interface AddressDivisionSeries
getCount, getDivisionStrings, getPrefixCount, getPrefixLength, getSequentialBlockIndex, isMore, isPrefixBlock, isPrefixed, isSequentialMethods inherited from interface AddressItem
compareTo, containsSinglePrefixBlock, getBytes, getBytes, getBytes, getUpperBytes, getUpperBytes, getUpperBytes, getUpperValue, getValue, includesMax, includesZero, isMax, isMultiple, isZeroMethods inherited from interface AddressSegmentSeries
isOneBit, testBitMethods inherited from interface AddressStringDivisionSeries
getDivisionCountMethods inherited from interface IPAddressDivisionSeries
getNetworkPrefixLengthMethods inherited from interface IPAddressStringDivisionSeries
getPrefixLength, isPrefixBlock, isPrefixed
-
Constructor Details
-
IPv4AddressSection
Constructs a single segment section.- Parameters:
segment-
-
IPv4AddressSection
- Throws:
AddressValueException
-
IPv4AddressSection
public IPv4AddressSection(IPv4AddressSegment[] segments, Integer networkPrefixLength) throws AddressValueException - Parameters:
segments- an array containing the segments. Segments that are entirely part of the host section need not be provided, although the array must be the correct length.networkPrefixLength-- Throws:
AddressValueException
-
IPv4AddressSection
public IPv4AddressSection(Address.SegmentValueProvider valueProvider, int segmentCount, Integer networkPrefixLength) throws AddressValueException - Throws:
AddressValueException
-
IPv4AddressSection
public IPv4AddressSection(Address.SegmentValueProvider lowerValueProvider, Address.SegmentValueProvider upperValueProvider, int segmentCount, Integer networkPrefixLength) throws AddressValueException - Throws:
AddressValueException
-
IPv4AddressSection
public IPv4AddressSection(Address.SegmentValueProvider valueProvider, int segmentCount) throws AddressValueException - Throws:
AddressValueException
-
IPv4AddressSection
public IPv4AddressSection(Address.SegmentValueProvider lowerValueProvider, Address.SegmentValueProvider upperValueProvider, int segmentCount) -
IPv4AddressSection
- Throws:
AddressValueException
-
IPv4AddressSection
- Throws:
AddressValueException
-
IPv4AddressSection
public IPv4AddressSection(byte[] bytes, int byteStartIndex, int byteEndIndex, Integer prefix) throws AddressValueException - Throws:
AddressValueException
-
IPv4AddressSection
public IPv4AddressSection(byte[] bytes, int byteStartIndex, int byteEndIndex) throws AddressValueException - Throws:
AddressValueException
-
IPv4AddressSection
- Throws:
AddressValueException
-
IPv4AddressSection
public IPv4AddressSection(int value)
-
-
Method Details
-
getSegments
Description copied from interface:AddressSegmentSeriesReturns the segments of this series of segments as an array. This must create a new array, so for efficiency useAddressSegmentSeries.getSegment(int)andAddressSegmentSeries.getSegmentCount()instead when feasible.- Specified by:
getSegmentsin interfaceAddressSegmentSeries- Specified by:
getSegmentsin interfaceIPAddressSegmentSeries- Returns:
-
getSection
Description copied from interface:AddressSegmentSeriesGets the subsection from the series that comprises all segments- Specified by:
getSectionin interfaceAddressSegmentSeries- Specified by:
getSectionin interfaceIPAddressSegmentSeries- Returns:
-
getSection
Description copied from interface:AddressSegmentSeriesGets the subsection from the series starting from the given index The first segment is at index 0.- Specified by:
getSectionin interfaceAddressSegmentSeries- Specified by:
getSectionin interfaceIPAddressSegmentSeries- Specified by:
getSectionin classIPAddressSection- Parameters:
index-- Returns:
-
getSection
Description copied from interface:AddressSegmentSeriesGets the subsection from the series starting from the given index and ending just before the give endIndex The first segment is at index 0.- Specified by:
getSectionin interfaceAddressSegmentSeries- Specified by:
getSectionin interfaceIPAddressSegmentSeries- Specified by:
getSectionin classIPAddressSection- Parameters:
index-endIndex-- Returns:
-
getLowerNonZeroHost
Description copied from interface:IPAddressSegmentSeriesSimilar toIPAddressSegmentSeries.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 asIPAddressSegmentSeries.getLower().- Specified by:
getLowerNonZeroHostin interfaceIPAddressSegmentSeries- Specified by:
getLowerNonZeroHostin classIPAddressSection- Returns:
- the lowest IP address series whose host is non-zero, or null if no such address section exists.
-
getLower
Description copied from interface:AddressSegmentSeriesIf this represents a series with ranging values, returns a series representing the lower values of the range. If this represents an series with a single value in each segment, returns this.- Specified by:
getLowerin interfaceAddressComponentRange- Specified by:
getLowerin interfaceAddressSection- Specified by:
getLowerin interfaceAddressSegmentSeries- Specified by:
getLowerin interfaceIPAddressSegmentSeries- Specified by:
getLowerin classIPAddressSection- Returns:
-
getUpper
Description copied from interface:AddressSegmentSeriesIf this represents a series with ranging values, returns a series representing the upper values of the range. If this represents a series with a single value in each segment, returns this.- Specified by:
getUpperin interfaceAddressComponentRange- Specified by:
getUpperin interfaceAddressSection- Specified by:
getUpperin interfaceAddressSegmentSeries- Specified by:
getUpperin interfaceIPAddressSegmentSeries- Specified by:
getUpperin classIPAddressSection- Returns:
-
intValue
public int intValue() -
upperIntValue
public int upperIntValue() -
longValue
public long longValue() -
upperLongValue
public long upperLongValue() -
reverseBits
Description copied from interface:IPAddressSegmentSeriesReturns a new series which has the bits reversed.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 callIPAddressSegmentSeries.iterator(),IPAddressSegmentSeries.getLower(),IPAddressSegmentSeries.getUpper()or some other method to transform the address into an address representing a single value before reversing.- Specified by:
reverseBitsin interfaceAddressComponent- Specified by:
reverseBitsin interfaceAddressSection- Specified by:
reverseBitsin interfaceAddressSegmentSeries- Specified by:
reverseBitsin interfaceIPAddressSegmentSeries- Specified by:
reverseBitsin classIPAddressSection- Parameters:
perByte- if true, only the bits in each byte are reversed, if false, then all bits in the address are reversed- Returns:
-
reverseBytes
Description copied from interface:AddressSegmentSeriesReturns a new segment series with the bytes reversed.- Specified by:
reverseBytesin interfaceAddressComponent- Specified by:
reverseBytesin interfaceAddressSection- Specified by:
reverseBytesin interfaceAddressSegmentSeries- Specified by:
reverseBytesin interfaceIPAddressSegmentSeries- Specified by:
reverseBytesin classIPAddressSection- Returns:
-
reverseBytesPerSegment
Description copied from interface:AddressSegmentSeriesReturns a new segment series with the bytes reversed within each segment.- Specified by:
reverseBytesPerSegmentin interfaceAddressSection- Specified by:
reverseBytesPerSegmentin interfaceAddressSegmentSeries- Specified by:
reverseBytesPerSegmentin interfaceIPAddressSegmentSeries- Specified by:
reverseBytesPerSegmentin classIPAddressSection- Returns:
-
reverseSegments
Description copied from interface:AddressSegmentSeriesReturns a new segment series with the segments reversed. This does not throwIncompatibleAddressExceptionsince all address series can reverse their segments.- Specified by:
reverseSegmentsin interfaceAddressSection- Specified by:
reverseSegmentsin interfaceAddressSegmentSeries- Specified by:
reverseSegmentsin interfaceIPAddressSegmentSeries- Specified by:
reverseSegmentsin classIPAddressSection- Returns:
-
getIterable
Description copied from interface:AddressComponentRangeUseful for using an instance in a "for-each loop". Otherwise just callAddressComponentRange.iterator()directly.- Specified by:
getIterablein interfaceAddressComponentRange- Specified by:
getIterablein interfaceAddressSection- Specified by:
getIterablein interfaceAddressSegmentSeries- Specified by:
getIterablein interfaceIPAddressSegmentSeries- Specified by:
getIterablein classIPAddressSection- Returns:
-
nonZeroHostIterator
Description copied from interface:IPAddressSegmentSeriesSimilar to the iterator, but series with a host of zero are skipped.- Specified by:
nonZeroHostIteratorin interfaceIPAddressSegmentSeries- Specified by:
nonZeroHostIteratorin classIPAddressSection- Returns:
-
iterator
Description copied from interface:AddressComponentRangeIterates through the individual address components.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, orAddressItem.getCount()for the count.- Specified by:
iteratorin interfaceAddressComponentRange- Specified by:
iteratorin interfaceAddressSection- Specified by:
iteratorin interfaceAddressSegmentSeries- Specified by:
iteratorin interfaceIPAddressSegmentSeries- Specified by:
iteratorin interfaceIterable<IPv4AddressSection>- Specified by:
iteratorin classIPAddressSection- Returns:
-
spliterator
Description copied from interface:AddressComponentRangePartitions and traverses through the individual address components.- Specified by:
spliteratorin interfaceAddressComponent- Specified by:
spliteratorin interfaceAddressComponentRange- Specified by:
spliteratorin interfaceAddressSection- Specified by:
spliteratorin interfaceAddressSegmentSeries- Specified by:
spliteratorin interfaceIPAddressSegmentSeries- Specified by:
spliteratorin interfaceIterable<IPv4AddressSection>- Specified by:
spliteratorin classIPAddressSection- Returns:
-
stream
Description copied from interface:AddressComponentRangeReturns a sequential stream of the individual address components. For a parallel stream, callBaseStream.parallel()on the returned stream.- Specified by:
streamin interfaceAddressComponentRange- Specified by:
streamin interfaceAddressSection- Specified by:
streamin interfaceAddressSegmentSeries- Specified by:
streamin interfaceIPAddressSegmentSeries- Specified by:
streamin classIPAddressSection- Returns:
-
prefixIterator
Description copied from interface:AddressSegmentSeriesIterates through the individual prefixes.If the series has no prefix length, then this is equivalent to
AddressSegmentSeries.iterator()- Specified by:
prefixIteratorin interfaceAddressSection- Specified by:
prefixIteratorin interfaceAddressSegmentSeries- Specified by:
prefixIteratorin interfaceIPAddressSegmentSeries- Specified by:
prefixIteratorin classIPAddressSection
-
prefixSpliterator
Description copied from interface:AddressSegmentSeriesPartitions and traverses through the individual prefixes for the prefix length of this series.- Specified by:
prefixSpliteratorin interfaceAddressSection- Specified by:
prefixSpliteratorin interfaceAddressSegmentSeries- Specified by:
prefixSpliteratorin interfaceIPAddressSegmentSeries- Specified by:
prefixSpliteratorin classIPAddressSection- Returns:
-
prefixStream
Description copied from interface:AddressSegmentSeriesReturns a sequential stream of the individual prefixes for the prefix length of this series. For a parallel stream, callBaseStream.parallel()on the returned stream.- Specified by:
prefixStreamin interfaceAddressSection- Specified by:
prefixStreamin interfaceAddressSegmentSeries- Specified by:
prefixStreamin interfaceIPAddressSegmentSeries- Specified by:
prefixStreamin classIPAddressSection- Returns:
-
prefixBlockIterator
Description copied from interface:AddressSegmentSeriesIterates through the individual prefix blocks.If the series has no prefix length, then this is equivalent to
AddressSegmentSeries.iterator()- Specified by:
prefixBlockIteratorin interfaceAddressSection- Specified by:
prefixBlockIteratorin interfaceAddressSegmentSeries- Specified by:
prefixBlockIteratorin interfaceIPAddressSegmentSeries- Specified by:
prefixBlockIteratorin classIPAddressSection
-
prefixBlockSpliterator
Description copied from interface:AddressSegmentSeriesPartitions and traverses through the individual prefix blocks for the prefix length of this series.- Specified by:
prefixBlockSpliteratorin interfaceAddressSection- Specified by:
prefixBlockSpliteratorin interfaceAddressSegmentSeries- Specified by:
prefixBlockSpliteratorin interfaceIPAddressSegmentSeries- Specified by:
prefixBlockSpliteratorin classIPAddressSection- Returns:
-
prefixBlockStream
Description copied from interface:AddressSegmentSeriesReturns a sequential stream of the individual prefix blocks for the prefix length of this series. For a parallel stream, callBaseStream.parallel()on the returned stream.- Specified by:
prefixBlockStreamin interfaceAddressSection- Specified by:
prefixBlockStreamin interfaceAddressSegmentSeries- Specified by:
prefixBlockStreamin interfaceIPAddressSegmentSeries- Specified by:
prefixBlockStreamin classIPAddressSection- Returns:
-
blockIterator
Description copied from interface:IPAddressSegmentSeriesIterates through series that can be obtained by iterating through all the upper segments up to the given segment count. Segments following remain the same in all iterated series.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
- Specified by:
blockIteratorin interfaceIPAddressSegmentSeries- Specified by:
blockIteratorin classIPAddressSection- Parameters:
segmentCount-- Returns:
-
blockSpliterator
Description copied from interface:IPAddressSegmentSeriesPartitions and traverses through the individual sequential blocks created from each of the individual values up to the given segment count.- Specified by:
blockSpliteratorin interfaceIPAddressSegmentSeries- Specified by:
blockSpliteratorin classIPAddressSection- Returns:
-
blockStream
Description copied from interface:IPAddressSegmentSeriesReturns a sequential stream of the individual blocks created from each of the individual values up to the given segment count. For a parallel stream, callBaseStream.parallel()on the returned stream.- Specified by:
blockStreamin interfaceIPAddressSegmentSeries- Specified by:
blockStreamin classIPAddressSection- Returns:
-
sequentialBlockIterator
Description copied from interface:IPAddressSegmentSeriesIterates through the sequential series that make up this series. Generally this means finding the count of segments for which the segments that follow are not full range, and then usingIPAddressSegmentSeries.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.- Specified by:
sequentialBlockIteratorin interfaceIPAddressSegmentSeries- Overrides:
sequentialBlockIteratorin classIPAddressSection- Returns:
-
sequentialBlockSpliterator
Description copied from interface:IPAddressSegmentSeriesPartitions and traverses through the individual sequential blocks.- Specified by:
sequentialBlockSpliteratorin interfaceIPAddressSegmentSeries- Overrides:
sequentialBlockSpliteratorin classIPAddressSection- Returns:
-
sequentialBlockStream
Description copied from interface:IPAddressSegmentSeriesReturns a sequential stream of the individual sequential blocks. For a parallel stream, callBaseStream.parallel()on the returned stream.Use
IPAddressSegmentSeries.getSequentialBlockCount()to get the count of streamed elements.- Specified by:
sequentialBlockStreamin interfaceIPAddressSegmentSeries- Overrides:
sequentialBlockStreamin classIPAddressSection- Returns:
-
segmentsNonZeroHostIterator
Description copied from interface:IPAddressSegmentSeriesSimilar to the segments iterator, but series with a host of zero are skipped.- Specified by:
segmentsNonZeroHostIteratorin interfaceIPAddressSegmentSeries- Returns:
-
segmentsIterator
Description copied from interface:AddressSegmentSeriesIterates through the individual segments.- Specified by:
segmentsIteratorin interfaceAddressSegmentSeries- Specified by:
segmentsIteratorin interfaceIPAddressSegmentSeries
-
segmentsSpliterator
public AddressComponentRangeSpliterator<IPv4AddressSection, IPv4AddressSegment[]> segmentsSpliterator()Description copied from interface:AddressSegmentSeriesPartitions and traverses through the individual segment arrays.- Specified by:
segmentsSpliteratorin interfaceAddressSegmentSeries- Specified by:
segmentsSpliteratorin interfaceIPAddressSegmentSeries- Returns:
-
segmentsStream
Description copied from interface:AddressSegmentSeriesReturns a sequential stream of the individual segment arrays. For a parallel stream, callBaseStream.parallel()on the returned stream.- Specified by:
segmentsStreamin interfaceAddressSegmentSeries- Specified by:
segmentsStreamin interfaceIPAddressSegmentSeries- Returns:
-
incrementBoundary
Description copied from interface:AddressSegmentSeriesIf the given increment is positive, adds the value to the upper series (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.
- Specified by:
incrementBoundaryin interfaceAddressSection- Specified by:
incrementBoundaryin interfaceAddressSegmentSeries- Specified by:
incrementBoundaryin interfaceIPAddressSegmentSeries- Specified by:
incrementBoundaryin classIPAddressSection- Parameters:
increment-- Returns:
-
increment
Description copied from interface:AddressSegmentSeriesReturns 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.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.
- Specified by:
incrementin interfaceAddressSection- Specified by:
incrementin interfaceAddressSegmentSeries- Specified by:
incrementin interfaceIPAddressSegmentSeries- Specified by:
incrementin classIPAddressSection- Parameters:
increment-- Returns:
-
getIPv4Count
public long getIPv4Count(boolean excludeZeroHosts) -
getIPv4PrefixCount
public long getIPv4PrefixCount(int prefixLength) -
getPrefixCount
Description copied from interface:AddressItemThe count of the number of distinct values within the prefix part of the address item, the bits that appear within the prefix length.- Specified by:
getPrefixCountin interfaceAddressDivisionSeries- Specified by:
getPrefixCountin interfaceAddressItem- Parameters:
prefixLength-- Returns:
-
getIPv4PrefixCount
public long getIPv4PrefixCount() -
getDivision
- Specified by:
getDivisionin interfaceAddressDivisionSeries- Specified by:
getDivisionin interfaceAddressStringDivisionSeries- Specified by:
getDivisionin interfaceIPAddressDivisionSeries- Specified by:
getDivisionin interfaceIPAddressStringDivisionSeries- Overrides:
getDivisionin classIPAddressSection- Returns:
- the given division in this series. The first is at index 0.
-
getSegment
Description copied from interface:AddressSegmentSeriesReturns the segment from this series at the given index. The first segment is at index 0. A segment is an address division, seeAddressDivisionSeries.getDivision(int), the difference being that all segments in a given series are the same bit count, while divisions can have variable length.- Specified by:
getSegmentin interfaceAddressSegmentSeries- Specified by:
getSegmentin interfaceIPAddressSegmentSeries- Overrides:
getSegmentin classIPAddressSection- Returns:
-
getSegments
-
getSegments
-
getBitsPerSegment
public int getBitsPerSegment()Description copied from interface:AddressSegmentSeriesReturns the number of bits comprising each segment in this series. Segments in the same series are equal length.- Specified by:
getBitsPerSegmentin interfaceAddressSegmentSeries- Returns:
-
getBytesPerSegment
public int getBytesPerSegment()Description copied from interface:AddressSegmentSeriesReturns the number of bytes comprising each segment in this series. Segments in the same series are equal length.- Specified by:
getBytesPerSegmentin interfaceAddressSegmentSeries- Returns:
-
getBitCount
public int getBitCount()Description copied from interface:AddressItemProvides the number of bits comprising this address item- Specified by:
getBitCountin interfaceAddressDivisionSeries- Specified by:
getBitCountin interfaceAddressItem- Overrides:
getBitCountin classIPAddressSection- Returns:
- the number of bits
-
getByteCount
public int getByteCount()Description copied from interface:AddressItemProvides the number of bytes required for this address item, rounding up if the bit count is not a multiple of 8- Specified by:
getByteCountin interfaceAddressItem- Overrides:
getByteCountin classIPAddressSection- Returns:
- the number of bytes
-
isIPv4
public boolean isIPv4()- Overrides:
isIPv4in classIPAddressSection
-
getIPVersion
Description copied from interface:IPAddressSegmentSeriesReturns the version of this segment series- Specified by:
getIPVersionin interfaceIPAddressSegmentSeries- Returns:
-
matchesWithMask
Description copied from class:IPAddressSectionApplies the mask to this address section and then compares values with the given address section- Overrides:
matchesWithMaskin classIPAddressSection- Parameters:
other-mask-- Returns:
-
equals
Description copied from class:AddressDivisionGroupingBaseTwo groupings are equal if: - they match type/version (ipv4, ipv6, mac, or a specific grouping class) - they match division counts - each division matches bit counts - each division matches their specific grouping class - each division matches values Prefix lengths, for those groupings and/or divisionsS that have them, are ignored.- Overrides:
equalsin classIPAddressDivisionGrouping
-
overlaps
Description copied from interface:AddressSectionDetermines if one section overlaps another.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.
- Specified by:
overlapsin interfaceAddressSection- Parameters:
other-- Returns:
- whether this section overlaps the given address section
-
contains
Description copied from interface:AddressSectionDetermines if one section contains another.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.
- Specified by:
containsin interfaceAddressSection- Overrides:
containsin classIPAddressSection- Parameters:
other-- Returns:
- whether this subnet contains the given address section
-
enumerateIPv4
Indicates where an address section sits relative to the ordering of individual address sections within this section.Equivalent to
enumerate(AddressSection)but returns a Long rather than a BigInteger. -
enumerate
Description copied from interface:AddressSectionIndicates where an address section sits relative to the ordering of individual address sections within this section.Determines how many address section elements precede the given address section element, if the given address section is within this address section. If above the range, it is the distance to the upper boundary added to the address section count less one, and if below the range, the distance to the lower boundary.
In other words, if the given address section is not in this section but above it, returns the number of individual address sections preceding the given address section from the upper section boundary, added to one less than the total number of individual address sections within. If the given address section is not in this section but below it, returns the number of individual address sections following the given address section to the lower section boundary.
enumerate returns null when the argument is a multi-valued section. The argument must be an individual address section.
When this address section is also single-valued, the returned value is the distance (difference) between this address section and the argument address section.
enumerate is the inverse of the increment method:
- section.enumerate(section.increment(inc)) = inc
- section.increment(section.enumerate(individualSection)) = individualSection
- Specified by:
enumeratein interfaceAddressSection
-
prefixEquals
Description copied from interface:AddressSectionDetermines if the argument section matches this section up to the prefix length of this section.The entire prefix of this section must be present in the other section to be comparable.
For sections which are aware of their position in an address (IPv6 and MAC), the argument section must have the same or an earlier position in the address to match all prefix segments of this section, and the matching is lined up relative to the position.
- Specified by:
prefixEqualsin interfaceAddressSection- Parameters:
other-- Returns:
- whether the argument section has the same address section prefix as this
-
prefixContains
Description copied from class:IPAddressSectionReturns whether the prefix of this address contains all values of the same bits in the given address or subnet- Specified by:
prefixContainsin classIPAddressSection- Parameters:
other-- Returns:
-
append
-
insert
-
replace
Replace the segments of this section starting at the given index with the given replacement segments- Parameters:
index-other-- Returns:
-
appendToNetwork
-
replace
public IPv4AddressSection replace(int startIndex, int endIndex, IPv4AddressSection replacement, int replacementStartIndex, int replacementEndIndex) Replaces segments starting from startIndex and ending before endIndex with the segments starting at replacementStartIndex and ending before replacementEndIndex from the replacement section- Parameters:
startIndex-endIndex-replacement-replacementStartIndex-replacementEndIndex-- Returns:
- Throws:
IndexOutOfBoundsExceptionIncompatibleAddressException- if the resulting section would exceed the maximum segment count for this address type and version
-
intersect
Produces the subnet sections whose individual sections are found in both this and the given argument.This is also known as the conjunction of the two sets of address sections.
- Parameters:
other-- Returns:
- the section containing the sections found in both this and the given subnet sections
- Throws:
SizeMismatchException
-
subtract
Subtract the given subnet from this subnet, returning an array of sections for the result (the subnets will not be contiguous so an array is required).Computes the subnet difference, the set of addresses in this address section but not in the provided section. This is also known as the relative complement of the given argument in this subnet.
Keep in mind this is set subtraction, not subtraction of segment values. We have a subnet of addresses and we are removing some of those addresses.
- Parameters:
other-- Returns:
- the difference, or null if there are no remaining sections
- Throws:
SizeMismatchException- if the two sections are different sizes
-
getNetwork
Description copied from interface:AddressComponentReturns the network object for components of the same version (eg IPv4, IPv6 and MAC each have their own network object)- Specified by:
getNetworkin interfaceAddressComponent- Specified by:
getNetworkin interfaceIPAddressSegmentSeries- Specified by:
getNetworkin interfaceIPAddressStringDivisionSeries- Overrides:
getNetworkin classIPAddressDivisionGrouping- Returns:
-
adjustPrefixBySegment
Description copied from interface:AddressSegmentSeriesIncreases or decreases prefix length to the next segment boundary.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, useAddressSegmentSeries.adjustPrefixBySegment(boolean, boolean)with second arg false.- Specified by:
adjustPrefixBySegmentin interfaceAddressSection- Specified by:
adjustPrefixBySegmentin interfaceAddressSegmentSeries- Specified by:
adjustPrefixBySegmentin interfaceIPAddressSegmentSeries- Specified by:
adjustPrefixBySegmentin classIPAddressSection- Parameters:
nextSegment- whether to move prefix to previous or following segment boundary- Returns:
-
adjustPrefixBySegment
Description copied from interface:AddressSegmentSeriesIncreases or decreases prefix length to the next segment boundary.- Specified by:
adjustPrefixBySegmentin interfaceAddressSection- Specified by:
adjustPrefixBySegmentin interfaceAddressSegmentSeries- Specified by:
adjustPrefixBySegmentin interfaceIPAddressSegmentSeries- Overrides:
adjustPrefixBySegmentin classIPAddressSection- Parameters:
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 values- Returns:
-
adjustPrefixLength
Description copied from interface:AddressSegmentSeriesIncreases or decreases prefix length by the given increment.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.- Specified by:
adjustPrefixLengthin interfaceAddressSection- Specified by:
adjustPrefixLengthin interfaceAddressSegmentSeries- Specified by:
adjustPrefixLengthin interfaceIPAddressSegmentSeries- Specified by:
adjustPrefixLengthin classIPAddressSection- Parameters:
adjustment-- Returns:
-
adjustPrefixLength
Description copied from interface:AddressSegmentSeriesIncreases or decreases prefix length by the given increment.- Specified by:
adjustPrefixLengthin interfaceAddressSection- Specified by:
adjustPrefixLengthin interfaceAddressSegmentSeries- Specified by:
adjustPrefixLengthin interfaceIPAddressSegmentSeries- Specified by:
adjustPrefixLengthin classIPAddressSection- Parameters:
adjustment- the incrementzeroed- whether the bits that move from one side of the prefix to the other become zero or retain their original values- Returns:
-
applyPrefixLength
Deprecated.Description copied from interface:AddressSegmentSeriesApplies the given prefix length to create a new segment series.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.
- Specified by:
applyPrefixLengthin interfaceAddressSection- Specified by:
applyPrefixLengthin interfaceAddressSegmentSeries- Specified by:
applyPrefixLengthin interfaceIPAddressSegmentSeries- Specified by:
applyPrefixLengthin classIPAddressSection- Parameters:
networkPrefixLength-- Returns:
- See Also:
-
setPrefixLength
Description copied from interface:AddressSegmentSeriesSets the prefix length.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.
- Specified by:
setPrefixLengthin interfaceAddressSection- Specified by:
setPrefixLengthin interfaceAddressSegmentSeries- Specified by:
setPrefixLengthin interfaceIPAddressSegmentSeries- Specified by:
setPrefixLengthin classIPAddressSection- Parameters:
networkPrefixLength-- Returns:
-
setPrefixLength
Description copied from interface:AddressSegmentSeriesSets the prefix length.When the prefix is extended beyond the segment series boundary, it is removed.
- Specified by:
setPrefixLengthin interfaceAddressSection- Specified by:
setPrefixLengthin interfaceAddressSegmentSeries- Specified by:
setPrefixLengthin interfaceIPAddressSegmentSeries- Specified by:
setPrefixLengthin classIPAddressSection- Parameters:
withZeros- 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.- Returns:
-
setPrefixLength
public IPv4AddressSection setPrefixLength(int networkPrefixLength, boolean withZeros, boolean zeroHostIsBlock) throws PrefixLenException Description copied from class:IPAddressSectionSets 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. The latter behaviour only applies to the default prefix handling configuration, PREFIXED_ZERO_HOSTS_ARE_SUBNETS. The methodsIPAddressSection.setPrefixLength(int, boolean)andIPAddressSection.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.
- Specified by:
setPrefixLengthin classIPAddressSection- Parameters:
networkPrefixLength-withZeros-zeroHostIsBlock-- Returns:
- Throws:
PrefixLenException
-
removePrefixLength
Deprecated.Description copied from interface:AddressSegmentSeriesRemoves the prefix length while zeroing out the bits beyond the prefix.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)
- Specified by:
removePrefixLengthin interfaceAddressSection- Specified by:
removePrefixLengthin interfaceAddressSegmentSeries- Specified by:
removePrefixLengthin interfaceIPAddressSegmentSeries- Specified by:
removePrefixLengthin classIPAddressSection- Returns:
- See Also:
-
withoutPrefixLength
Description copied from interface:AddressSegmentSeriesProvides the same address with no prefix. The values remain unchanged.Use
AddressSegmentSeries.removePrefixLength()as an alternative that deletes the host at the same time by zeroing the host values.- Specified by:
withoutPrefixLengthin interfaceAddressSection- Specified by:
withoutPrefixLengthin interfaceAddressSegmentSeries- Specified by:
withoutPrefixLengthin interfaceIPAddressSegmentSeries- Specified by:
withoutPrefixLengthin classIPAddressSection
-
removePrefixLength
Deprecated.Description copied from interface:AddressSegmentSeriesRemoves the prefix length. If zeroed is false, the bits that were host bits do not become zero, unlikeAddressSegmentSeries.removePrefixLength()- Specified by:
removePrefixLengthin interfaceAddressSection- Specified by:
removePrefixLengthin interfaceAddressSegmentSeries- Specified by:
removePrefixLengthin interfaceIPAddressSegmentSeries- Specified by:
removePrefixLengthin classIPAddressSection- Parameters:
zeroed- whether the bits outside the prefix become zero- Returns:
-
toZeroHost
Description copied from interface:IPAddressSegmentSeriesReturns the segment series with a host of zero, the host being the bits following the prefix length. If the series has no prefix length, then it returns an all-zero series.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()isAddressNetwork.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- Specified by:
toZeroHostin interfaceIPAddressSegmentSeries- Specified by:
toZeroHostin classIPAddressSection- Returns:
- Throws:
IncompatibleAddressException- See Also:
-
toZeroHost
Description copied from interface:IPAddressSegmentSeriesProduces the series with host values of 0 for the given prefix length.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- Specified by:
toZeroHostin interfaceIPAddressSegmentSeries- Specified by:
toZeroHostin classIPAddressSection- Parameters:
prefixLength-- Returns:
-
toZeroNetwork
Description copied from interface:IPAddressSegmentSeriesReturns the segment series with a network of zero, the network being the bits within the prefix length. If the series has no prefix length, then it returns an all-zero series.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()isAddressNetwork.PrefixConfiguration.ALL_PREFIXED_ADDRESSES_ARE_SUBNETS.- Specified by:
toZeroNetworkin interfaceIPAddressSegmentSeries- Specified by:
toZeroNetworkin classIPAddressSection- Returns:
- See Also:
-
toMaxHost
Description copied from interface:IPAddressSegmentSeriesReturns the segment series with a host of all ones. If the series has no prefix length, then it returns an all-ones series.The resultant series will have the same prefix length if
AddressNetwork.getPrefixConfiguration()is notAddressNetwork.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- Specified by:
toMaxHostin interfaceIPAddressSegmentSeries- Specified by:
toMaxHostin classIPAddressSection- Returns:
- Throws:
IncompatibleAddressException
-
createMaxHost
-
toMaxHost
Description copied from interface:IPAddressSegmentSeriesProduces the series with host values of all one bits for the given prefix length.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- Specified by:
toMaxHostin interfaceIPAddressSegmentSeries- Specified by:
toMaxHostin classIPAddressSection- Parameters:
prefixLength-- Returns:
-
mask
public IPv4AddressSection mask(IPv4AddressSection mask, boolean retainPrefix) throws IncompatibleAddressException, SizeMismatchException Does the bitwise conjunction with this address. Useful when subnetting.- Parameters:
mask-retainPrefix- whether to drop the prefix- Returns:
- Throws:
IncompatibleAddressExceptionSizeMismatchException
-
mask
public IPv4AddressSection mask(IPv4AddressSection mask) throws IncompatibleAddressException, SizeMismatchException Equivalent tomask(IPv4AddressSection, boolean)with the second argument as false. -
maskNetwork
public IPv4AddressSection maskNetwork(IPv4AddressSection mask, int networkPrefixLength) throws IncompatibleAddressException, PrefixLenException, SizeMismatchException Produces the bitwise conjunction of the given mask with the network section of the address as indicated by the given prefix length. Useful for subnetting. Once you have zeroed a section of the network you can insert bits usingbitwiseOr(IPv4AddressSection)orreplace(int, IPv4AddressSection)- Parameters:
mask-networkPrefixLength-- Returns:
- Throws:
IncompatibleAddressExceptionPrefixLenExceptionSizeMismatchException
-
bitwiseOr
Equivalent tobitwiseOr(IPv4AddressSection, boolean)with the second argument as false.- Throws:
IncompatibleAddressException
-
bitwiseOr
public IPv4AddressSection bitwiseOr(IPv4AddressSection mask, boolean retainPrefix) throws IncompatibleAddressException, SizeMismatchException Does the bitwise disjunction with this address section. Useful when subnetting. Similar tomask(IPv4AddressSection)which does the bitwise conjunction.- Parameters:
retainPrefix- whether the result will retain the same prefix length as this.- Returns:
- Throws:
IncompatibleAddressExceptionSizeMismatchException
-
bitwiseOrNetwork
public IPv4AddressSection bitwiseOrNetwork(IPv4AddressSection mask, int networkPrefixLength) throws IncompatibleAddressException, SizeMismatchException Does the bitwise disjunction with this address section. Useful when subnetting. Similar tomaskNetwork(IPv4AddressSection, int)which does the bitwise conjunction.Any existing prefix length is dropped for the new prefix length and the disjunction is applied up to the end the new prefix length.
- Parameters:
mask-- Returns:
- Throws:
IncompatibleAddressExceptionSizeMismatchException
-
getHostMask
Description copied from interface:IPAddressSegmentSeriesReturns the host mask associated with the CIDR network prefix length of this series. If this series has no prefix length, then the whole series is considered a host and the all ones host mask is returned.- Specified by:
getHostMaskin interfaceIPAddressSegmentSeries- Overrides:
getHostMaskin classIPAddressSection- Returns:
-
getNetworkMask
Description copied from interface:IPAddressSegmentSeriesReturns the network mask associated with the CIDR network prefix length of this series. If this series has no prefix length, then the whole series is considered network and the all ones network mask is returned.- Specified by:
getNetworkMaskin interfaceIPAddressSegmentSeries- Overrides:
getNetworkMaskin classIPAddressSection- Returns:
-
getNetworkSection
Description copied from interface:IPAddressSegmentSeriesReturns 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.- Specified by:
getNetworkSectionin interfaceIPAddressSegmentSeries- Returns:
-
getNetworkSection
Description copied from interface:IPAddressSegmentSeriesReturns the network section of the series. The returned section will have only as many segments as needed as indicated by networkPrefixLength. It will have networkPrefixLength as its associated prefix length, unless this address already has a smaller prefix length, in which case the existing prefix length is retained.- Specified by:
getNetworkSectionin interfaceIPAddressSegmentSeries- Parameters:
networkPrefixLength-- Returns:
- Throws:
PrefixLenException
-
getNetworkSection
public IPv4AddressSection getNetworkSection(int networkPrefixLength, boolean withPrefixLength) throws PrefixLenException Description copied from interface:IPAddressSegmentSeriesReturns the network section of the series. The returned section will have only as many segments as needed as indicated by networkPrefixLength. If withPrefixLength is true, it will have networkPrefixLength as its associated prefix length, unless this series already has a smaller prefix length, in which case the existing prefix length is retained.- Specified by:
getNetworkSectionin interfaceIPAddressSegmentSeries- Parameters:
networkPrefixLength-withPrefixLength- whether the resulting section will have networkPrefixLength as the associated prefix length or not- Returns:
- Throws:
PrefixLenException
-
getHostSection
Description copied from interface:IPAddressSegmentSeriesReturns the host section of the series. The returned section will have only as many segments as needed as determined by the existing CIDR network prefix length. If this series has no CIDR prefix length, the returned host section will be the full section associated with a prefix length of 0.- Specified by:
getHostSectionin interfaceIPAddressSegmentSeries- Returns:
-
getHostSection
Description copied from interface:IPAddressSegmentSeriesReturns the host section of the address as indicated by the network prefix length provided. The returned section will have only as many segments as needed to hold the host as indicated by the provided network prefix length.- Specified by:
getHostSectionin interfaceIPAddressSegmentSeries- Parameters:
networkPrefixLength-- Returns:
- Throws:
PrefixLenException
-
toPrefixBlock
Description copied from interface:IPAddressSegmentSeriesIf this series has a prefix length, returns the subnet block for that prefix. If this series has no prefix length, this series is returned.- Specified by:
toPrefixBlockin interfaceAddressSection- Specified by:
toPrefixBlockin interfaceAddressSegmentSeries- Specified by:
toPrefixBlockin interfaceIPAddressSegmentSeries- Specified by:
toPrefixBlockin classIPAddressSection- Returns:
- the subnet block for the prefix length
-
toPrefixBlock
Description copied from interface:IPAddressSegmentSeriesReturns the segment series of the same length that spans all hosts. The network prefix length will be the one provided, and the network values will match the same of this series.- Specified by:
toPrefixBlockin interfaceIPAddressSegmentSeries- Specified by:
toPrefixBlockin classIPAddressSection- Parameters:
networkPrefixLength-- Returns:
- Throws:
PrefixLenException
-
assignPrefixForSingleBlock
Description copied from class:IPAddressSectionReturns 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.If no such prefix length exists, returns null.
If this address represents just a single address, "this" is returned.
- Specified by:
assignPrefixForSingleBlockin interfaceIPAddressSegmentSeries- Overrides:
assignPrefixForSingleBlockin classIPAddressSection- Returns:
- See Also:
-
assignMinPrefixForBlock
Description copied from class:IPAddressSectionConstructs 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.- Specified by:
assignMinPrefixForBlockin interfaceIPAddressSegmentSeries- Overrides:
assignMinPrefixForBlockin classIPAddressSection- Returns:
- See Also:
-
coverWithPrefixBlock
Description copied from interface:IPAddressSegmentSeriesReturns the minimal-size prefix block that covers all the values in this series. The resulting block will have a larger series count than this, unless this series is already a prefix block.- Specified by:
coverWithPrefixBlockin interfaceIPAddressSegmentSeries- Specified by:
coverWithPrefixBlockin classIPAddressSection
-
coverWithPrefixBlock
public IPv4AddressSection coverWithPrefixBlock(IPv4AddressSection other) throws AddressConversionException - Throws:
AddressConversionException
-
spanWithPrefixBlocks
Produces an array of prefix blocks that spans the same set of values.Unlike
spanWithPrefixBlocks(IPv4AddressSection)this method only includes blocks that are a part of this section.- Specified by:
spanWithPrefixBlocksin interfaceIPAddressSegmentSeries
-
spanWithPrefixBlocks
Produces the list of prefix block subnets that span from this series to the given series.- Parameters:
other-- Returns:
-
spanWithRangedSegments
Deprecated.- Parameters:
other-- Returns:
-
spanWithSequentialBlocks
Produces an array of blocks that are sequential that cover the same set of sections as this.This array can be shorter than that produced by
spanWithPrefixBlocks()and is never longer.Unlike
spanWithSequentialBlocks(IPv4AddressSection)this method only includes values that are a part of this section.- Specified by:
spanWithSequentialBlocksin interfaceIPAddressSegmentSeries- Throws:
AddressConversionException
-
spanWithSequentialBlocks
Produces a list of range subnets that span from this series to the given series.- Parameters:
other-- Returns:
-
mergePrefixBlocks
@Deprecated public IPv4AddressSection[] mergePrefixBlocks(IPv4AddressSection... sections) throws SizeMismatchException Deprecated.- Parameters:
sections-- Returns:
- Throws:
SizeMismatchException
-
mergeToPrefixBlocks
public IPv4AddressSection[] mergeToPrefixBlocks(IPv4AddressSection... sections) throws SizeMismatchException Merges this with the list of sections to produce the smallest array of prefix blocks.The resulting array is sorted from lowest address value to highest, regardless of the size of each prefix block.
In version 5.3.1 and earlier, the result was sorted from single address to smallest blocks to largest blocks. For that ordering, sort with
IPAddressSegmentSeries.getPrefixLenComparator():
Arrays.sort(result, IPAddressSegmentSeries.getPrefixLenComparator());- Parameters:
sections- the sections to merge with this- Returns:
- Throws:
SizeMismatchException
-
mergeToSequentialBlocks
public IPv4AddressSection[] mergeToSequentialBlocks(IPv4AddressSection... sections) throws SizeMismatchException Merges this with the list of sections to produce the smallest array of sequential block subnets.The resulting array is sorted by lower address, regardless of the size of each prefix block.
In version 5.3.1 and earlier, the result was sorted from single address to smallest blocks to largest blocks. For that ordering, sort with
IPAddressSegmentSeries.getPrefixLenComparator():
Arrays.sort(result, IPAddressSegmentSeries.getPrefixLenComparator());- Parameters:
sections- the sections to merge with this- Returns:
- Throws:
SizeMismatchException
-
toCanonicalString
This produces a canonical string. If this has a prefix length, that will be included in the string.- Specified by:
toCanonicalStringin interfaceAddressSegmentSeries- Returns:
-
toFullString
This produces a string with no compressed segments and all segments of full length, which is 3 characters for IPv4 segments.- Specified by:
toFullStringin interfaceIPAddressSegmentSeries
-
toCompressedString
The shortest string for IPv4 addresses is the same as the canonical string.- Specified by:
toCompressedStringin interfaceAddressSegmentSeries- Returns:
-
toNormalizedString
The normalized string returned by this method is consistent with java.net.Inet4Address, and is the same astoCanonicalString().- Specified by:
toNormalizedStringin interfaceAddressComponent- Returns:
-
toCompressedWildcardString
Description copied from interface:IPAddressSegmentSeriesThis is similar to toNormalizedWildcardString, avoiding the CIDR prefix, but with compression as well.- Specified by:
toCompressedWildcardStringin interfaceIPAddressSegmentSeries
-
toSubnetString
Description copied from interface:IPAddressSegmentSeriesProduces a consistent subnet string. In the case of IPv4, this means that wildcards are used instead of a network prefix. In the case of IPv6, a prefix will be used and the host section will be compressed with ::.- Specified by:
toSubnetStringin interfaceIPAddressSegmentSeries
-
toPrefixLengthString
Description copied from interface:IPAddressSegmentSeriesReturns a string with a CIDR prefix length if this section has a network prefix length. For IPv6, the host section will be compressed with ::, for IPv4 the host section will be zeros.- Specified by:
toPrefixLengthStringin interfaceIPAddressSegmentSeries- Returns:
-
toInetAtonString
-
toInetAtonString
public String toInetAtonString(IPv4Address.inet_aton_radix radix, int joinedCount) throws IncompatibleAddressException - Throws:
IncompatibleAddressException
-
toNormalizedWildcardString
Description copied from interface:IPAddressSegmentSeriesThis produces a string similar to the normalized string and avoids the CIDR prefix. CIDR addresses will be shown with wildcards and ranges instead of using the CIDR prefix notation.- Specified by:
toNormalizedWildcardStringin interfaceIPAddressSegmentSeries
-
toCanonicalWildcardString
Description copied from interface:IPAddressSegmentSeriesThis produces a string similar to the canonical string and avoids the CIDR prefix. Addresses with a network prefix length will be shown with wildcards and ranges instead of using the CIDR prefix length notation. IPv6 addresses will be compressed according to the canonical representation.- Specified by:
toCanonicalWildcardStringin interfaceIPAddressSegmentSeries
-
toSQLWildcardString
Description copied from interface:IPAddressSegmentSeriesThis is the same as the string from toNormalizedWildcardString except that it usesAddress.SEGMENT_SQL_WILDCARDinstead ofAddress.SEGMENT_WILDCARDand also usesAddress.SEGMENT_SQL_SINGLE_WILDCARD- Specified by:
toSQLWildcardStringin interfaceIPAddressSegmentSeries
-
toReverseDNSLookupString
Description copied from interface:IPAddressSegmentSeriesGenerates 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- Specified by:
toReverseDNSLookupStringin interfaceIPAddressSegmentSeries- Returns:
-
toSegmentedBinaryString
Description copied from interface:IPAddressSegmentSeriesWrites this IP address segment series as a segments of binary values preceded by the "0b" prefix.- Specified by:
toSegmentedBinaryStringin interfaceIPAddressSegmentSeries
-
toNormalizedString
public String toNormalizedString(IPAddressSection.IPStringOptions stringParams, int joinCount) throws IncompatibleAddressException - Throws:
IncompatibleAddressException
-
toJoinedSegments
-
toAllStringCollection
Description copied from class:IPAddressSectionUse this method with care... a single IPv6 address can have thousands of string representations. Examples: "::" has 1297 such variations, but only 9 are considered standard "a:b:c:0:d:e:f:1" has 1920 variations, but only 12 are standard Variations included in this method: -all standard variations -choosing specific segments for full leading zeros (::a:b can be ::000a:b, ::a:000b, or ::000a:000b) -choosing which zero-segments to compress (0:0:a:: can be ::a:0:0:0:0:0 or 0:0:a::) -mixed representation (1:2:3:4:5:6:1.2.3.4) -all combinations of such variations Variations omitted from this method: -mixed case of a-f, which you can easily handle yourself with String.equalsIgnoreCase -adding a variable number of leading zeros (::a can be ::0a, ::00a, ::000a) -choosing any number of zero-segments anywhere to compress (:: can be 0:0:0::0:0)- Overrides:
toAllStringCollectionin classIPAddressSection- Returns:
-
toStandardStringCollection
Description copied from class:IPAddressSectionReturns 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- Overrides:
toStandardStringCollectionin classIPAddressSection- Returns:
-
toDatabaseSearchStringCollection
Description copied from class:IPAddressSectionReturns 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- Overrides:
toDatabaseSearchStringCollectionin classIPAddressSection- Returns:
-
toStringCollection
public IPAddressPartStringCollection toStringCollection(IPAddressSection.IPStringBuilderOptions opts) - Specified by:
toStringCollectionin interfaceIPAddressSegmentSeries
-
toStringCollection
public IPAddressPartStringCollection toStringCollection(IPv4AddressSection.IPv4StringBuilderOptions opts) -
getParts
Description copied from class:IPAddressSectionGet all representations of this address including this IPAddressSection. This includes:- alternative segment groupings expressed as
IPAddressDivisionGrouping - conversions to IPv6, and alternative representations of those IPv6 addresses
- Overrides:
getPartsin classIPAddressSection- Parameters:
options-- Returns:
- alternative segment groupings expressed as
-
getParts
public IPAddressStringDivisionSeries[] getParts(IPv4AddressSection.IPv4StringBuilderOptions options)
-
mergeToPrefixBlocks(IPv4AddressSection...)