public interface AddressSegmentSeries extends AddressDivisionSeries, AddressComponent
Modifier and Type | Method and Description |
---|---|
AddressSegmentSeries |
adjustPrefixBySegment(boolean nextSegment)
Increases or decreases prefix length to the next segment boundary.
|
AddressSegmentSeries |
adjustPrefixBySegment(boolean nextSegment,
boolean zeroed)
Increases or decreases prefix length to the next segment boundary.
|
AddressSegmentSeries |
adjustPrefixLength(int adjustment)
Increases or decreases prefix length by the given increment.
|
AddressSegmentSeries |
adjustPrefixLength(int adjustment,
boolean zeroed)
Increases or decreases prefix length by the given increment.
|
AddressSegmentSeries |
applyPrefixLength(int prefixLength)
Deprecated.
use #setPrefixLength(int)
|
int |
getBitsPerSegment()
Returns the number of bits comprising each segment in this series.
|
int |
getBytesPerSegment()
Returns the number of bytes comprising each segment in this series.
|
Iterable<? extends AddressSegmentSeries> |
getIterable()
Useful for using an instance in a "for-each loop".
|
AddressSegmentSeries |
getLower()
If this represents a series with ranging values, returns a series representing the lower values of the range.
|
int |
getMaxSegmentValue()
Returns the maximum possible segment value for this type of address.
|
AddressSection |
getSection()
Gets the subsection from the series that comprises all segments
|
AddressSection |
getSection(int index)
Gets the subsection from the series starting from the given index
The first segment is at index 0.
|
AddressSection |
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.
|
AddressSegment |
getSegment(int index)
Returns the segment from this series at the given index.
|
int |
getSegmentCount()
Returns the number of segments in this series.
|
AddressSegment[] |
getSegments()
Returns the segments of this series of segments as an array.
|
void |
getSegments(AddressSegment[] segs)
Copies the existing segments into the given array.
|
void |
getSegments(int start,
int end,
AddressSegment[] segs,
int index)
get the segments from start to end and insert into the segs array at the given index
|
String[] |
getSegmentStrings()
Returns the an array with the values of each segment as they would appear in the normalized with wildcards string.
|
AddressSegmentSeries |
getUpper()
If this represents a series with ranging values, returns a series representing the upper values of the range.
|
AddressSegmentSeries |
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.
|
AddressSegmentSeries |
incrementBoundary(long increment)
If the given increment is positive, adds the value to the upper series (
getUpper() ) in the subnet range to produce a new series. |
default boolean |
isOneBit(int prefixBitIndex)
Returns true if the bit in the lower value of this series at the given index is 1, where index 0 is the most significant bit.
|
Iterator<? extends AddressSegmentSeries> |
iterator()
Iterates through the individual address components.
|
Iterator<? extends AddressSegmentSeries> |
prefixBlockIterator()
Iterates through the individual prefix blocks.
|
AddressComponentSpliterator<? extends AddressSegmentSeries> |
prefixBlockSpliterator()
Partitions and traverses through the individual prefix blocks for the prefix length of this series.
|
Stream<? extends AddressSegmentSeries> |
prefixBlockStream()
Returns a sequential stream of the individual prefix blocks for the prefix length of this series.
|
Iterator<? extends AddressSegmentSeries> |
prefixIterator()
Iterates through the individual prefixes.
|
AddressComponentSpliterator<? extends AddressSegmentSeries> |
prefixSpliterator()
Partitions and traverses through the individual prefixes for the prefix length of this series.
|
Stream<? extends AddressSegmentSeries> |
prefixStream()
Returns a sequential stream of the individual prefixes for the prefix length of this series.
|
AddressSegmentSeries |
removePrefixLength()
Deprecated.
to remove the prefix length, use
withoutPrefixLength() ,
to remove the prefix length and zero out the bits beyond the prefix, use adjustPrefixLength(int)
with AddressDivisionSeries.getBitCount() as the argument, as in adjustPrefixLength(getBitCount()) |
AddressSegmentSeries |
removePrefixLength(boolean zeroed)
Deprecated.
|
AddressSegmentSeries |
reverseBits(boolean perByte)
Returns a new segment series with the bits reversed.
|
AddressSegmentSeries |
reverseBytes()
Returns a new segment series with the bytes reversed.
|
AddressSegmentSeries |
reverseBytesPerSegment()
Returns a new segment series with the bytes reversed within each segment.
|
AddressSegmentSeries |
reverseSegments()
Returns a new segment series with the segments reversed.
|
Iterator<? extends AddressSegment[]> |
segmentsIterator()
Iterates through the individual segments.
|
AddressComponentRangeSpliterator<? extends AddressSegmentSeries,? extends AddressSegment[]> |
segmentsSpliterator()
Partitions and traverses through the individual segment arrays.
|
Stream<? extends AddressSegment[]> |
segmentsStream()
Returns a sequential stream of the individual segment arrays.
|
AddressSegmentSeries |
setPrefixLength(int prefixLength)
Sets the prefix length.
|
AddressSegmentSeries |
setPrefixLength(int prefixLength,
boolean zeroed)
Sets the prefix length.
|
AddressComponentSpliterator<? extends AddressSegmentSeries> |
spliterator()
Partitions and traverses through the individual address components.
|
Stream<? extends AddressSegmentSeries> |
stream()
Returns a sequential stream of the individual address components.
|
default boolean |
testBit(int n)
Analogous to
BigInteger.testBit(int) ,
Computes (this & (1 << n)) != 0) |
String |
toCanonicalString()
Produces the canonical representation of the address
|
String |
toCompressedString()
Produces a short representation of the address while remaining within the confines of standard representation(s) of the address
|
AddressSegmentSeries |
toPrefixBlock()
If this series has a prefix length, returns the block for that prefix.
|
AddressSegmentSeries |
withoutPrefixLength()
Provides the same address with no prefix.
|
getBitCount, getBlockCount, getCount, getDivision, getDivisionStrings, getPrefixCount, getPrefixCount, getPrefixLength, getSequentialBlockIndex, isMore, isPrefixBlock, isPrefixed, isSequential, isSinglePrefixBlock
getDivisionCount
getNetwork, toHexString, toNormalizedString
stream, stream
compareTo, containsPrefixBlock, containsSinglePrefixBlock, getBitsForCount, getBlockSize, getByteCount, getBytes, getBytes, getBytes, getMinPrefixLengthForBlock, getPrefixLengthForSingleBlock, getUpperBytes, getUpperBytes, getUpperBytes, getUpperValue, getValue, includesMax, includesZero, isFullRange, isMax, isMultiple, isZero
int getSegmentCount()
int getBitsPerSegment()
int getBytesPerSegment()
int getMaxSegmentValue()
AddressSection getSection()
AddressSection getSection(int index)
index
- IndexOutOfBoundsException
- if index is negativeAddressSection getSection(int index, int endIndex)
index
- endIndex
- IndexOutOfBoundsException
- if index is negative or endIndex extends beyond the end of the seriesAddressSegment getSegment(int index)
AddressDivisionSeries.getDivision(int)
, the difference being that all segments in a given series are the same bit count, while divisions can have variable length.IndexOutOfBoundsException
- if the index is negative or as large as the segment countString[] getSegmentStrings()
void getSegments(AddressSegment[] segs)
getSegmentCount()
IndexOutOfBoundsException
- if the provided array is too smallvoid getSegments(int start, int end, AddressSegment[] segs, int index)
start
- the first segment index from this series to be includedend
- the first segment index to be excludedsegs
- the target arrayindex
- where to insert the segments in the segs arrayAddressSegment[] getSegments()
getSegment(int)
and getSegmentCount()
instead when feasible.AddressSegmentSeries getLower()
getLower
in interface AddressComponentRange
AddressSegmentSeries getUpper()
getUpper
in interface AddressComponentRange
default boolean testBit(int n)
BigInteger.testBit(int)
,
Computes (this & (1 << n)) != 0)n
- IndexOutOfBoundsException
- if the index is negative or as large as the bit countisOneBit(int)
default boolean isOneBit(int prefixBitIndex)
prefixBitIndex
- IndexOutOfBoundsException
- if the index is negative or as large as the bit counttestBit(int)
Iterable<? extends AddressSegmentSeries> getIterable()
AddressComponentRange
AddressComponentRange.iterator()
directly.getIterable
in interface AddressComponentRange
Iterator<? extends AddressSegmentSeries> iterator()
AddressComponentRange
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, or AddressItem.getCount()
for the count.
iterator
in interface AddressComponentRange
AddressComponentSpliterator<? extends AddressSegmentSeries> spliterator()
AddressComponentRange
spliterator
in interface AddressComponent
spliterator
in interface AddressComponentRange
Stream<? extends AddressSegmentSeries> stream()
AddressComponentRange
BaseStream.parallel()
on the returned stream.stream
in interface AddressComponentRange
Iterator<? extends AddressSegmentSeries> prefixIterator()
If the series has no prefix length, then this is equivalent to iterator()
AddressComponentSpliterator<? extends AddressSegmentSeries> prefixSpliterator()
Iterator<? extends AddressSegmentSeries> prefixBlockIterator()
If the series has no prefix length, then this is equivalent to iterator()
Stream<? extends AddressSegmentSeries> prefixStream()
BaseStream.parallel()
on the returned stream.AddressComponentSpliterator<? extends AddressSegmentSeries> prefixBlockSpliterator()
Stream<? extends AddressSegmentSeries> prefixBlockStream()
BaseStream.parallel()
on the returned stream.Iterator<? extends AddressSegment[]> segmentsIterator()
AddressComponentRangeSpliterator<? extends AddressSegmentSeries,? extends AddressSegment[]> segmentsSpliterator()
Stream<? extends AddressSegment[]> segmentsStream()
BaseStream.parallel()
on the returned stream.AddressSegmentSeries increment(long increment) throws AddressValueException
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 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.
increment
- AddressValueException
- in case of underflow or overflowAddressSegmentSeries incrementBoundary(long increment) throws AddressValueException
getUpper()
) in the subnet range to produce a new series.
If the given increment is negative, adds the value to the lower series (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.
increment
- AddressValueException
- in case of underflow or overflowString toCanonicalString()
String toCompressedString()
AddressSegmentSeries reverseSegments()
IncompatibleAddressException
since all address series can reverse their segments.AddressSegmentSeries reverseBits(boolean perByte)
reverseBits
in interface AddressComponent
perByte
- if true, only the bits in each byte are reversed, if false, then all bits in the component are reversedIncompatibleAddressException
- if reversing the bits within a single segment cannot be done
because the segment represents a range, and when all values in that range are reversed, the result is not contiguous.
In practice this means that to be reversible the range must include all values except possibly the largest and/or smallest.AddressSegmentSeries reverseBytes()
reverseBytes
in interface AddressComponent
IncompatibleAddressException
- if the segments have more than 1 bytes,
and if reversing the bits within a single segment cannot be done because the segment represents a range that is not the entire segment range.AddressSegmentSeries reverseBytesPerSegment()
IncompatibleAddressException
- if the segments have more than 1 bytes,
and if reversing the bits within a single segment cannot be done because the segment represents a range that is not the entire segment range.AddressSegmentSeries toPrefixBlock()
@Deprecated AddressSegmentSeries removePrefixLength()
withoutPrefixLength()
,
to remove the prefix length and zero out the bits beyond the prefix, use adjustPrefixLength(int)
with AddressDivisionSeries.getBitCount()
as the argument, as in adjustPrefixLength(getBitCount())
If the series already has a prefix length, the bits outside the prefix become zero.
Use withoutPrefixLength()
to remove the prefix length without changing the series values.
Equivalent to calling removePrefixLength(true)
for an alternative which does not change the address series values.
AddressSegmentSeries withoutPrefixLength()
Use removePrefixLength()
as an alternative that deletes the host at the same time by zeroing the host values.
@Deprecated AddressSegmentSeries removePrefixLength(boolean zeroed)
removePrefixLength()
or withoutPrefixLength()
removePrefixLength()
zeroed
- whether the bits outside the prefix become zeroAddressSegmentSeries adjustPrefixBySegment(boolean nextSegment)
Follows the same rules as 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, use adjustPrefixBySegment(boolean, boolean)
with second arg false.
nextSegment
- whether to move prefix to previous or following segment boundaryAddressSegmentSeries adjustPrefixBySegment(boolean nextSegment, boolean zeroed)
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 valuesAddressSegmentSeries adjustPrefixLength(int adjustment)
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 adjustPrefixLength(int, boolean)
with second arg false.
adjustment
- AddressSegmentSeries adjustPrefixLength(int adjustment, boolean zeroed)
zeroed
- whether the bits that move from one side of the prefix to the other become zero or retain their original valuesadjustment
- the incrementAddressSegmentSeries setPrefixLength(int prefixLength)
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 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.
prefixLength
- AddressSegmentSeries setPrefixLength(int prefixLength, boolean zeroed)
When the prefix is extended beyond the segment series boundary, it is removed.
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.@Deprecated AddressSegmentSeries applyPrefixLength(int prefixLength)
Similar to 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.
prefixLength
- setPrefixLength(int)