- All Implemented Interfaces:
AddressComponent
,AddressSegment
,AddressComponentRange
,AddressGenericDivision
,AddressItem
,AddressItemRange
,IPAddressGenericDivision
,AddressStringDivision
,IPAddressStringDivision
,Serializable
,Comparable<AddressItem>
,Iterable<IPv6AddressSegment>
- Author:
- sfoley
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class inet.ipaddr.format.standard.AddressDivision
AddressDivision.BitwiseOrResult, AddressDivision.MaskResult
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionIPv6AddressSegment
(int value) Constructs a segment of an IPv6 address with the given value.IPv6AddressSegment
(int lower, int upper, Integer segmentPrefixLength) Constructs a segment of an IPv6 address with the given range of values.IPv6AddressSegment
(int value, Integer segmentPrefixLength) Constructs a segment of an IPv6 address. -
Method Summary
Modifier and TypeMethodDescriptionboolean
contains
(AddressSegment other) boolean
Two divisions are equal if they: - they match type/version (ipv4, ipv6, mac, or a specific division class) - match bit counts - match values Prefix lengths, for those divisions that have them, are ignored.int
Provides the number of bits comprising this address itemint
Provides the number of bytes required for this address item, rounding up if the bit count is not a multiple of 8int
Useful for using an instance in a "for-each loop".getLower()
If this segment represents a range of values, returns a segment representing just the lowest value in the range, otherwise returns this.int
int
Gets the maximum possible value for this type of segment (for the highest range value of this particular segment, useAddressSegment.getUpper()
long
Returns the network object for components of the same version (eg IPv4, IPv6 and MAC each have their own network object)<S extends AddressSegment>
voidgetSplitSegments
(S[] segs, int index, AddressNetwork.AddressSegmentCreator<S> creator) Converts this IPv6 address segment into smaller segments, copying them into the given array starting at the given index.getUpper()
If this segment represents a range of values, returns a segment representing just the highest value in the range, otherwise returns this.boolean
isIPv6()
iterator()
Iterates through the individual address components.Iterates through the individual prefix blocks.prefixBlockIterator
(int prefixLength) Iterates through the individual prefix blocks according to the given segment prefix length.Partitions and traverses through the individual prefix blocks of this segment for its prefix length.prefixBlockSpliterator
(int segPrefLength) Partitions and traverses through the individual prefix blocks for the given prefix length.Returns a sequential stream of the individual prefix blocks of this segment.prefixBlockStream
(int segPrefLength) Returns a sequential stream of the individual prefix blocks for the given prefix length.boolean
prefixContains
(IPAddressSegment other, int segmentPrefixLength) Returns whether the given prefix bit value ranges contain the same bits of the given segment.boolean
prefixEquals
(AddressSegment other, int segmentPrefixLength) Returns whether the given prefix bits match the same bits of the given segment.Iterates through the individual prefixes.Partitions and traverses through the individual prefixes of this segment for its prefix length.Returns a sequential stream of the individual prefixes of this segment.Deprecated.removePrefixLength
(boolean zeroed) Deprecated.reverseBits
(boolean perByte) Returns a new AddressComponent with the bits reversed.Returns an AddressComponent with the bytes reversed.Partitions and traverses through the individual address components.stream()
Returns a sequential stream of the individual address components.toHostSegment
(Integer bits) used by getHostSection, seeIPAddressSegmentSeries.getHostSection(int)
toNetworkSegment
(Integer segmentPrefixLength) used by constructors of IPAddressSection, seeIPAddressSegmentSeries.getNetworkSection(int, boolean)
toNetworkSegment
(Integer segmentPrefixLength, boolean withPrefixLength) used by getNetworkSection and by constructors of IPAddressSection, seeIPAddressSegmentSeries.getNetworkSection(int, boolean)
Returns a segment with the same network bits as this segment, but with the host bits changed to 0.Returns a segment with the same values but without a prefix length.Methods inherited from class inet.ipaddr.IPAddressSegment
bitwiseOrRange, getBitCount, getByteCount, getDefaultTextualRadix, getDivisionValue, getDivisionValueCount, getMaxSegmentValue, getMinPrefixLengthForBlock, getPrefixValueCount, getSegmentPrefixLength, getSegmentValue, getUpperDivisionValue, getUpperSegmentValue, getValueCount, hashCode, includesMax, includesZero, isBoundedBy, isIPv4, isMultiple, isPrefixBlock, maskRange, matches, matchesWithMask, matchesWithMask, matchesWithPrefixMask, prefixContains, prefixEquals, toHexString, toNormalizedString, toNormalizedString
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, 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, getBytes, getBytes, getBytes, getCount, getPrefixCount, getPrefixLengthForSingleBlock, getUpperBytes, getUpperBytes, getUpperBytes, getUpperValue, getValue, isMax, isZero
Methods inherited from interface inet.ipaddr.AddressSegment
isOneBit, testBit
Methods inherited from interface inet.ipaddr.format.string.AddressStringDivision
getDigitCount, getLowerStandardString, getMaxDigitCount, getStandardString
Methods inherited from interface inet.ipaddr.format.IPAddressGenericDivision
isFullRange
-
Field Details
-
MAX_CHARS
public static final int MAX_CHARS- See Also:
-
BITS_PER_CHAR
public static final int BITS_PER_CHAR- See Also:
-
-
Constructor Details
-
IPv6AddressSegment
Constructs a segment of an IPv6 address with the given value.- Parameters:
value
- the value of the segment- Throws:
AddressValueException
- if value is negative or too large
-
IPv6AddressSegment
Constructs a segment of an IPv6 address.- Parameters:
value
- the value of the segment. If the segmentPrefixLength is non-null, the network prefix of the value is used, and the segment represents all segment values with the same network prefix.segmentPrefixLength
- the segment prefix length, which can be null- Throws:
AddressValueException
- if value or prefix length is negative or too large
-
IPv6AddressSegment
public IPv6AddressSegment(int lower, int upper, Integer segmentPrefixLength) throws AddressValueException Constructs a segment of an IPv6 address with the given range of values.- Parameters:
lower
- the lower value of the range of values represented by the segment. If segmentPrefixLength is non-null, the lower value becomes the smallest value with the same network prefix.upper
- the upper value of the range of values represented by the segment. If segmentPrefixLength is non-null, the upper value becomes the largest value with the same network prefix.segmentPrefixLength
- the segment prefix length, which can be null. If segmentPrefixLength is non-null, this segment represents a range of segment values with the given network prefix length.- Throws:
AddressValueException
- if value or prefix length is negative or too large
-
-
Method Details
-
getMaxValue
public long getMaxValue()- Overrides:
getMaxValue
in classIPAddressSegment
-
isIPv6
public boolean isIPv6()- Overrides:
isIPv6
in classIPAddressSegment
-
getIPVersion
- Specified by:
getIPVersion
in classIPAddressSegment
-
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
- Specified by:
getNetwork
in classIPAddressSegment
- Returns:
-
getMaxSegmentValue
public int getMaxSegmentValue()Description copied from interface:AddressSegment
Gets the maximum possible value for this type of segment (for the highest range value of this particular segment, useAddressSegment.getUpper()
- Specified by:
getMaxSegmentValue
in interfaceAddressSegment
- Returns:
-
toNetworkSegment
Description copied from class:IPAddressSegment
used by constructors of IPAddressSection, seeIPAddressSegmentSeries.getNetworkSection(int, boolean)
- Overrides:
toNetworkSegment
in classIPAddressSegment
-
toNetworkSegment
Description copied from class:IPAddressSegment
used by getNetworkSection and by constructors of IPAddressSection, seeIPAddressSegmentSeries.getNetworkSection(int, boolean)
- Specified by:
toNetworkSegment
in classIPAddressSegment
-
toHostSegment
Description copied from class:IPAddressSegment
used by getHostSection, seeIPAddressSegmentSeries.getHostSection(int)
- Specified by:
toHostSegment
in classIPAddressSegment
-
getLower
Description copied from class:IPAddressSegment
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
- Specified by:
getLower
in classIPAddressSegment
- Returns:
-
getUpper
Description copied from class:IPAddressSegment
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
- Specified by:
getUpper
in classIPAddressSegment
- Returns:
-
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
- Specified by:
reverseBits
in classIPAddressSegment
- 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
- Specified by:
reverseBytes
in classIPAddressSegment
- Returns:
-
toZeroHost
Description copied from class:IPAddressSegment
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
IPAddressSegment.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
.- Specified by:
toZeroHost
in classIPAddressSegment
- Returns:
-
removePrefixLength
Deprecated.- Specified by:
removePrefixLength
in classIPAddressSegment
- Parameters:
zeroed
-- Returns:
-
removePrefixLength
Deprecated.- Specified by:
removePrefixLength
in classIPAddressSegment
- Returns:
-
withoutPrefixLength
Description copied from class:IPAddressSegment
Returns a segment with the same values but without a prefix length.- Specified by:
withoutPrefixLength
in classIPAddressSegment
- 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
- Specified by:
getIterable
in classIPAddressSegment
- 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
- Specified by:
iterator
in interfaceIterable<IPv6AddressSegment>
- Specified by:
iterator
in classIPAddressSegment
- 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
- Specified by:
spliterator
in interfaceIterable<IPv6AddressSegment>
- Specified by:
spliterator
in classIPAddressSegment
- 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
- Specified by:
stream
in classIPAddressSegment
- Returns:
-
prefixBlockIterator
Description copied from class:IPAddressSegment
Iterates through the individual prefix blocks.If the series has no prefix length, then this is equivalent to
IPAddressSegment.iterator()
- Specified by:
prefixBlockIterator
in classIPAddressSegment
-
prefixBlockSpliterator
Description copied from class:IPAddressSegment
Partitions and traverses through the individual prefix blocks of this segment for its prefix length.- Specified by:
prefixBlockSpliterator
in classIPAddressSegment
- Returns:
-
prefixBlockStream
Description copied from class:IPAddressSegment
Returns a sequential stream of the individual prefix blocks of this segment. For a parallel stream, callBaseStream.parallel()
on the returned stream.- Specified by:
prefixBlockStream
in classIPAddressSegment
- Returns:
-
prefixBlockIterator
Description copied from class:IPAddressSegment
Iterates through the individual prefix blocks according to the given segment prefix length. Any existing prefix length is disregarded.- Specified by:
prefixBlockIterator
in classIPAddressSegment
-
prefixBlockSpliterator
Description copied from class:IPAddressSegment
Partitions and traverses through the individual prefix blocks for the given prefix length.- Specified by:
prefixBlockSpliterator
in classIPAddressSegment
- Returns:
-
prefixBlockStream
Description copied from class:IPAddressSegment
Returns a sequential stream of the individual prefix blocks for the given prefix length. For a parallel stream, callBaseStream.parallel()
on the returned stream.- Specified by:
prefixBlockStream
in classIPAddressSegment
- Returns:
-
prefixIterator
Description copied from class:IPAddressSegment
Iterates through the individual prefixes.If the series has no prefix length, then this is equivalent to
IPAddressSegment.iterator()
- Specified by:
prefixIterator
in classIPAddressSegment
-
prefixSpliterator
Description copied from class:IPAddressSegment
Partitions and traverses through the individual prefixes of this segment for its prefix length.- Specified by:
prefixSpliterator
in classIPAddressSegment
- Returns:
-
prefixStream
Description copied from class:IPAddressSegment
Returns a sequential stream of the individual prefixes of this segment. For a parallel stream, callBaseStream.parallel()
on the returned stream.- Specified by:
prefixStream
in classIPAddressSegment
- Returns:
-
getBitCount
public int getBitCount()Description copied from interface:AddressItem
Provides the number of bits comprising this address item- Specified by:
getBitCount
in interfaceAddressItem
- Specified by:
getBitCount
in interfaceIPAddressStringDivision
- Returns:
- the number of bits
-
getByteCount
public int getByteCount()Description copied from interface:AddressItem
Provides the number of bytes required for this address item, rounding up if the bit count is not a multiple of 8- Specified by:
getByteCount
in interfaceAddressItem
- Returns:
- the number of bytes
-
getDefaultTextualRadix
public int getDefaultTextualRadix() -
getMaxDigitCount
public int getMaxDigitCount() -
getSplitSegments
public <S extends AddressSegment> void getSplitSegments(S[] segs, int index, AddressNetwork.AddressSegmentCreator<S> creator) Converts this IPv6 address segment into smaller segments, copying them into the given array starting at the given index. If a segment does not fit into the array because the segment index in the array is out of bounds of the array, then it is not copied.- Parameters:
segs
-index
-
-
prefixContains
Description copied from class:IPAddressSegment
Returns whether the given prefix bit value ranges contain the same bits of the given segment.- Overrides:
prefixContains
in classIPAddressSegment
- Parameters:
other
-segmentPrefixLength
-- Returns:
-
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
- Overrides:
prefixEquals
in classIPAddressSegment
- Parameters:
other
-segmentPrefixLength
-- Returns:
-
contains
- Specified by:
contains
in interfaceAddressSegment
-
equals
Description copied from class:AddressDivisionBase
Two divisions are equal if they: - they match type/version (ipv4, ipv6, mac, or a specific division class) - match bit counts - match values Prefix lengths, for those divisions that have them, are ignored.- Specified by:
equals
in interfaceAddressSegment
- Overrides:
equals
in classAddressDivision
-