public abstract class IPAddressSegment extends IPAddressDivision implements AddressSegment
AddressDivision.BitwiseOrResult, AddressDivision.MaskResultEXTENDED_DIGITS| Modifier and Type | Method and Description |
|---|---|
AddressDivision.BitwiseOrResult |
bitwiseOrRange(int maskValue) |
static int |
getBitCount(IPAddress.IPVersion version) |
static int |
getByteCount(IPAddress.IPVersion version) |
BigInteger |
getCount()
The count of possible distinct values for this AddressComponent.
|
static int |
getDefaultTextualRadix(IPAddress.IPVersion version) |
long |
getDivisionValue()
returns the lower value as a long, although for individual segments
getSegmentValue() provides the same value as an int |
abstract IPAddress.IPVersion |
getIPVersion() |
abstract Iterable<? extends IPAddressSegment> |
getIterable()
Useful for using an instance in a "for-each loop".
|
abstract IPAddressSegment |
getLower()
If this segment represents a range of values, returns a segment representing just the lowest value in the range, otherwise returns this.
|
static int |
getMaxSegmentValue(IPAddress.IPVersion version) |
long |
getMaxValue() |
int |
getMinPrefixLengthForBlock()
Returns the smallest prefix length possible such that this item includes the block of all values for that prefix length.
|
abstract IPAddressNetwork<?,?,?,?,?> |
getNetwork()
Returns the network object for components of the same version (eg IPv4, IPv6 and MAC each have their own network object)
|
BigInteger |
getPrefixCount(int segmentPrefixLength)
The count of the number of distinct values within the prefix part of the address item, the bits that appear within the prefix length.
|
int |
getPrefixValueCount()
Counts the number of prefixes in this address segment.
|
int |
getPrefixValueCount(int segmentPrefixLength)
Returns the count of prefix values in this address segment for the given prefix bit count.
|
Integer |
getSegmentPrefixLength() |
int |
getSegmentValue()
returns the lower value
|
abstract IPAddressSegment |
getUpper()
If this segment represents a range of values, returns a segment representing just the highest value in the range, otherwise returns this.
|
long |
getUpperDivisionValue()
returns the lower upper value as a long, although for individual segments
getUpperSegmentValue() provides the same value as an int |
int |
getUpperSegmentValue()
returns the upper value
|
int |
getValueCount()
Returns the count of values in this address segment.
|
int |
hashCode()
Returns a hash code value for the object.
|
boolean |
includesMax()
Returns whether this item includes the maximum possible value for the address type or version within its range
|
boolean |
includesZero()
Returns whether this item includes the value of zero within its range
|
boolean |
isBoundedBy(int value)
Returns true if the possible values of this division fall below the given value.
|
boolean |
isIPv4() |
boolean |
isIPv6() |
boolean |
isMultiple()
Whether this represents multiple potential values (eg a prefixed address or a segment representing a range of values)
|
boolean |
isPrefixBlock()
Returns whether the division range includes the block of values for its prefix length
|
abstract Iterator<? extends IPAddressSegment> |
iterator()
Iterates through the individual address components.
|
AddressDivision.MaskResult |
maskRange(int maskValue) |
boolean |
matches(int value) |
boolean |
matchesWithMask(int value,
int mask) |
boolean |
matchesWithMask(int lowerValue,
int upperValue,
int mask) |
boolean |
matchesWithPrefixMask(int value,
Integer segmentPrefixLength) |
abstract Iterator<? extends IPAddressSegment> |
prefixBlockIterator()
Iterates through the individual prefix blocks.
|
abstract Iterator<? extends IPAddressSegment> |
prefixBlockIterator(int prefixLength)
Iterates through the individual prefix blocks according to the given segment prefix length.
|
abstract AddressComponentSpliterator<? extends IPAddressSegment> |
prefixBlockSpliterator()
Partitions and traverses through the individual prefix blocks of this segment for its prefix length.
|
abstract AddressComponentSpliterator<? extends IPAddressSegment> |
prefixBlockSpliterator(int prefixLength)
Partitions and traverses through the individual prefix blocks for the given prefix length.
|
abstract Stream<? extends IPAddressSegment> |
prefixBlockStream()
Returns a sequential stream of the individual prefix blocks of this segment.
|
abstract Stream<? extends IPAddressSegment> |
prefixBlockStream(int prefixLength)
Returns a sequential stream of the individual prefix blocks for the given prefix length.
|
boolean |
prefixContains(IPAddressSegment other)
Using the prefix length of this segment, or the whole segment if it has no prefix length,
returns whether the prefix bit value ranges contain the same bits of the given segment.
|
boolean |
prefixContains(IPAddressSegment other,
int prefixLength)
Returns whether the given prefix bit value ranges contain the same bits of the given segment.
|
boolean |
prefixEquals(AddressSegment other,
int prefixLength)
Returns whether the given prefix bits match the same bits of the given segment.
|
boolean |
prefixEquals(IPAddressSegment other) |
abstract Iterator<? extends IPAddressSegment> |
prefixIterator()
Iterates through the individual prefixes.
|
abstract AddressComponentSpliterator<? extends IPAddressSegment> |
prefixSpliterator()
Partitions and traverses through the individual prefixes of this segment for its prefix length.
|
abstract Stream<? extends IPAddressSegment> |
prefixStream()
Returns a sequential stream of the individual prefixes of this segment.
|
abstract IPAddressSegment |
removePrefixLength()
Deprecated.
use
withoutPrefixLength() and toZeroHost() |
abstract IPAddressSegment |
removePrefixLength(boolean zeroed)
Deprecated.
use
toZeroHost() and withoutPrefixLength() |
abstract IPAddressSegment |
reverseBits(boolean perByte)
Returns a new AddressComponent with the bits reversed.
|
abstract IPAddressSegment |
reverseBytes()
Returns an AddressComponent with the bytes reversed.
|
abstract AddressComponentSpliterator<? extends IPAddressSegment> |
spliterator()
Partitions and traverses through the individual address components.
|
abstract Stream<? extends IPAddressSegment> |
stream()
Returns a sequential stream of the individual address components.
|
String |
toHexString(boolean with0xPrefix)
Writes this address component as a single hexadecimal value with always the exact same number of characters, with or without a preceding 0x prefix.
|
abstract IPAddressSegment |
toHostSegment(Integer segmentPrefixLength)
used by getHostSection, see
IPAddressSegmentSeries.getHostSection(int) |
IPAddressSegment |
toNetworkSegment(Integer segmentPrefixLength)
used by constructors of IPAddressSection, see
IPAddressSegmentSeries.getNetworkSection(int, boolean) |
abstract IPAddressSegment |
toNetworkSegment(Integer segmentPrefixLength,
boolean withPrefixLength)
used by getNetworkSection and by constructors of IPAddressSection, see
IPAddressSegmentSeries.getNetworkSection(int, boolean) |
String |
toNormalizedString()
Produces a string that is consistent for all address components of the same type and version,
and is also similar to the canonical string
AddressSegmentSeries.toCanonicalString() in AddressComponent instances that are also AddressSegmentSeries instances. |
String |
toNormalizedString(IPAddressSection.IPStringOptions options) |
abstract IPAddressSegment |
toZeroHost()
Returns a segment with the same network bits as this segment,
but with the host bits changed to 0.
|
abstract IPAddressSegment |
withoutPrefixLength()
Returns a segment with the same values but without a prefix length.
|
containsPrefixBlock, containsSinglePrefixBlock, getBlockMaskPrefixLength, getDivisionPrefixLength, getLeadingBitCount, getPrefixAdjustedRangeString, getString, getTrailingBitCount, getWildcardString, isPrefixed, isSinglePrefixBlock, matchesWithPrefixMaskbitwiseOrRange, equals, getDigitCount, getMaxDigitCount, getPrefixLengthForSingleBlock, getUpperValue, getValue, hasUppercaseVariations, isBitwiseOrCompatibleWithRange, isMaskCompatibleWithRange, isMax, isZero, maskRange, matches, matchesWithMask, matchesWithMaskgetBytes, getBytes, getBytes, getDigitCount, getLowerStandardString, getStandardString, getUpperBytes, getUpperBytes, getUpperBytes, toStringcontains, equals, getMaxSegmentValue, isOneBit, testBitstream, streamcompareTo, containsPrefixBlock, containsSinglePrefixBlock, getBitCount, getByteCount, getBytes, getBytes, getBytes, getPrefixLengthForSingleBlock, getUpperBytes, getUpperBytes, getUpperBytes, getUpperValue, getValue, isFullRange, isMax, isZerogetDigitCount, getLowerStandardString, getMaxDigitCount, getStandardStringisFullRangegetBitCountpublic abstract IPAddressNetwork<?,?,?,?,?> getNetwork()
AddressComponentgetNetwork in interface AddressComponentpublic boolean isIPv4()
public boolean isIPv6()
public abstract IPAddress.IPVersion getIPVersion()
public int getMinPrefixLengthForBlock()
AddressItem
If the entire range can be dictated this way, then this method returns the same value as AddressItem.getPrefixLengthForSingleBlock().
Otherwise, this method will return the minimal possible prefix that can be paired with this address, while AddressItem.getPrefixLengthForSingleBlock() will return null.
In cases where the final bit is constant so there is no such block, this returns the bit count.
getMinPrefixLengthForBlock in interface AddressItemgetMinPrefixLengthForBlock in class AddressDivisionpublic static int getMaxSegmentValue(IPAddress.IPVersion version)
public boolean isPrefixBlock()
IPAddressStringDivisionisPrefixBlock in interface IPAddressStringDivisionisPrefixBlock in class IPAddressDivisionpublic IPAddressSegment toNetworkSegment(Integer segmentPrefixLength)
IPAddressSegmentSeries.getNetworkSection(int, boolean)public abstract IPAddressSegment toNetworkSegment(Integer segmentPrefixLength, boolean withPrefixLength)
IPAddressSegmentSeries.getNetworkSection(int, boolean)public abstract IPAddressSegment toHostSegment(Integer segmentPrefixLength)
IPAddressSegmentSeries.getHostSection(int)public AddressDivision.MaskResult maskRange(int maskValue)
public AddressDivision.BitwiseOrResult bitwiseOrRange(int maskValue)
public abstract IPAddressSegment getLower()
getLower in interface AddressSegmentgetLower in interface AddressComponentRangepublic abstract IPAddressSegment getUpper()
getUpper in interface AddressSegmentgetUpper in interface AddressComponentRangepublic abstract Iterable<? extends IPAddressSegment> getIterable()
AddressComponentRangeAddressComponentRange.iterator() directly.getIterable in interface AddressSegmentgetIterable in interface AddressComponentRangepublic abstract Iterator<? extends IPAddressSegment> iterator()
AddressComponentRangeAn 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 AddressSegmentiterator in interface AddressComponentRangepublic abstract AddressComponentSpliterator<? extends IPAddressSegment> spliterator()
AddressComponentRangespliterator in interface AddressComponentspliterator in interface AddressSegmentspliterator in interface AddressComponentRangepublic abstract Stream<? extends IPAddressSegment> stream()
AddressComponentRangeBaseStream.parallel() on the returned stream.stream in interface AddressSegmentstream in interface AddressComponentRangepublic abstract Iterator<? extends IPAddressSegment> prefixBlockIterator()
If the series has no prefix length, then this is equivalent to iterator()
public abstract AddressComponentSpliterator<? extends IPAddressSegment> prefixBlockSpliterator()
public abstract Stream<? extends IPAddressSegment> prefixBlockStream()
BaseStream.parallel() on the returned stream.public abstract Iterator<? extends IPAddressSegment> prefixIterator()
If the series has no prefix length, then this is equivalent to iterator()
public abstract AddressComponentSpliterator<? extends IPAddressSegment> prefixSpliterator()
public abstract Stream<? extends IPAddressSegment> prefixStream()
BaseStream.parallel() on the returned stream.public abstract Iterator<? extends IPAddressSegment> prefixBlockIterator(int prefixLength)
public abstract AddressComponentSpliterator<? extends IPAddressSegment> prefixBlockSpliterator(int prefixLength)
public abstract Stream<? extends IPAddressSegment> prefixBlockStream(int prefixLength)
BaseStream.parallel() on the returned stream.public static int getBitCount(IPAddress.IPVersion version)
public static int getByteCount(IPAddress.IPVersion version)
public static int getDefaultTextualRadix(IPAddress.IPVersion version)
public boolean matches(int value)
matches in interface AddressSegmentpublic boolean matchesWithPrefixMask(int value,
Integer segmentPrefixLength)
public boolean matchesWithMask(int value,
int mask)
matchesWithMask in interface AddressSegmentpublic boolean matchesWithMask(int lowerValue,
int upperValue,
int mask)
matchesWithMask in interface AddressSegmentpublic int getValueCount()
AddressSegmentgetValueCount in interface AddressSegmentgetCount() as an integerpublic int getPrefixValueCount()
If this segment has no prefix length, this is equivalent to getValueCount()
public BigInteger getCount()
AddressItemgetCount in interface AddressItempublic BigInteger getPrefixCount(int segmentPrefixLength)
AddressItemgetPrefixCount in interface AddressItempublic int getPrefixValueCount(int segmentPrefixLength)
AddressSegmentgetPrefixValueCount in interface AddressSegmentpublic long getMaxValue()
getMaxValue in class AddressDivisionpublic boolean isMultiple()
AddressItemisMultiple in interface AddressItemisMultiple in class AddressDivisionpublic int getSegmentValue()
getSegmentValue in interface AddressSegmentpublic int getUpperSegmentValue()
getUpperSegmentValue in interface AddressSegmentpublic long getDivisionValue()
getSegmentValue() provides the same value as an intgetDivisionValue in class AddressDivisionpublic long getUpperDivisionValue()
getUpperSegmentValue() provides the same value as an intgetUpperDivisionValue in class AddressDivisionpublic abstract IPAddressSegment reverseBits(boolean perByte)
AddressComponentIncompatibleAddressException. 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.
reverseBits in interface AddressComponentreverseBits in interface AddressSegmentperByte - if true, only the bits in each byte are reversed, if false, then all bits in the component are reversedpublic abstract IPAddressSegment reverseBytes()
AddressComponentIncompatibleAddressException. 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.
reverseBytes in interface AddressComponentreverseBytes in interface AddressSegment@Deprecated public abstract IPAddressSegment removePrefixLength()
withoutPrefixLength() and toZeroHost()public abstract IPAddressSegment toZeroHost()
If there is no prefix length associated with this segment, returns an all-zero segment.
This is nearly equivalent to doing the mask (see 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() is AddressNetwork.PrefixConfiguration.ALL_PREFIXED_ADDRESSES_ARE_SUBNETS.
@Deprecated public abstract IPAddressSegment removePrefixLength(boolean zeroed)
toZeroHost() and withoutPrefixLength()zeroed - public abstract IPAddressSegment withoutPrefixLength()
public boolean isBoundedBy(int value)
AddressDivisionisBoundedBy in interface AddressStringDivisionisBoundedBy in class AddressDivisionpublic Integer getSegmentPrefixLength()
public int hashCode()
java.lang.ObjectHashMap.
The general contract of hashCode is:
hashCode method
must consistently return the same integer, provided no information
used in equals comparisons on the object is modified.
This integer need not remain consistent from one execution of an
application to another execution of the same application.
equals(Object)
method, then calling the hashCode method on each of
the two objects must produce the same integer result.
Object.equals(java.lang.Object)
method, then calling the hashCode method on each of the
two objects must produce distinct integer results. However, the
programmer should be aware that producing distinct integer results
for unequal objects may improve the performance of hash tables.
As much as is reasonably practical, the hashCode method defined by
class Object does return distinct integers for distinct
objects. (This is typically implemented by converting the internal
address of the object into an integer, but this implementation
technique is not required by the
Java™ programming language.)
hashCode in class AddressDivisionObject.equals(java.lang.Object),
System.identityHashCode(java.lang.Object)public boolean prefixEquals(IPAddressSegment other)
public boolean prefixEquals(AddressSegment other, int prefixLength)
AddressSegmentprefixEquals in interface AddressSegmentpublic boolean prefixContains(IPAddressSegment other)
other - public boolean prefixContains(IPAddressSegment other, int prefixLength)
other - prefixLength - public boolean includesZero()
AddressItemincludesZero in interface AddressItemincludesZero in class AddressDivisionpublic boolean includesMax()
AddressItemincludesMax in interface AddressItemincludesMax in class AddressDivisionpublic String toHexString(boolean with0xPrefix)
AddressComponentIf this component represents a range of values outside of the network prefix length, then this is printed as a range of two hex values.
For instance, for IPv4 addresses there are 8 hex characters, for IPv6 addresses there are 32 hex characters.
toHexString in interface AddressComponentpublic String toNormalizedString()
AddressComponentAddressSegmentSeries.toCanonicalString() in AddressComponent instances that are also AddressSegmentSeries instances.toNormalizedString in interface AddressComponentpublic String toNormalizedString(IPAddressSection.IPStringOptions options)