Class IPv6AddressSegment
- 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 AddressDivision
AddressDivision.BitwiseOrResult, AddressDivision.MaskResult -
Field Summary
FieldsFields inherited from class AddressDivisionBase
EXTENDED_DIGITS -
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 TypeMethodDescriptionbooleancontains(AddressSegment other) booleanTwo 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.intProvides the number of bits comprising this address itemintProvides the number of bytes required for this address item, rounding up if the bit count is not a multiple of 8intUseful 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.intintGets the maximum possible value for this type of segment (for the highest range value of this particular segment, useAddressSegment.getUpper()longReturns 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.booleanisIPv6()iterator()Iterates through the individual address components.booleanoverlaps(AddressSegment other) 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.booleanprefixContains(IPAddressSegment other, int segmentPrefixLength) Returns whether the given prefix bit value ranges contain the same bits of the given segment.booleanprefixEquals(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 IPAddressSegment
bitwiseOrRange, getBitCount, getByteCount, getCount, getDefaultTextualRadix, getDivisionValue, getMaxSegmentValue, getMinPrefixLengthForBlock, getPrefixCount, getPrefixValueCount, getPrefixValueCount, getSegmentPrefixLength, getSegmentValue, getUpperDivisionValue, getUpperSegmentValue, getValueCount, hashCode, includesMax, includesZero, isBoundedBy, isIPv4, isMultiple, isPrefixBlock, maskRange, matches, matchesWithMask, matchesWithMask, matchesWithPrefixMask, prefixContains, prefixEquals, toHexString, toNormalizedString, toNormalizedStringMethods inherited from class IPAddressDivision
containsPrefixBlock, containsSinglePrefixBlock, getBlockMaskPrefixLength, getDivisionPrefixLength, getLeadingBitCount, getPrefixAdjustedRangeString, getString, getTrailingBitCount, getWildcardString, isPrefixed, isSinglePrefixBlock, matchesWithPrefixMaskMethods inherited from class AddressDivision
bitwiseOrRange, getDigitCount, getMaxDigitCount, getPrefixLengthForSingleBlock, getUpperValue, getValue, hasUppercaseVariations, isBitwiseOrCompatibleWithRange, isMaskCompatibleWithRange, isMax, isZero, maskRange, matches, matchesWithMask, matchesWithMaskMethods inherited from class AddressDivisionBase
getBytes, getBytes, getBytes, getDigitCount, getDigitCount, getLowerStandardString, getStandardString, getUpperBytes, getUpperBytes, getUpperBytes, toStringMethods inherited from interface AddressItem
compareTo, containsPrefixBlock, containsSinglePrefixBlock, getBytes, getBytes, getBytes, getPrefixLengthForSingleBlock, getUpperBytes, getUpperBytes, getUpperBytes, getUpperValue, getValue, isMax, isZeroMethods inherited from interface AddressSegment
isOneBit, testBitMethods inherited from interface AddressStringDivision
getDigitCount, getLowerStandardString, getMaxDigitCount, getStandardStringMethods inherited from interface 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:
getMaxValuein classIPAddressSegment
-
isIPv6
public boolean isIPv6()- Overrides:
isIPv6in classIPAddressSegment
-
getIPVersion
- Specified by:
getIPVersionin classIPAddressSegment
-
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 classIPAddressSegment- Returns:
-
getMaxSegmentValue
public int getMaxSegmentValue()Description copied from interface:AddressSegmentGets the maximum possible value for this type of segment (for the highest range value of this particular segment, useAddressSegment.getUpper()- Specified by:
getMaxSegmentValuein interfaceAddressSegment- Returns:
-
toNetworkSegment
Description copied from class:IPAddressSegmentused by constructors of IPAddressSection, seeIPAddressSegmentSeries.getNetworkSection(int, boolean)- Overrides:
toNetworkSegmentin classIPAddressSegment
-
toNetworkSegment
Description copied from class:IPAddressSegmentused by getNetworkSection and by constructors of IPAddressSection, seeIPAddressSegmentSeries.getNetworkSection(int, boolean)- Specified by:
toNetworkSegmentin classIPAddressSegment
-
toHostSegment
Description copied from class:IPAddressSegmentused by getHostSection, seeIPAddressSegmentSeries.getHostSection(int)- Specified by:
toHostSegmentin classIPAddressSegment
-
getLower
Description copied from class:IPAddressSegmentIf this segment represents a range of values, returns a segment representing just the lowest value in the range, otherwise returns this.- Specified by:
getLowerin interfaceAddressComponentRange- Specified by:
getLowerin interfaceAddressSegment- Specified by:
getLowerin classIPAddressSegment- Returns:
-
getUpper
Description copied from class:IPAddressSegmentIf this segment represents a range of values, returns a segment representing just the highest value in the range, otherwise returns this.- Specified by:
getUpperin interfaceAddressComponentRange- Specified by:
getUpperin interfaceAddressSegment- Specified by:
getUpperin classIPAddressSegment- Returns:
-
reverseBits
Description copied from interface:AddressComponentReturns 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:
reverseBitsin interfaceAddressComponent- Specified by:
reverseBitsin interfaceAddressSegment- Specified by:
reverseBitsin 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:AddressComponentReturns 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:
reverseBytesin interfaceAddressComponent- Specified by:
reverseBytesin interfaceAddressSegment- Specified by:
reverseBytesin classIPAddressSegment- Returns:
-
toZeroHost
Description copied from class:IPAddressSegmentReturns 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:
toZeroHostin classIPAddressSegment- Returns:
-
removePrefixLength
Deprecated.- Specified by:
removePrefixLengthin classIPAddressSegment- Parameters:
zeroed-- Returns:
-
removePrefixLength
Deprecated.- Specified by:
removePrefixLengthin classIPAddressSegment- Returns:
-
withoutPrefixLength
Description copied from class:IPAddressSegmentReturns a segment with the same values but without a prefix length.- Specified by:
withoutPrefixLengthin classIPAddressSegment- 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 interfaceAddressSegment- Specified by:
getIterablein classIPAddressSegment- 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 interfaceAddressSegment- Specified by:
iteratorin interfaceIterable<IPv6AddressSegment>- Specified by:
iteratorin classIPAddressSegment- 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 interfaceAddressSegment- Specified by:
spliteratorin interfaceIterable<IPv6AddressSegment>- Specified by:
spliteratorin classIPAddressSegment- 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 interfaceAddressSegment- Specified by:
streamin classIPAddressSegment- Returns:
-
prefixBlockIterator
Description copied from class:IPAddressSegmentIterates through the individual prefix blocks.If the series has no prefix length, then this is equivalent to
IPAddressSegment.iterator()- Specified by:
prefixBlockIteratorin classIPAddressSegment
-
prefixBlockSpliterator
Description copied from class:IPAddressSegmentPartitions and traverses through the individual prefix blocks of this segment for its prefix length.- Specified by:
prefixBlockSpliteratorin classIPAddressSegment- Returns:
-
prefixBlockStream
Description copied from class:IPAddressSegmentReturns a sequential stream of the individual prefix blocks of this segment. For a parallel stream, callBaseStream.parallel()on the returned stream.- Specified by:
prefixBlockStreamin classIPAddressSegment- Returns:
-
prefixBlockIterator
Description copied from class:IPAddressSegmentIterates through the individual prefix blocks according to the given segment prefix length. Any existing prefix length is disregarded.- Specified by:
prefixBlockIteratorin classIPAddressSegment
-
prefixBlockSpliterator
Description copied from class:IPAddressSegmentPartitions and traverses through the individual prefix blocks for the given prefix length.- Specified by:
prefixBlockSpliteratorin classIPAddressSegment- Returns:
-
prefixBlockStream
Description copied from class:IPAddressSegmentReturns 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:
prefixBlockStreamin classIPAddressSegment- Returns:
-
prefixIterator
Description copied from class:IPAddressSegmentIterates through the individual prefixes.If the series has no prefix length, then this is equivalent to
IPAddressSegment.iterator()- Specified by:
prefixIteratorin classIPAddressSegment
-
prefixSpliterator
Description copied from class:IPAddressSegmentPartitions and traverses through the individual prefixes of this segment for its prefix length.- Specified by:
prefixSpliteratorin classIPAddressSegment- Returns:
-
prefixStream
Description copied from class:IPAddressSegmentReturns a sequential stream of the individual prefixes of this segment. For a parallel stream, callBaseStream.parallel()on the returned stream.- Specified by:
prefixStreamin classIPAddressSegment- Returns:
-
getBitCount
public int getBitCount()Description copied from interface:AddressItemProvides the number of bits comprising this address item- Specified by:
getBitCountin interfaceAddressItem- Specified by:
getBitCountin interfaceIPAddressStringDivision- 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- 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:IPAddressSegmentReturns whether the given prefix bit value ranges contain the same bits of the given segment.- Overrides:
prefixContainsin classIPAddressSegment- Parameters:
other-segmentPrefixLength-- Returns:
-
prefixEquals
Description copied from interface:AddressSegmentReturns whether the given prefix bits match the same bits of the given segment.- Specified by:
prefixEqualsin interfaceAddressSegment- Overrides:
prefixEqualsin classIPAddressSegment- Parameters:
other-segmentPrefixLength-- Returns:
-
overlaps
- Specified by:
overlapsin interfaceAddressSegment
-
contains
- Specified by:
containsin interfaceAddressSegment
-
equals
Description copied from class:AddressDivisionBaseTwo 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:
equalsin interfaceAddressSegment- Overrides:
equalsin classAddressDivision
-