public abstract class IPAddressSegment extends IPAddressDivision implements AddressSegment
| Modifier and Type | Method and Description |
|---|---|
static int |
getBitCount(IPAddress.IPVersion version) |
static int |
getByteCount(IPAddress.IPVersion version) |
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 |
long |
getDivisionValueCount() |
abstract IPAddress.IPVersion |
getIPVersion() |
abstract java.lang.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() |
int |
getPrefixValueCount()
Counts the number of prefixes in this address segment.
|
java.lang.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() |
int |
hashCode() |
boolean |
includesMax() |
boolean |
includesZero() |
boolean |
isBitwiseOrCompatibleWithRange(int maskValue,
java.lang.Integer segmentPrefixLength)
Similar to masking, checks that the range resulting from the bitwise or is contiguous.
|
boolean |
isBoundedBy(int value)
Returns true if the possible values of this division fall below the given value.
|
boolean |
isIPv4() |
boolean |
isIPv6() |
boolean |
isMaskCompatibleWithRange(int maskValue,
java.lang.Integer segmentPrefixLength)
Check that the range resulting from the mask is contiguous, otherwise we cannot represent it.
|
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 java.util.Iterator<? extends IPAddressSegment> |
iterator()
Iterates through the individual elements of this address component.
|
boolean |
matches(int value) |
boolean |
matchesWithMask(int value,
int mask) |
boolean |
matchesWithMask(int lowerValue,
int upperValue,
int mask) |
boolean |
matchesWithPrefixMask(int value,
java.lang.Integer segmentPrefixLength) |
abstract java.util.Iterator<? extends IPAddressSegment> |
prefixBlockIterator()
Iterates through the individual prefix blocks.
|
abstract java.util.Iterator<? extends IPAddressSegment> |
prefixBlockIterator(int prefixLength)
Iterates through the individual prefix blocks according to the given segment prefix length.
|
boolean |
prefixEquals(AddressSegment other,
int prefixLength) |
boolean |
prefixEquals(IPAddressSegment other) |
abstract java.util.Iterator<? extends IPAddressSegment> |
prefixIterator()
Iterates through the individual prefixes.
|
abstract IPAddressSegment |
removePrefixLength() |
abstract IPAddressSegment |
removePrefixLength(boolean zeroed) |
abstract IPAddressSegment |
reverseBits(boolean perByte)
Returns a new AddressComponent with the bits reversed.
|
abstract IPAddressSegment |
reverseBytes()
Returns an AddressComponent with the bytes reversed.
|
java.lang.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(java.lang.Integer segmentPrefixLength)
used by getHostSection, see
IPAddressSegmentSeries.getHostSection(int) |
IPAddressSegment |
toNetworkSegment(java.lang.Integer segmentPrefixLength)
used by constructors of IPAddressSection, see
IPAddressSegmentSeries.getNetworkSection(int, boolean) |
abstract IPAddressSegment |
toNetworkSegment(java.lang.Integer segmentPrefixLength,
boolean withPrefixLength)
used by getNetworkSection and by constructors of IPAddressSection, see
IPAddressSegmentSeries.getNetworkSection(int, boolean) |
java.lang.String |
toNormalizedString()
Produces a string that is consistent for all address components of the same type and version.
|
java.lang.String |
toNormalizedString(IPAddressSection.IPStringOptions options) |
abstract IPAddressSegment |
withoutPrefixLength() |
containsPrefixBlock, containsSinglePrefixBlock, getBlockMaskPrefixLength, getDivisionPrefixLength, getPrefixAdjustedRangeString, getString, getWildcardString, isPrefixed, isSinglePrefixBlock, matchesWithPrefixMaskequals, getCount, getDigitCount, getDivisionPrefixCount, getMaxDigitCount, getPrefixCount, getPrefixLengthForSingleBlock, getUpperValue, getValue, hasUppercaseVariations, isMax, isZero, matches, matchesWithMask, matchesWithMaskgetBytes, getBytes, getBytes, getDigitCount, getLowerStandardString, getStandardString, getUpperBytes, getUpperBytes, getUpperBytes, toStringcontains, equals, getMaxSegmentValuecompareTo, containsPrefixBlock, containsSinglePrefixBlock, getBitCount, getByteCount, getBytes, getBytes, getBytes, getCount, getPrefixCount, getPrefixLengthForSingleBlock, getUpperBytes, getUpperBytes, getUpperBytes, getUpperValue, getValue, isFullRange, isMax, isZero, testRange, testRangegetDigitCount, getLowerStandardString, getMaxDigitCount, getStandardStringisFullRangegetBitCountpublic abstract IPAddressNetwork<?,?,?,?,?> getNetwork()
getNetwork in interface AddressSegmentpublic 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(java.lang.Integer segmentPrefixLength)
IPAddressSegmentSeries.getNetworkSection(int, boolean)public abstract IPAddressSegment toNetworkSegment(java.lang.Integer segmentPrefixLength, boolean withPrefixLength)
IPAddressSegmentSeries.getNetworkSection(int, boolean)public abstract IPAddressSegment toHostSegment(java.lang.Integer segmentPrefixLength)
IPAddressSegmentSeries.getHostSection(int)public boolean isMaskCompatibleWithRange(int maskValue,
java.lang.Integer segmentPrefixLength)
throws PrefixLenException
maskValue - segmentPrefixLength - PrefixLenExceptionpublic boolean isBitwiseOrCompatibleWithRange(int maskValue,
java.lang.Integer segmentPrefixLength)
throws PrefixLenException
maskValue - segmentPrefixLength - PrefixLenExceptionpublic abstract IPAddressSegment getLower()
getLower in interface AddressComponentgetLower in interface AddressSegmentgetLower in interface AddressItemRangepublic abstract IPAddressSegment getUpper()
getUpper in interface AddressComponentgetUpper in interface AddressSegmentgetUpper in interface AddressItemRangepublic abstract java.lang.Iterable<? extends IPAddressSegment> getIterable()
AddressItemRangeAddressItemRange.iterator() directly.getIterable in interface AddressComponentgetIterable in interface AddressSegmentgetIterable in interface AddressItemRangepublic abstract java.util.Iterator<? extends IPAddressSegment> iterator()
AddressComponentAn address component can represent a single 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.
iterator in interface AddressComponentiterator in interface AddressSegmentiterator in interface AddressItemRangepublic abstract java.util.Iterator<? extends IPAddressSegment> prefixBlockIterator()
If the series has no prefix length, then this is equivalent to iterator()
public abstract java.util.Iterator<? extends IPAddressSegment> prefixIterator()
If the series has no prefix length, then this is equivalent to iterator()
public abstract java.util.Iterator<? extends IPAddressSegment> prefixBlockIterator(int prefixLength)
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,
java.lang.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()
getValueCount in interface AddressSegmentAddressItem.getCount() as an integerpublic int getPrefixValueCount()
If this segment has no prefix length, this is equivalent to getValueCount()
public long getDivisionValueCount()
getDivisionValueCount in class AddressDivisionpublic 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 AddressSegmentpublic abstract IPAddressSegment removePrefixLength()
public abstract IPAddressSegment removePrefixLength(boolean zeroed)
public abstract IPAddressSegment withoutPrefixLength()
public boolean isBoundedBy(int value)
AddressDivisionisBoundedBy in interface AddressStringDivisionisBoundedBy in class AddressDivisionpublic java.lang.Integer getSegmentPrefixLength()
public int hashCode()
hashCode in class AddressDivisionpublic boolean prefixEquals(IPAddressSegment other)
public boolean prefixEquals(AddressSegment other, int prefixLength)
prefixEquals in interface AddressSegmentpublic boolean includesZero()
includesZero in interface AddressItemincludesZero in class AddressDivisionpublic boolean includesMax()
includesMax in interface AddressItemincludesMax in class AddressDivisionpublic java.lang.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 java.lang.String toNormalizedString()
AddressComponenttoNormalizedString in interface AddressComponentpublic java.lang.String toNormalizedString(IPAddressSection.IPStringOptions options)