- All Implemented Interfaces:
AddressComponent
,AddressSegment
,AddressComponentRange
,AddressGenericDivision
,AddressItem
,AddressItemRange
,IPAddressGenericDivision
,AddressStringDivision
,IPAddressStringDivision
,Serializable
,Comparable<AddressItem>
- Direct Known Subclasses:
IPv4AddressSegment
,IPv6AddressSegment
- Author:
- sfoley
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class inet.ipaddr.format.standard.AddressDivision
AddressDivision.BitwiseOrResult, AddressDivision.MaskResult
-
Method Summary
Modifier and TypeMethodDescriptionbitwiseOrRange
(int maskValue) static int
getBitCount
(IPAddress.IPVersion version) static int
getByteCount
(IPAddress.IPVersion version) static int
long
returns the lower value as a long, although for individual segmentsgetSegmentValue()
provides the same value as an intlong
abstract IPAddress.IPVersion
abstract Iterable
<? extends IPAddressSegment> Useful for using an instance in a "for-each loop".abstract IPAddressSegment
getLower()
If this segment represents a range of values, returns a segment representing just the lowest value in the range, otherwise returns this.static int
getMaxSegmentValue
(IPAddress.IPVersion version) long
int
Returns the smallest prefix length possible such that this item includes the block of all values for that prefix length.abstract IPAddressNetwork
<?, ?, ?, ?, ?> Returns the network object for components of the same version (eg IPv4, IPv6 and MAC each have their own network object)int
Counts the number of prefixes in this address segment.int
returns the lower valueabstract IPAddressSegment
getUpper()
If this segment represents a range of values, returns a segment representing just the highest value in the range, otherwise returns this.long
returns the lower upper value as a long, although for individual segmentsgetUpperSegmentValue()
provides the same value as an intint
returns the upper valueint
int
hashCode()
boolean
Returns whether this item includes the maximum possible value for the address type or version within its rangeboolean
Returns whether this item includes the value of zero within its rangeboolean
isBoundedBy
(int value) Returns true if the possible values of this division fall below the given value.boolean
isIPv4()
boolean
isIPv6()
boolean
Whether this represents multiple potential values (eg a prefixed address or a segment representing a range of values)boolean
Returns whether the division range includes the block of values for its prefix lengthabstract Iterator
<? extends IPAddressSegment> iterator()
Iterates through the individual address components.maskRange
(int maskValue) boolean
matches
(int value) boolean
matchesWithMask
(int value, int mask) boolean
matchesWithMask
(int lowerValue, int upperValue, int mask) boolean
matchesWithPrefixMask
(int value, Integer segmentPrefixLength) abstract Iterator
<? extends IPAddressSegment> Iterates through the individual prefix blocks.abstract Iterator
<? extends IPAddressSegment> prefixBlockIterator
(int prefixLength) Iterates through the individual prefix blocks according to the given segment prefix length.abstract AddressComponentSpliterator
<? extends IPAddressSegment> Partitions and traverses through the individual prefix blocks of this segment for its prefix length.abstract AddressComponentSpliterator
<? extends IPAddressSegment> prefixBlockSpliterator
(int prefixLength) Partitions and traverses through the individual prefix blocks for the given prefix length.abstract Stream
<? extends IPAddressSegment> Returns a sequential stream of the individual prefix blocks of this segment.abstract Stream
<? extends IPAddressSegment> prefixBlockStream
(int prefixLength) Returns a sequential stream of the individual prefix blocks for the given prefix length.boolean
prefixContains
(IPAddressSegment other) Using the prefix length of this segment, or the whole segment if it has no prefix length, returns whether the prefix bit value ranges contain the same bits of the given segment.boolean
prefixContains
(IPAddressSegment other, int prefixLength) Returns whether the given prefix bit value ranges contain the same bits of the given segment.boolean
prefixEquals
(AddressSegment other, int prefixLength) Returns whether the given prefix bits match the same bits of the given segment.boolean
prefixEquals
(IPAddressSegment other) abstract Iterator
<? extends IPAddressSegment> Iterates through the individual prefixes.abstract AddressComponentSpliterator
<? extends IPAddressSegment> Partitions and traverses through the individual prefixes of this segment for its prefix length.abstract Stream
<? extends IPAddressSegment> Returns a sequential stream of the individual prefixes of this segment.abstract IPAddressSegment
Deprecated.abstract IPAddressSegment
removePrefixLength
(boolean zeroed) Deprecated.usetoZeroHost()
andwithoutPrefixLength()
abstract IPAddressSegment
reverseBits
(boolean perByte) Returns a new AddressComponent with the bits reversed.abstract IPAddressSegment
Returns an AddressComponent with the bytes reversed.abstract AddressComponentSpliterator
<? extends IPAddressSegment> Partitions and traverses through the individual address components.abstract Stream
<? extends IPAddressSegment> stream()
Returns a sequential stream of the individual address components.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 IPAddressSegment
toHostSegment
(Integer segmentPrefixLength) used by getHostSection, seeIPAddressSegmentSeries.getHostSection(int)
toNetworkSegment
(Integer segmentPrefixLength) used by constructors of IPAddressSection, seeIPAddressSegmentSeries.getNetworkSection(int, boolean)
abstract IPAddressSegment
toNetworkSegment
(Integer segmentPrefixLength, boolean withPrefixLength) used by getNetworkSection and by constructors of IPAddressSection, seeIPAddressSegmentSeries.getNetworkSection(int, boolean)
Produces a string that is consistent for all address components of the same type and version, and is also similar to the canonical stringAddressSegmentSeries.toCanonicalString()
inAddressComponent
instances that are alsoAddressSegmentSeries
instances.abstract IPAddressSegment
Returns a segment with the same network bits as this segment, but with the host bits changed to 0.abstract IPAddressSegment
Returns a segment with the same values but without a prefix length.Methods inherited from class inet.ipaddr.format.standard.IPAddressDivision
containsPrefixBlock, containsSinglePrefixBlock, getBlockMaskPrefixLength, getDivisionPrefixLength, getLeadingBitCount, getPrefixAdjustedRangeString, getString, getTrailingBitCount, getWildcardString, isPrefixed, isSinglePrefixBlock, matchesWithPrefixMask
Methods inherited from class inet.ipaddr.format.standard.AddressDivision
bitwiseOrRange, equals, getCount, getDigitCount, getDivisionPrefixCount, getMaxDigitCount, getPrefixCount, getPrefixLengthForSingleBlock, getUpperValue, getValue, hasUppercaseVariations, isBitwiseOrCompatibleWithRange, isMaskCompatibleWithRange, isMax, isZero, maskRange, matches, matchesWithMask, matchesWithMask
Methods inherited from class inet.ipaddr.format.AddressDivisionBase
getBytes, getBytes, getBytes, getDigitCount, getLowerStandardString, getStandardString, getUpperBytes, getUpperBytes, getUpperBytes, toString
Methods inherited from interface inet.ipaddr.format.AddressItem
compareTo, containsPrefixBlock, containsSinglePrefixBlock, getBitCount, getByteCount, getBytes, getBytes, getBytes, getCount, getPrefixCount, getPrefixLengthForSingleBlock, getUpperBytes, getUpperBytes, getUpperBytes, getUpperValue, getValue, isMax, isZero
Methods inherited from interface inet.ipaddr.AddressSegment
contains, equals, getMaxSegmentValue, isOneBit, testBit
Methods inherited from interface inet.ipaddr.format.string.AddressStringDivision
getDigitCount, getLowerStandardString, getMaxDigitCount, getStandardString
Methods inherited from interface inet.ipaddr.format.IPAddressGenericDivision
isFullRange
Methods inherited from interface inet.ipaddr.format.string.IPAddressStringDivision
getBitCount
-
Method Details
-
getNetwork
Description copied from interface:AddressComponent
Returns the network object for components of the same version (eg IPv4, IPv6 and MAC each have their own network object)- Specified by:
getNetwork
in interfaceAddressComponent
- Returns:
-
isIPv4
public boolean isIPv4() -
isIPv6
public boolean isIPv6() -
getIPVersion
-
getMinPrefixLengthForBlock
public int getMinPrefixLengthForBlock()Description copied from interface:AddressItem
Returns the smallest prefix length possible such that this item includes the block of all values for that prefix length.If the entire range can be dictated this way, then this method returns the same value as
AddressItem.getPrefixLengthForSingleBlock()
. Otherwise, this method will return the minimal possible prefix that can be paired with this address, whileAddressItem.getPrefixLengthForSingleBlock()
will return null.In cases where the final bit is constant so there is no such block, this returns the bit count.
- Specified by:
getMinPrefixLengthForBlock
in interfaceAddressItem
- Overrides:
getMinPrefixLengthForBlock
in classAddressDivision
- Returns:
- the prefix length
-
getMaxSegmentValue
-
isPrefixBlock
public boolean isPrefixBlock()Description copied from interface:IPAddressStringDivision
Returns whether the division range includes the block of values for its prefix length- Specified by:
isPrefixBlock
in interfaceIPAddressStringDivision
- Overrides:
isPrefixBlock
in classIPAddressDivision
- Returns:
- whether the division range includes the block of values for the division prefix length, or false if the division has no prefix length
-
toNetworkSegment
used by constructors of IPAddressSection, seeIPAddressSegmentSeries.getNetworkSection(int, boolean)
-
toNetworkSegment
public abstract IPAddressSegment toNetworkSegment(Integer segmentPrefixLength, boolean withPrefixLength) used by getNetworkSection and by constructors of IPAddressSection, seeIPAddressSegmentSeries.getNetworkSection(int, boolean)
-
toHostSegment
used by getHostSection, seeIPAddressSegmentSeries.getHostSection(int)
-
maskRange
-
bitwiseOrRange
-
getLower
If this segment represents a range of values, returns a segment representing just the lowest value in the range, otherwise returns this.- Specified by:
getLower
in interfaceAddressComponentRange
- Specified by:
getLower
in interfaceAddressSegment
- Returns:
-
getUpper
If this segment represents a range of values, returns a segment representing just the highest value in the range, otherwise returns this.- Specified by:
getUpper
in interfaceAddressComponentRange
- Specified by:
getUpper
in interfaceAddressSegment
- Returns:
-
getIterable
Description copied from interface:AddressComponentRange
Useful for using an instance in a "for-each loop". Otherwise just callAddressComponentRange.iterator()
directly.- Specified by:
getIterable
in interfaceAddressComponentRange
- Specified by:
getIterable
in interfaceAddressSegment
- Returns:
-
iterator
Description copied from interface:AddressComponentRange
Iterates 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:
iterator
in interfaceAddressComponentRange
- Specified by:
iterator
in interfaceAddressSegment
- Returns:
-
spliterator
Description copied from interface:AddressComponentRange
Partitions and traverses through the individual address components.- Specified by:
spliterator
in interfaceAddressComponent
- Specified by:
spliterator
in interfaceAddressComponentRange
- Specified by:
spliterator
in interfaceAddressSegment
- Returns:
-
stream
Description copied from interface:AddressComponentRange
Returns a sequential stream of the individual address components. For a parallel stream, callBaseStream.parallel()
on the returned stream.- Specified by:
stream
in interfaceAddressComponentRange
- Specified by:
stream
in interfaceAddressSegment
- Returns:
-
prefixBlockIterator
Iterates through the individual prefix blocks.If the series has no prefix length, then this is equivalent to
iterator()
-
prefixBlockSpliterator
Partitions and traverses through the individual prefix blocks of this segment for its prefix length.- Returns:
-
prefixBlockStream
Returns a sequential stream of the individual prefix blocks of this segment. For a parallel stream, callBaseStream.parallel()
on the returned stream.- Returns:
-
prefixIterator
Iterates through the individual prefixes.If the series has no prefix length, then this is equivalent to
iterator()
-
prefixSpliterator
Partitions and traverses through the individual prefixes of this segment for its prefix length.- Returns:
-
prefixStream
Returns a sequential stream of the individual prefixes of this segment. For a parallel stream, callBaseStream.parallel()
on the returned stream.- Returns:
-
prefixBlockIterator
Iterates through the individual prefix blocks according to the given segment prefix length. Any existing prefix length is disregarded. -
prefixBlockSpliterator
public abstract AddressComponentSpliterator<? extends IPAddressSegment> prefixBlockSpliterator(int prefixLength) Partitions and traverses through the individual prefix blocks for the given prefix length.- Returns:
-
prefixBlockStream
Returns a sequential stream of the individual prefix blocks for the given prefix length. For a parallel stream, callBaseStream.parallel()
on the returned stream.- Returns:
-
getBitCount
-
getByteCount
-
getDefaultTextualRadix
-
matches
public boolean matches(int value) - Specified by:
matches
in interfaceAddressSegment
-
matchesWithPrefixMask
-
matchesWithMask
public boolean matchesWithMask(int value, int mask) - Specified by:
matchesWithMask
in interfaceAddressSegment
-
matchesWithMask
public boolean matchesWithMask(int lowerValue, int upperValue, int mask) - Specified by:
matchesWithMask
in interfaceAddressSegment
-
getValueCount
public int getValueCount()- Specified by:
getValueCount
in interfaceAddressSegment
- Returns:
- the same value as
AddressItem.getCount()
as an integer
-
getPrefixValueCount
public int getPrefixValueCount()Counts the number of prefixes in this address segment.If this segment has no prefix length, this is equivalent to
getValueCount()
- Returns:
-
getDivisionValueCount
public long getDivisionValueCount()- Overrides:
getDivisionValueCount
in classAddressDivision
-
getMaxValue
public long getMaxValue()- Overrides:
getMaxValue
in classAddressDivision
-
isMultiple
public boolean isMultiple()Description copied from interface:AddressItem
Whether this represents multiple potential values (eg a prefixed address or a segment representing a range of values)- Specified by:
isMultiple
in interfaceAddressItem
- Overrides:
isMultiple
in classAddressDivision
- Returns:
- whether this segment represents multiple values
-
getSegmentValue
public int getSegmentValue()returns the lower value- Specified by:
getSegmentValue
in interfaceAddressSegment
-
getUpperSegmentValue
public int getUpperSegmentValue()returns the upper value- Specified by:
getUpperSegmentValue
in interfaceAddressSegment
-
getDivisionValue
public long getDivisionValue()returns the lower value as a long, although for individual segmentsgetSegmentValue()
provides the same value as an int- Specified by:
getDivisionValue
in classAddressDivision
-
getUpperDivisionValue
public long getUpperDivisionValue()returns the lower upper value as a long, although for individual segmentsgetUpperSegmentValue()
provides the same value as an int- Specified by:
getUpperDivisionValue
in classAddressDivision
-
reverseBits
Description copied from interface:AddressComponent
Returns a new AddressComponent with the bits reversed. If this component represents a range of values that cannot be reversed, then this throwsIncompatibleAddressException
. In a range the most significant bits stay constant while the least significant bits range over different values, so reversing that scenario results in a series of non-consecutive values, in most cases, which cannot be represented with a single AddressComponent object.In such cases where isMultiple() is true, call iterator(), getLower(), getUpper() or some other methods to break the series down into a series representing a single value.
- Specified by:
reverseBits
in interfaceAddressComponent
- Specified by:
reverseBits
in interfaceAddressSegment
- Parameters:
perByte
- if true, only the bits in each byte are reversed, if false, then all bits in the component are reversed- Returns:
-
reverseBytes
Description copied from interface:AddressComponent
Returns an AddressComponent with the bytes reversed. If this component represents a range of values that cannot be reversed, then this throwsIncompatibleAddressException
. In a range the most significant bits stay constant while the least significant bits range over different values, so reversing that scenario results in a series of non-consecutive values, in most cases, which cannot be represented with a single AddressComponent object.In such cases where isMultiple() is true, call iterator(), getLower(), getUpper() or some other methods to break the series down into a series representing a single value.
- Specified by:
reverseBytes
in interfaceAddressComponent
- Specified by:
reverseBytes
in interfaceAddressSegment
- Returns:
-
removePrefixLength
Deprecated.usewithoutPrefixLength()
andtoZeroHost()
- Returns:
-
toZeroHost
Returns a segment with the same network bits as this segment, but with the host bits changed to 0.If there is no prefix length associated with this segment, returns an all-zero segment.
This is nearly equivalent to doing the mask (see
maskRange(int)
) of this segment with the network mask for the given prefix length, but when applying a mask to a range of values you can have a non-sequential result.With this method, if the resulting series has a range of values, then the resulting series range boundaries will have host values of 0, but not necessarily all the intervening values.
For instance, the 1-byte segment range 4-7 with prefix length 6, when masked with 252 (the network mask) results in just the single value 4, matching the result of this method. The 1-byte segment range 4-8 with prefix length 6, when masked with 252 results in the two non-sequential values, 4 and 8, but the result of this method with prefix length 6 results in the range 4-8, the same as the original segment.
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
.- Returns:
-
removePrefixLength
Deprecated.usetoZeroHost()
andwithoutPrefixLength()
- Parameters:
zeroed
-- Returns:
-
withoutPrefixLength
Returns a segment with the same values but without a prefix length.- Returns:
-
isBoundedBy
public boolean isBoundedBy(int value) Description copied from class:AddressDivision
Returns true if the possible values of this division fall below the given value.- Specified by:
isBoundedBy
in interfaceAddressStringDivision
- Overrides:
isBoundedBy
in classAddressDivision
-
getSegmentPrefixLength
-
hashCode
public int hashCode()- Overrides:
hashCode
in classAddressDivision
-
prefixEquals
-
prefixEquals
Description copied from interface:AddressSegment
Returns whether the given prefix bits match the same bits of the given segment.- Specified by:
prefixEquals
in interfaceAddressSegment
- Parameters:
other
-prefixLength
-- Returns:
-
prefixContains
Using the prefix length of this segment, or the whole segment if it has no prefix length, returns whether the prefix bit value ranges contain the same bits of the given segment.- Parameters:
other
-- Returns:
-
prefixContains
Returns whether the given prefix bit value ranges contain the same bits of the given segment.- Parameters:
other
-prefixLength
-- Returns:
-
includesZero
public boolean includesZero()Description copied from interface:AddressItem
Returns whether this item includes the value of zero within its range- Specified by:
includesZero
in interfaceAddressItem
- Overrides:
includesZero
in classAddressDivision
- Returns:
- whether this item includes the value of zero within its range
-
includesMax
public boolean includesMax()Description copied from interface:AddressItem
Returns whether this item includes the maximum possible value for the address type or version within its range- Specified by:
includesMax
in interfaceAddressItem
- Overrides:
includesMax
in classAddressDivision
- Returns:
- whether this item includes the maximum possible value within its range
-
toHexString
Description copied from interface:AddressComponent
Writes this address component as a single hexadecimal value with always the exact same number of characters, with or without a preceding 0x prefix.If this component represents a range of values outside of the network prefix length, then this is printed as a range of two hex values.
For instance, for IPv4 addresses there are 8 hex characters, for IPv6 addresses there are 32 hex characters.
- Specified by:
toHexString
in interfaceAddressComponent
-
toNormalizedString
Description copied from interface:AddressComponent
Produces a string that is consistent for all address components of the same type and version, and is also similar to the canonical stringAddressSegmentSeries.toCanonicalString()
inAddressComponent
instances that are alsoAddressSegmentSeries
instances.- Specified by:
toNormalizedString
in interfaceAddressComponent
- Returns:
-
toNormalizedString
-
withoutPrefixLength()
andtoZeroHost()