- All Implemented Interfaces:
AddressComponent
,AddressSection
,AddressSegmentSeries
,AddressComponentRange
,AddressDivisionSeries
,AddressItem
,AddressItemRange
,AddressStringDivisionSeries
,Serializable
,Comparable<AddressItem>
,Iterable<MACAddressSection>
- Author:
- sfoley
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Represents a clear way to create a specific type of string.Nested classes/interfaces inherited from class inet.ipaddr.format.standard.AddressDivisionGrouping
AddressDivisionGrouping.DivisionLengthProvider, AddressDivisionGrouping.DivisionValueProvider, AddressDivisionGrouping.StringOptions
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMACAddressSection
(byte[] bytes) MACAddressSection
(byte[] bytes, int startIndex, boolean extended) MACAddressSection
(long value) MACAddressSection
(long value, int startIndex, boolean extended) MACAddressSection
(Address.SegmentValueProvider valueProvider) MACAddressSection
(Address.SegmentValueProvider valueProvider, int startIndex, boolean extended) MACAddressSection
(Address.SegmentValueProvider lowerValueProvider, Address.SegmentValueProvider upperValueProvider, int startIndex, boolean extended) MACAddressSection
(MACAddressSegment segment) Constructs a single segment section, the segment being the leading segment.MACAddressSection
(MACAddressSegment[] segments) Use this constructor for any address section that includes the leading segment of a MAC addressMACAddressSection
(MACAddressSegment[] segments, int startIndex, boolean extended) MACAddressSection
(MACAddressSegment segment, int startIndex, boolean extended) Constructs a single segment section with the segment at the given index in the address. -
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
(MACAddressSection other) appendToPrefix
(MACAddressSection other) applyPrefixLength
(int prefixLength) Deprecated.boolean
contains
(AddressSection other) Determines if one section contains another.boolean
contains
(MACAddressSection other) boolean
Two 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.int
Provides the number of bits comprising this address itemint
Returns the number of bits comprising each segment in this series.getBlockCount
(int segmentCount) Returns the count of values in the initial (higher) count of divisions.int
Provides the number of bytes required for this address item, rounding up if the bit count is not a multiple of 8int
Returns the number of bytes comprising each segment in this series.getDivision
(int index) Useful 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.int
Returns the maximum possible segment value for this type of address.Returns the network object for components of the same version (eg IPv4, IPv6 and MAC each have their own network object)int
int
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.The bit-length of the portion of the address that is not specific to an individual address but common amongst a group of addresses.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.int
Returns the number of segments in this series.Returns the segments of this series of segments as an array.void
getSegments
(int start, int end, AddressSegment[] segs, int destIndex) get the segments from start to end and insert into the segs array at the given indexvoid
getSegments
(int start, int end, Collection<? super MACAddressSegment> segs) void
getSegments
(AddressSegment[] segs) Copies the existing segments into the given array.void
getSegments
(Collection<? super MACAddressSegment> segs) String[]
Returns the an array with the values of each segment as they would appear in the normalized with wildcards string.getUpper()
If 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.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, MACAddressSection other) boolean
isEntireAddress
(boolean extended) boolean
isEUI64
(boolean asMAC) Equivalent to isEUI64(asMAC, false)boolean
isEUI64
(boolean asMAC, boolean partial) Whether this section is consistent with an EUI64 section, which means it came from an extended 8 byte address, and the corresponding segments in the middle match 0xff and 0xff/fe for MAC/not-MACboolean
boolean
Indicates if the address represents all devices with the same OUI segments.iterator()
Iterates through the individual address components.long
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.boolean
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, MACAddressSection 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, MACAddressSection replacement) Replace the segments of this section starting at the given index with the given replacement segmentsreverseBits
(boolean perByte) Returns a new segment series with 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.Partitions and traverses through the individual segment arrays.Returns a sequential stream of the individual segment arrays.setPrefixLength
(int prefixLength) Sets the prefix length.setPrefixLength
(int prefixLength, boolean zeroed) Sets the prefix length.Partitions and traverses through the individual address components.stream()
Returns a sequential stream of the individual address components.This produces a canonical string using the canonical standardized IEEE 802 MAC address representation of xx-xx-xx-xx-xx-xx For range segments, '..' is used: 11-22-33..44-55-66This produces a shorter string for the address that uses the canonical representation but not using leading zeroes.This produces the dotted hexadecimal format aaaa.bbbb.cccctoEUI64
(boolean asMAC) If this section is part of a shorter 48 bit MAC or EUI-48 address seeisExtended()
, then the required sections are inserted (FF-FF for MAC, FF-FE for EUI-48) to extend it to EUI-64.Converts to Ipv6.toHexString
(boolean with0xPrefix) Writes this address as a single hexadecimal value with always the exact same number of characters, with or without a preceding 0x prefix.The normalized string returned by this method is the most common representation of MAC addresses: xx:xx:xx:xx:xx:xxtoNormalizedString
(AddressDivisionGrouping.StringOptions stringOptions) static String
Returns a section in which the range of values match the block for the OUI (organizationally unique identifier) bytesIf this series has a prefix length, returns the block for that prefix.This produces a string delimited by spaces: aa bb cc dd ee fftoString()
long
Provides the same address with no prefix.Methods inherited from class inet.ipaddr.format.standard.AddressDivisionGrouping
containsPrefixBlock, containsSinglePrefixBlock, hashCode
Methods inherited from class inet.ipaddr.format.AddressDivisionGroupingBase
getBytes, getBytes, getBytes, getCount, getDivisionCount, getDivisionStrings, getMinPrefixLengthForBlock, getPrefixCount, getPrefixLengthForSingleBlock, getUpperBytes, getUpperBytes, getUpperBytes, getUpperValue, getValue, includesMax, includesZero, isFullRange, isMax, isMultiple, isPrefixBlock, isSinglePrefixBlock, isZero
Methods inherited from interface inet.ipaddr.format.AddressDivisionSeries
getCount, getDivisionStrings, getPrefixCount, getSequentialBlockIndex, isMore, isPrefixBlock, isSequential, isSinglePrefixBlock
Methods inherited from interface inet.ipaddr.format.AddressItem
compareTo, containsPrefixBlock, containsSinglePrefixBlock, getBytes, getBytes, getBytes, getMinPrefixLengthForBlock, getPrefixLengthForSingleBlock, getUpperBytes, getUpperBytes, getUpperBytes, getUpperValue, getValue, includesMax, includesZero, isFullRange, isMax, isMultiple, isZero
Methods inherited from interface inet.ipaddr.AddressSegmentSeries
isOneBit, testBit
Methods inherited from interface inet.ipaddr.format.string.AddressStringDivisionSeries
getDivisionCount
-
Field Details
-
addressSegmentIndex
public final int addressSegmentIndex -
extended
public final boolean extended
-
-
Constructor Details
-
MACAddressSection
Constructs a single segment section, the segment being the leading segment.- Parameters:
segment
-
-
MACAddressSection
Constructs a single segment section with the segment at the given index in the address.- Parameters:
segment
-
-
MACAddressSection
Use this constructor for any address section that includes the leading segment of a MAC address -
MACAddressSection
-
MACAddressSection
-
MACAddressSection
public MACAddressSection(Address.SegmentValueProvider valueProvider, int startIndex, boolean extended) -
MACAddressSection
public MACAddressSection(Address.SegmentValueProvider lowerValueProvider, Address.SegmentValueProvider upperValueProvider, int startIndex, boolean extended) -
MACAddressSection
public MACAddressSection(byte[] bytes, int startIndex, boolean extended) -
MACAddressSection
public MACAddressSection(byte[] bytes) -
MACAddressSection
public MACAddressSection(long value, int startIndex, boolean extended) -
MACAddressSection
public MACAddressSection(long value)
-
-
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:
-
getIPv6Network
-
equals
Description copied from class:AddressDivisionGroupingBase
Two 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:
equals
in classAddressDivisionGrouping
-
getSegments
Description copied from interface:AddressSegmentSeries
Returns 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:
getSegments
in interfaceAddressSegmentSeries
- Returns:
-
getSegments
Description copied from interface:AddressSegmentSeries
Copies the existing segments into the given array. The array size should be at least as large asAddressSegmentSeries.getSegmentCount()
- Specified by:
getSegments
in interfaceAddressSegmentSeries
-
getSegments
Description copied from interface:AddressSegmentSeries
get the segments from start to end and insert into the segs array at the given index- Specified by:
getSegments
in interfaceAddressSegmentSeries
- Parameters:
start
- the first segment index from this series to be includedend
- the first segment index to be excludedsegs
- the target arraydestIndex
- where to insert the segments in the segs array
-
isExtended
public boolean isExtended()- Returns:
- whether this section is part of a larger EUI-64 address.
-
getSegmentCount
public int getSegmentCount()Description copied from interface:AddressSegmentSeries
Returns the number of segments in this series.- Specified by:
getSegmentCount
in interfaceAddressSegmentSeries
- Returns:
-
isEntireAddress
public boolean isEntireAddress(boolean extended) -
getDivision
- Specified by:
getDivision
in interfaceAddressDivisionSeries
- Specified by:
getDivision
in interfaceAddressStringDivisionSeries
- Overrides:
getDivision
in classAddressDivisionGrouping
- Returns:
- the given division in this series. The first is at index 0.
-
getSegment
Description copied from interface:AddressSegmentSeries
Returns 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:
getSegment
in interfaceAddressSegmentSeries
- Returns:
-
getSegments
-
getSegments
-
getMaxSegmentValue
public int getMaxSegmentValue()Description copied from interface:AddressSegmentSeries
Returns the maximum possible segment value for this type of address. Note this is not the maximum value of the range of segment values in this specific address, this is the maximum value of any segment for this address type, and is usually determined by the number of bits per segment.- Specified by:
getMaxSegmentValue
in interfaceAddressSegmentSeries
- Returns:
- the maximum possible segment value for a series of the same type
-
getBitsPerSegment
public int getBitsPerSegment()Description copied from interface:AddressSegmentSeries
Returns the number of bits comprising each segment in this series. Segments in the same series are equal length.- Specified by:
getBitsPerSegment
in interfaceAddressSegmentSeries
- Returns:
-
getBytesPerSegment
public int getBytesPerSegment()Description copied from interface:AddressSegmentSeries
Returns the number of bytes comprising each segment in this series. Segments in the same series are equal length.- Specified by:
getBytesPerSegment
in interfaceAddressSegmentSeries
- Returns:
-
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
-
getBitCount
public int getBitCount()Description copied from interface:AddressItem
Provides the number of bits comprising this address item- Specified by:
getBitCount
in interfaceAddressDivisionSeries
- Specified by:
getBitCount
in interfaceAddressItem
- Returns:
- the number of bits
-
getBlockCount
Description copied from interface:AddressDivisionSeries
Returns the count of values in the initial (higher) count of divisions.- Specified by:
getBlockCount
in interfaceAddressDivisionSeries
- Returns:
-
getPrefixCount
Description copied from interface:AddressItem
The 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:
getPrefixCount
in interfaceAddressDivisionSeries
- Specified by:
getPrefixCount
in interfaceAddressItem
- Parameters:
prefixLength
-- Returns:
-
isPrefixed
public boolean isPrefixed()Indicates if the address represents all devices with the same OUI segments.- Specified by:
isPrefixed
in interfaceAddressDivisionSeries
- Overrides:
isPrefixed
in classAddressDivisionGroupingBase
- Returns:
- true if all the ODI segments are full-range, covering all devices
-
getOUISegmentCount
public int getOUISegmentCount() -
getODISegmentCount
public int getODISegmentCount() -
getPrefixLength
Description copied from interface:AddressDivisionSeries
The bit-length of the portion of the address that is not specific to an individual address but common amongst a group of addresses.Typically this is the largest number of bits in the upper-most portion of the section for which the remaining bits assume all possible values.
For IP addresses, this must be explicitly defined when the address is created. For example, 1.2.0.0/16 has a prefix length of 16, while 1.2.*.* has no prefix length, even though they both represent the same set of addresses and are considered equal. Prefixes can be considered variable for any given IP addresses and can depend on the routing table.
The methods
AddressItem.getMinPrefixLengthForBlock()
andAddressItem.getPrefixLengthForSingleBlock()
can help you to obtain or define a prefix length if one does not exist already. 1.2.0.0/16 and 1.2.*.* both the same equivalent and minimum prefix length of 16.For MAC addresses, the prefix is initially defined by the range, so 1:2:3:*:*:* has a prefix length of 24 by definition. Addresses derived from the original may retain the original prefix length regardless of their range.
- Specified by:
getPrefixLength
in interfaceAddressDivisionSeries
- Overrides:
getPrefixLength
in classAddressDivisionGroupingBase
- Returns:
- the number of bits in the prefix. The prefix is the smallest bit length x for which all possible values with the same first x bits are included in this range of sections, unless that value x matches the bit count of this section, in which case the prefix is null. If the prefix is the OUI bit length (24) then the ODI segments cover all possibly values.
-
getSection
Description copied from interface:AddressSegmentSeries
Gets the subsection from the series that comprises all segments- Specified by:
getSection
in interfaceAddressSegmentSeries
- Returns:
-
getSection
Description copied from interface:AddressSegmentSeries
Gets the subsection from the series starting from the given index The first segment is at index 0.- Specified by:
getSection
in interfaceAddressSegmentSeries
- Parameters:
index
-- Returns:
-
getSection
Description copied from interface:AddressSegmentSeries
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.- Specified by:
getSection
in interfaceAddressSegmentSeries
- Parameters:
index
-endIndex
-- Returns:
-
getOUISection
-
getODISection
-
toOUIPrefixBlock
Returns a section in which the range of values match the block for the OUI (organizationally unique identifier) bytes- Returns:
-
toEUI64IPv6
Converts to Ipv6. Any MAC prefix length is ignored. Other elements of this address section are incorporated into the conversion.- Returns:
-
isEUI64
public boolean isEUI64(boolean asMAC) Equivalent to isEUI64(asMAC, false)- Returns:
-
isEUI64
public boolean isEUI64(boolean asMAC, boolean partial) Whether this section is consistent with an EUI64 section, which means it came from an extended 8 byte address, and the corresponding segments in the middle match 0xff and 0xff/fe for MAC/not-MAC- Parameters:
asMAC
- whether to search for the ffff or fffe patternpartial
- whether missing segments are considered a match (this only has an effect if this section came from an extended 8 byte address), or in other words, we don't consider 6 byte addresses to be "missing" the bytes that would make it 8 byte.- Returns:
-
toEUI64
If this section is part of a shorter 48 bit MAC or EUI-48 address seeisExtended()
, then the required sections are inserted (FF-FF for MAC, FF-FE for EUI-48) to extend it to EUI-64. However, if the section does not encompass the parts of the address where the new sections should be placed, then the section is unchanged. If the section is already part of an EUI-64 address, then it is checked to see if it has the segments that identify it as extended to EUI-64 (FF-FF for MAC, FF-FE for EUI-48), and if not,IncompatibleAddressException
is thrown.- Parameters:
asMAC
-- Returns:
-
append
-
appendToPrefix
-
insert
-
replace
Replace the segments of this section starting at the given index with the given replacement segments- Parameters:
index
-replacement
-- Returns:
-
replace
public MACAddressSection replace(int startIndex, int endIndex, MACAddressSection 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:
IndexOutOfBoundsException
AddressValueException
- if the resulting section would exceed the maximum segment count for this address type and version
-
getLower
Description copied from interface:AddressSegmentSeries
If 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:
getLower
in interfaceAddressComponentRange
- Specified by:
getLower
in interfaceAddressSection
- Specified by:
getLower
in interfaceAddressSegmentSeries
- Returns:
-
getUpper
Description copied from interface:AddressSegmentSeries
If 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:
getUpper
in interfaceAddressComponentRange
- Specified by:
getUpper
in interfaceAddressSection
- Specified by:
getUpper
in interfaceAddressSegmentSeries
- Returns:
-
longValue
public long longValue() -
upperLongValue
public long upperLongValue() -
reverseBits
Description copied from interface:AddressSegmentSeries
Returns a new segment series with the bits reversed.- Specified by:
reverseBits
in interfaceAddressComponent
- Specified by:
reverseBits
in interfaceAddressSection
- Specified by:
reverseBits
in interfaceAddressSegmentSeries
- 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:AddressSegmentSeries
Returns a new segment series with the bytes reversed.- Specified by:
reverseBytes
in interfaceAddressComponent
- Specified by:
reverseBytes
in interfaceAddressSection
- Specified by:
reverseBytes
in interfaceAddressSegmentSeries
- Returns:
-
reverseBytesPerSegment
Description copied from interface:AddressSegmentSeries
Returns a new segment series with the bytes reversed within each segment.- Specified by:
reverseBytesPerSegment
in interfaceAddressSection
- Specified by:
reverseBytesPerSegment
in interfaceAddressSegmentSeries
- Returns:
-
reverseSegments
Description copied from interface:AddressSegmentSeries
Returns a new segment series with the segments reversed. This does not throwIncompatibleAddressException
since all address series can reverse their segments.- Specified by:
reverseSegments
in interfaceAddressSection
- Specified by:
reverseSegments
in interfaceAddressSegmentSeries
- Returns:
-
removePrefixLength
Deprecated.Description copied from interface:AddressSegmentSeries
Removes 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:
removePrefixLength
in interfaceAddressSection
- Specified by:
removePrefixLength
in interfaceAddressSegmentSeries
- Returns:
- See Also:
-
withoutPrefixLength
Description copied from interface:AddressSegmentSeries
Provides 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:
withoutPrefixLength
in interfaceAddressSection
- Specified by:
withoutPrefixLength
in interfaceAddressSegmentSeries
-
removePrefixLength
Deprecated.Description copied from interface:AddressSegmentSeries
Removes the prefix length. If zeroed is false, the bits that were host bits do not become zero, unlikeAddressSegmentSeries.removePrefixLength()
- Specified by:
removePrefixLength
in interfaceAddressSection
- Specified by:
removePrefixLength
in interfaceAddressSegmentSeries
- Parameters:
zeroed
- whether the bits outside the prefix become zero- Returns:
-
adjustPrefixBySegment
Description copied from interface:AddressSegmentSeries
Increases 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:
adjustPrefixBySegment
in interfaceAddressSection
- Specified by:
adjustPrefixBySegment
in interfaceAddressSegmentSeries
- Parameters:
nextSegment
- whether to move prefix to previous or following segment boundary- Returns:
-
adjustPrefixBySegment
Description copied from interface:AddressSegmentSeries
Increases or decreases prefix length to the next segment boundary.- Specified by:
adjustPrefixBySegment
in interfaceAddressSection
- Specified by:
adjustPrefixBySegment
in interfaceAddressSegmentSeries
- 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:AddressSegmentSeries
Increases 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:
adjustPrefixLength
in interfaceAddressSection
- Specified by:
adjustPrefixLength
in interfaceAddressSegmentSeries
- Parameters:
adjustment
-- Returns:
-
adjustPrefixLength
Description copied from interface:AddressSegmentSeries
Increases or decreases prefix length by the given increment.- Specified by:
adjustPrefixLength
in interfaceAddressSection
- Specified by:
adjustPrefixLength
in interfaceAddressSegmentSeries
- 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:AddressSegmentSeries
Applies 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:
applyPrefixLength
in interfaceAddressSection
- Specified by:
applyPrefixLength
in interfaceAddressSegmentSeries
- Parameters:
prefixLength
-- Returns:
- See Also:
-
setPrefixLength
Description copied from interface:AddressSegmentSeries
Sets 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:
setPrefixLength
in interfaceAddressSection
- Specified by:
setPrefixLength
in interfaceAddressSegmentSeries
- Parameters:
prefixLength
-- Returns:
-
setPrefixLength
Description copied from interface:AddressSegmentSeries
Sets the prefix length.When the prefix is extended beyond the segment series boundary, it is removed.
- Specified by:
setPrefixLength
in interfaceAddressSection
- Specified by:
setPrefixLength
in interfaceAddressSegmentSeries
- Parameters:
zeroed
- 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:
-
toPrefixBlock
Description copied from interface:AddressSegmentSeries
If this series has a prefix length, returns the block for that prefix. Otherwise, this address series is returned.- Specified by:
toPrefixBlock
in interfaceAddressSection
- Specified by:
toPrefixBlock
in interfaceAddressSegmentSeries
- Returns:
- the block of address series for the prefix length
-
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 interfaceAddressSection
- Specified by:
getIterable
in interfaceAddressSegmentSeries
- 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 interfaceAddressSection
- Specified by:
iterator
in interfaceAddressSegmentSeries
- Specified by:
iterator
in interfaceIterable<MACAddressSection>
- Returns:
-
prefixIterator
Description copied from interface:AddressSegmentSeries
Iterates through the individual prefixes.If the series has no prefix length, then this is equivalent to
AddressSegmentSeries.iterator()
- Specified by:
prefixIterator
in interfaceAddressSection
- Specified by:
prefixIterator
in interfaceAddressSegmentSeries
-
prefixBlockIterator
Description copied from interface:AddressSegmentSeries
Iterates through the individual prefix blocks.If the series has no prefix length, then this is equivalent to
AddressSegmentSeries.iterator()
- Specified by:
prefixBlockIterator
in interfaceAddressSection
- Specified by:
prefixBlockIterator
in interfaceAddressSegmentSeries
-
segmentsIterator
Description copied from interface:AddressSegmentSeries
Iterates through the individual segments.- Specified by:
segmentsIterator
in interfaceAddressSegmentSeries
-
segmentsSpliterator
public AddressComponentRangeSpliterator<MACAddressSection,MACAddressSegment[]> segmentsSpliterator()Description copied from interface:AddressSegmentSeries
Partitions and traverses through the individual segment arrays.- Specified by:
segmentsSpliterator
in interfaceAddressSegmentSeries
- Returns:
-
segmentsStream
Description copied from interface:AddressSegmentSeries
Returns a sequential stream of the individual segment arrays. For a parallel stream, callBaseStream.parallel()
on the returned stream.- Specified by:
segmentsStream
in interfaceAddressSegmentSeries
- 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 interfaceAddressSection
- Specified by:
spliterator
in interfaceAddressSegmentSeries
- Specified by:
spliterator
in interfaceIterable<MACAddressSection>
- 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 interfaceAddressSection
- Specified by:
stream
in interfaceAddressSegmentSeries
- Returns:
-
prefixSpliterator
Description copied from interface:AddressSegmentSeries
Partitions and traverses through the individual prefixes for the prefix length of this series.- Specified by:
prefixSpliterator
in interfaceAddressSection
- Specified by:
prefixSpliterator
in interfaceAddressSegmentSeries
- Returns:
-
prefixStream
Description copied from interface:AddressSegmentSeries
Returns 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:
prefixStream
in interfaceAddressSection
- Specified by:
prefixStream
in interfaceAddressSegmentSeries
- Returns:
-
prefixBlockSpliterator
Description copied from interface:AddressSegmentSeries
Partitions and traverses through the individual prefix blocks for the prefix length of this series.- Specified by:
prefixBlockSpliterator
in interfaceAddressSection
- Specified by:
prefixBlockSpliterator
in interfaceAddressSegmentSeries
- Returns:
-
prefixBlockStream
Description copied from interface:AddressSegmentSeries
Returns 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:
prefixBlockStream
in interfaceAddressSection
- Specified by:
prefixBlockStream
in interfaceAddressSegmentSeries
- Returns:
-
incrementBoundary
Description copied from interface:AddressSegmentSeries
If 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:
incrementBoundary
in interfaceAddressSection
- Specified by:
incrementBoundary
in interfaceAddressSegmentSeries
- Parameters:
increment
-- Returns:
-
increment
Description copied from interface:AddressSegmentSeries
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.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:
increment
in interfaceAddressSection
- Specified by:
increment
in interfaceAddressSegmentSeries
- Parameters:
increment
-- Returns:
-
toHexString
Writes this address as a single hexadecimal value with always the exact same number of characters, with or without a preceding 0x prefix.- Specified by:
toHexString
in interfaceAddressComponent
- Throws:
IncompatibleAddressException
-
toNormalizedString
-
toNormalizedString
public static String toNormalizedString(AddressDivisionGrouping.StringOptions opts, AddressDivisionGrouping section) -
toNormalizedString
The normalized string returned by this method is the most common representation of MAC addresses: xx:xx:xx:xx:xx:xx- Specified by:
toNormalizedString
in interfaceAddressComponent
- Returns:
-
toCanonicalString
This produces a canonical string using the canonical standardized IEEE 802 MAC address representation of xx-xx-xx-xx-xx-xx For range segments, '..' is used: 11-22-33..44-55-66- Specified by:
toCanonicalString
in interfaceAddressSegmentSeries
- Returns:
-
toCompressedString
This produces a shorter string for the address that uses the canonical representation but not using leading zeroes. Each address has a unique compressed string.- Specified by:
toCompressedString
in interfaceAddressSegmentSeries
- Returns:
-
toDottedString
This produces the dotted hexadecimal format aaaa.bbbb.cccc- Throws:
IncompatibleAddressException
-
toSpaceDelimitedString
This produces a string delimited by spaces: aa bb cc dd ee ff -
toDashedString
-
toColonDelimitedString
-
toString
- Overrides:
toString
in classAddressDivisionGroupingBase
-
getSegmentStrings
Description copied from interface:AddressSegmentSeries
Returns the an array with the values of each segment as they would appear in the normalized with wildcards string.- Specified by:
getSegmentStrings
in interfaceAddressSegmentSeries
- Returns:
-
getDottedGrouping
-
contains
Description copied from interface:AddressSection
Determines 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:
contains
in interfaceAddressSection
- Parameters:
other
-- Returns:
- whether this section contains the given address section
-
contains
- Parameters:
other
-- Returns:
- whether this section contains the given address section
-
prefixEquals
Description copied from interface:AddressSection
Determines 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:
prefixEquals
in interfaceAddressSection
- Parameters:
o
-- Returns:
- whether the argument section has the same address section prefix as this
-