public interface AddressSection extends AddressSegmentSeries
Modifier and Type | Method and Description |
---|---|
AddressSection |
adjustPrefixBySegment(boolean nextSegment)
Increases or decreases prefix length to the next segment boundary.
|
AddressSection |
adjustPrefixBySegment(boolean nextSegment,
boolean zeroed)
Increases or decreases prefix length to the next segment boundary.
|
AddressSection |
adjustPrefixLength(int adjustment)
Increases or decreases prefix length by the given increment.
|
AddressSection |
adjustPrefixLength(int adjustment,
boolean zeroed)
Increases or decreases prefix length by the given increment.
|
AddressSection |
applyPrefixLength(int networkPrefixLength)
Applies the given prefix length to create a new segment series.
|
boolean |
contains(AddressSection other)
Determines if one section contains another.
|
java.lang.Iterable<? extends AddressSection> |
getIterable()
Useful for using an instance in a "for-each loop".
|
AddressSection |
getLower()
If this represents a series with ranging values, returns a series representing the lower values of the range.
|
AddressSection |
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.
|
AddressSection |
increment(long increment)
Returns the series from the subnet that is the given increment upwards into the subnet range,
or if the given increment is negative the given increment downwards into the subnet range,
or if this is just an individual series, it simply adds the increment to this.
|
java.util.Iterator<? extends AddressSection> |
iterator()
Iterates through the individual segment series.
|
java.util.Iterator<? extends AddressSection> |
prefixBlockIterator()
Iterates through the individual prefix blocks.
|
AddressSection |
removePrefixLength()
Removes the prefix length.
|
AddressSection |
removePrefixLength(boolean zeroed)
Removes the prefix length.
|
AddressSection |
reverseBits(boolean perByte)
Returns a new segment series with the bits reversed.
|
AddressSection |
reverseBytes()
Returns a new segment series with the bytes reversed.
|
AddressSection |
reverseBytesPerSegment()
Returns a new segment series with the bytes reversed within each segment.
|
AddressSection |
reverseSegments()
Returns a new segment series with the segments reversed.
|
AddressSection |
setPrefixLength(int prefixLength)
Sets the prefix length.
|
AddressSection |
setPrefixLength(int prefixLength,
boolean zeroed)
Sets the prefix length.
|
AddressSection |
toPrefixBlock()
If this series has a prefix length, returns the block for that prefix.
|
getBitsPerSegment, getBytesPerSegment, getNetwork, getSection, getSection, getSection, getSegment, getSegmentCount, getSegments, getSegments, getSegments, getSegmentStrings, segmentsIterator, toCanonicalString, toCompressedString
containsPrefixBlock, containsSinglePrefixBlock, getDivision, getDivisionStrings, getMinPrefixLengthForBlock, getPrefixCount, getPrefixLength, getPrefixLengthForSingleBlock, getUpperValue, getValue, isMore, isPrefixBlock, isPrefixed, isSinglePrefixBlock
getDivisionCount
getByteCount, toHexString, toNormalizedString
getBitCount, getBytes, getBytes, getCount, getUpperBytes, getUpperBytes, includesMax, includesZero, isFullRange, isMax, isMultiple, isZero
boolean contains(AddressSection other)
other
- AddressSection getLower()
AddressSegmentSeries
getLower
in interface AddressComponent
getLower
in interface AddressSegmentSeries
AddressSection getUpper()
AddressSegmentSeries
getUpper
in interface AddressComponent
getUpper
in interface AddressSegmentSeries
AddressSection reverseSegments()
AddressSegmentSeries
IncompatibleAddressException
since all address series can reverse their segments.reverseSegments
in interface AddressSegmentSeries
AddressSection reverseBits(boolean perByte)
AddressSegmentSeries
reverseBits
in interface AddressComponent
reverseBits
in interface AddressSegmentSeries
perByte
- if true, only the bits in each byte are reversed, if false, then all bits in the component are reversedAddressSection reverseBytes()
AddressSegmentSeries
reverseBytes
in interface AddressComponent
reverseBytes
in interface AddressSegmentSeries
AddressSection reverseBytesPerSegment()
AddressSegmentSeries
reverseBytesPerSegment
in interface AddressSegmentSeries
AddressSection toPrefixBlock()
AddressSegmentSeries
toPrefixBlock
in interface AddressSegmentSeries
AddressSection removePrefixLength()
AddressSegmentSeries
If the series already has a prefix length, the bits outside the prefix become zero.
removePrefixLength
in interface AddressSegmentSeries
AddressSection removePrefixLength(boolean zeroed)
AddressSegmentSeries
removePrefixLength
in interface AddressSegmentSeries
zeroed
- whether the bits outside the prefix become zeroAddressSection adjustPrefixBySegment(boolean nextSegment)
AddressSegmentSeries
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.
adjustPrefixBySegment
in interface AddressSegmentSeries
nextSegment
- whether to move prefix to previous or following segment coundaryAddressSection adjustPrefixBySegment(boolean nextSegment, boolean zeroed)
AddressSegmentSeries
adjustPrefixBySegment
in interface AddressSegmentSeries
nextSegment
- whether to move prefix to previous or following segment coundaryzeroed
- whether the bits that move from one side of the prefix to the other become zero or retain their original valuesAddressSection adjustPrefixLength(int adjustment)
AddressSegmentSeries
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.
adjustPrefixLength
in interface AddressSegmentSeries
AddressSection adjustPrefixLength(int adjustment, boolean zeroed)
AddressSegmentSeries
adjustPrefixLength
in interface AddressSegmentSeries
adjustment
- the incrementzeroed
- whether the bits that move from one side of the prefix to the other become zero or retain their original valuesAddressSection setPrefixLength(int prefixLength)
AddressSegmentSeries
If this series has a prefix length, and the 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.
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.
setPrefixLength
in interface AddressSegmentSeries
AddressSegmentSeries.applyPrefixLength(int)
AddressSection setPrefixLength(int prefixLength, boolean zeroed)
AddressSegmentSeries
When the prefix is extended beyond the segment series boundary, it is removed.
setPrefixLength
in interface AddressSegmentSeries
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.AddressSection applyPrefixLength(int networkPrefixLength)
AddressSegmentSeries
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.
applyPrefixLength
in interface AddressSegmentSeries
AddressSegmentSeries.setPrefixLength(int)
java.lang.Iterable<? extends AddressSection> getIterable()
AddressComponent
AddressComponent.iterator()
directly.getIterable
in interface AddressComponent
getIterable
in interface AddressSegmentSeries
java.util.Iterator<? extends AddressSection> iterator()
AddressSegmentSeries
iterator
in interface AddressComponent
iterator
in interface AddressSegmentSeries
java.util.Iterator<? extends AddressSection> prefixBlockIterator()
AddressSegmentSeries
AddressSegmentSeries.iterator()
prefixBlockIterator
in interface AddressSegmentSeries
AddressSection increment(long increment)
AddressSegmentSeries
If the subnet has multiple values and the increment exceeds the subnet size, then the amount by which is exceeds the size is added to the upper series of the range (the final iterator value) or is subtracted from the lower series of the range (the first iterator value) if negative.
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 iterator. For instance, a increment of 1 is value 1 from the iterator, an increment of 2 is the second value from the iterator, and so on. A negative increment is equivalent to the same number of values preceding the upper bound of the iterator. For instance, an increment of -1 is the last value from the iterator, and increment of -2 is the second last value, and so on.
Therefore, to get the series just above the highest series of the subnet, use an increment of size:count > 1 ? count + 1 : 1
where count is the subnet size.
To get the series just below the lowest series of the subnet, use an increment of size:-(count > 1 ? count + 1 : 1)
where count is the subnet size.
increment
in interface AddressSegmentSeries