- All Superinterfaces:
AddressComponent
,AddressComponentRange
,AddressDivisionSeries
,AddressItem
,AddressItemRange
,AddressSegmentSeries
,AddressStringDivisionSeries
,Comparable<AddressItem>
,Serializable
- All Known Implementing Classes:
IPAddressSection
,IPv4AddressSection
,IPv6AddressSection
,MACAddressSection
- Author:
- sfoley
-
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.applyPrefixLength
(int networkPrefixLength) Deprecated.boolean
contains
(AddressSection other) Determines if one section contains another.Iterable
<? extends AddressSection> 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.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.Iterator
<? extends AddressSection> iterator()
Iterates through the individual address components.Iterator
<? extends AddressSection> Iterates through the individual prefix blocks.AddressComponentSpliterator
<? extends AddressSection> Partitions and traverses through the individual prefix blocks for the prefix length of this series.Stream
<? extends AddressSection> Returns a sequential stream of the individual prefix blocks for the prefix length of this series.boolean
prefixEquals
(AddressSection other) Determines if the argument section matches this section up to the prefix length of this section.Iterator
<? extends AddressSection> Iterates through the individual prefixes.AddressComponentSpliterator
<? extends AddressSection> Partitions and traverses through the individual prefixes for the prefix length of this series.Stream
<? extends AddressSection> Returns a sequential stream of the individual prefixes for the prefix length of this series.Deprecated.removePrefixLength
(boolean zeroed) Deprecated.reverseBits
(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.setPrefixLength
(int prefixLength) Sets the prefix length.setPrefixLength
(int prefixLength, boolean zeroed) Sets the prefix length.AddressComponentSpliterator
<? extends AddressSection> Partitions and traverses through the individual address components.Stream
<? extends AddressSection> stream()
Returns a sequential stream of the individual address components.If this series has a prefix length, returns the block for that prefix.Provides the same address with no prefix.Methods inherited from interface inet.ipaddr.AddressComponent
getNetwork, toHexString, toNormalizedString
Methods inherited from interface inet.ipaddr.format.AddressDivisionSeries
getBitCount, getBlockCount, getCount, getDivision, getDivisionStrings, getPrefixCount, getPrefixCount, getPrefixLength, getSequentialBlockIndex, isMore, isPrefixBlock, isPrefixed, isSequential, isSinglePrefixBlock
Methods inherited from interface inet.ipaddr.format.AddressItem
compareTo, containsPrefixBlock, containsSinglePrefixBlock, getByteCount, getBytes, getBytes, getBytes, getMinPrefixLengthForBlock, getPrefixLengthForSingleBlock, getUpperBytes, getUpperBytes, getUpperBytes, getUpperValue, getValue, includesMax, includesZero, isFullRange, isMax, isMultiple, isZero
Methods inherited from interface inet.ipaddr.AddressSegmentSeries
getBitsPerSegment, getBytesPerSegment, getMaxSegmentValue, getSection, getSection, getSection, getSegment, getSegmentCount, getSegments, getSegments, getSegments, getSegmentStrings, isOneBit, segmentsIterator, segmentsSpliterator, segmentsStream, testBit, toCanonicalString, toCompressedString
Methods inherited from interface inet.ipaddr.format.string.AddressStringDivisionSeries
getDivisionCount
-
Method Details
-
contains
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.
- Parameters:
other
-- Returns:
- whether this section contains the given address section
-
prefixEquals
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.
- Parameters:
other
-- Returns:
- whether the argument section has the same address section prefix as this
-
getLower
AddressSection 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 interfaceAddressSegmentSeries
- Returns:
-
getUpper
AddressSection 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 interfaceAddressSegmentSeries
- Returns:
-
reverseSegments
AddressSection 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 interfaceAddressSegmentSeries
- Returns:
-
reverseBits
Description copied from interface:AddressSegmentSeries
Returns a new segment series with the bits reversed.- Specified by:
reverseBits
in interfaceAddressComponent
- 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
AddressSection reverseBytes()Description copied from interface:AddressSegmentSeries
Returns a new segment series with the bytes reversed.- Specified by:
reverseBytes
in interfaceAddressComponent
- Specified by:
reverseBytes
in interfaceAddressSegmentSeries
- Returns:
-
reverseBytesPerSegment
AddressSection reverseBytesPerSegment()Description copied from interface:AddressSegmentSeries
Returns a new segment series with the bytes reversed within each segment.- Specified by:
reverseBytesPerSegment
in interfaceAddressSegmentSeries
- Returns:
-
toPrefixBlock
AddressSection 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 interfaceAddressSegmentSeries
- Returns:
- the block of address series for the prefix length
-
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 interfaceAddressSegmentSeries
- Returns:
- See Also:
-
withoutPrefixLength
AddressSection 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 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 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 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 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 interfaceAddressSegmentSeries
- Parameters:
adjustment
-- Returns:
-
adjustPrefixLength
Description copied from interface:AddressSegmentSeries
Increases or decreases prefix length by the given increment.- 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:
-
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 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 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:
-
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 interfaceAddressSegmentSeries
- Parameters:
networkPrefixLength
-- Returns:
- See Also:
-
getIterable
Iterable<? extends AddressSection> 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 interfaceAddressSegmentSeries
- Returns:
-
iterator
Iterator<? extends AddressSection> 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 interfaceAddressSegmentSeries
- Returns:
-
spliterator
AddressComponentSpliterator<? extends AddressSection> 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 interfaceAddressSegmentSeries
- Returns:
-
stream
Stream<? extends AddressSection> 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 interfaceAddressSegmentSeries
- Returns:
-
prefixIterator
Iterator<? extends AddressSection> 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 interfaceAddressSegmentSeries
-
prefixSpliterator
AddressComponentSpliterator<? extends AddressSection> prefixSpliterator()Description copied from interface:AddressSegmentSeries
Partitions and traverses through the individual prefixes for the prefix length of this series.- Specified by:
prefixSpliterator
in interfaceAddressSegmentSeries
- Returns:
-
prefixStream
Stream<? extends AddressSection> 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 interfaceAddressSegmentSeries
- Returns:
-
prefixBlockIterator
Iterator<? extends AddressSection> 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 interfaceAddressSegmentSeries
-
prefixBlockSpliterator
AddressComponentSpliterator<? extends AddressSection> 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 interfaceAddressSegmentSeries
- Returns:
-
prefixBlockStream
Stream<? extends AddressSection> 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 interfaceAddressSegmentSeries
- 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 interfaceAddressSegmentSeries
- Parameters:
increment
-- 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 interfaceAddressSegmentSeries
- Parameters:
increment
-- Returns:
-