public abstract class IPAddressSegment extends IPAddressDivision implements AddressSegment
ADJUST_RANGES_BY_PREFIX
Modifier and Type | Method and Description |
---|---|
boolean |
contains(AddressSegment other) |
static int |
getBitCount(IPAddress.IPVersion version) |
static int |
getByteCount(IPAddress.IPVersion version) |
static int |
getDefaultTextualRadix(IPAddress.IPVersion version) |
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.
|
int |
getLowerSegmentValue()
returns the lower value
|
long |
getLowerValue()
returns the lower value as a long, although for individual segments
getLowerSegmentValue() provides the same value as an int |
static int |
getMaxSegmentValue(IPAddress.IPVersion version) |
long |
getMaxValue() |
int |
getMinPrefix() |
java.lang.Integer |
getSegmentPrefixLength() |
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.
|
int |
getUpperSegmentValue()
returns the upper value
|
long |
getUpperValue()
returns the lower upper value as a long, although for individual segments
getUpperSegmentValue() provides the same value as an int |
int |
getValueCount() |
int |
hashCode() |
boolean |
isBoundedBy(int value)
Returns true if the possible values of this division fall below the given value.
|
boolean |
isFullRange() |
static boolean |
isFullRange(int lower,
int upper,
java.lang.Integer prefix,
IPAddress.IPVersion version) |
static boolean |
isFullRange(int lower,
int upper,
IPAddress.IPVersion version) |
boolean |
isIPv4() |
boolean |
isIPv6() |
boolean |
isMaskCompatibleWithRange(int maskValue,
java.lang.Integer segmentPrefix) |
boolean |
isMaskCompatibleWithRange(IPAddressSegment maskSegment,
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)
|
abstract java.util.Iterator<? extends IPAddressSegment> |
iterator()
An address component can represent a single segment, address, or section, or it can represent multiple,
typically a subnet or range of segment, address, or section values.
|
boolean |
matches(int value) |
boolean |
matchesWithMask(int value,
int mask) |
boolean |
matchesWithPrefix(int value,
java.lang.Integer segmentPrefixLength) |
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
IPAddress.getHostSection(int) |
abstract IPAddressSegment |
toMaskedSegment(IPAddressSegment maskSegment,
java.lang.Integer segmentPrefixLength)
returns a new segment masked by the given mask
This method applies the mask first to every address in the range, and it does not preserve any existing prefix.
|
IPAddressSegment |
toNetworkSegment(java.lang.Integer segmentPrefixLength)
used by constructors of IPAddressSection, see
IPAddress.getNetworkSection(int, boolean) |
abstract IPAddressSegment |
toNetworkSegment(java.lang.Integer segmentPrefixLength,
boolean withPrefixLength)
used by getNetworkSection and by constructors of IPAddressSection, see
IPAddress.getNetworkSection(int, boolean) |
java.lang.String |
toNormalizedString()
Produces a string that is somewhat similar for all address components of the same type.
|
java.lang.String |
toNormalizedString(IPAddressSection.IPStringOptions options) |
getConfiguredString, getDivisionPrefixLength, getMaskPrefixLength, getString, getWildcardString, isBitwiseOrCompatibleWithRange, isMaskCompatibleWithRange, isPrefixed, isRangeEquivalent, isRangeEquivalentToPrefix, isRangeUnchanged, isSamePrefixedRange, matchesWithPrefix
compareTo, getCount, getDigitCount, getMaxDigitCount, hasUppercaseVariations, isZero, matches, matchesWithMask
getBytes, getBytes, getDefaultTextualRadix, getDigitCount, getMaxDigitCount, getPrefixAdjustedString, getStandardString, getUpperBytes, getUpperBytes, toString
equals, getMaxSegmentValue
getByteCount
getBitCount, getBytes, getBytes, getCount, getUpperBytes, getUpperBytes, isZero
public boolean isIPv4()
public boolean isIPv6()
public abstract IPAddress.IPVersion getIPVersion()
public int getMinPrefix()
public static int getMaxSegmentValue(IPAddress.IPVersion version)
public IPAddressSegment toNetworkSegment(java.lang.Integer segmentPrefixLength)
IPAddress.getNetworkSection(int, boolean)
public abstract IPAddressSegment toNetworkSegment(java.lang.Integer segmentPrefixLength, boolean withPrefixLength)
IPAddress.getNetworkSection(int, boolean)
public abstract IPAddressSegment toHostSegment(java.lang.Integer segmentPrefixLength)
IPAddress.getHostSection(int)
public abstract IPAddressSegment toMaskedSegment(IPAddressSegment maskSegment, java.lang.Integer segmentPrefixLength) throws AddressTypeException
AddressTypeException
is thrown.
See IPAddress.applyPrefixLength(int)
,
IPAddress#apply(IPAddress, Integer)
,
IPAddress#isMaskCompatibleWithRange(IPAddress, Integer)
AddressTypeException
public boolean isMaskCompatibleWithRange(IPAddressSegment maskSegment, java.lang.Integer segmentPrefixLength)
maskSegment
- segmentPrefixLength
- public boolean isMaskCompatibleWithRange(int maskValue, java.lang.Integer segmentPrefix)
public abstract IPAddressSegment getLower()
getLower
in interface AddressComponent
getLower
in interface AddressSegment
public abstract IPAddressSegment getUpper()
getUpper
in interface AddressComponent
getUpper
in interface AddressSegment
public abstract java.lang.Iterable<? extends IPAddressSegment> getIterable()
AddressComponent
AddressComponent.iterator()
directly.getIterable
in interface AddressComponent
getIterable
in interface AddressSegment
public abstract java.util.Iterator<? extends IPAddressSegment> iterator()
AddressComponent
AddressItem.isMultiple()
to determine if this instance represents multiple.
This method iterates through the individual elements.iterator
in interface AddressComponent
iterator
in interface AddressSegment
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 AddressSegment
public boolean matchesWithPrefix(int value, java.lang.Integer segmentPrefixLength)
public boolean matchesWithMask(int value, int mask)
matchesWithMask
in interface AddressSegment
public int getValueCount()
getValueCount
in interface AddressSegment
AddressItem.getCount()
public long getDivisionValueCount()
getDivisionValueCount
in class AddressDivision
public long getMaxValue()
getMaxValue
in class AddressDivision
public boolean isMultiple()
AddressItem
isMultiple
in interface AddressItem
isMultiple
in class AddressDivision
public int getLowerSegmentValue()
getLowerSegmentValue
in interface AddressSegment
public int getUpperSegmentValue()
getUpperSegmentValue
in interface AddressSegment
public long getLowerValue()
getLowerSegmentValue()
provides the same value as an intgetLowerValue
in class AddressDivision
public long getUpperValue()
getUpperSegmentValue()
provides the same value as an intgetUpperValue
in class AddressDivision
public abstract IPAddressSegment reverseBits(boolean perByte)
AddressComponent
reverseBits
in interface AddressComponent
reverseBits
in interface AddressSegment
perByte
- if true, only the bits in each byte are reversed, if false, then all bits in the component are reversedpublic abstract IPAddressSegment reverseBytes()
AddressComponent
reverseBytes
in interface AddressComponent
reverseBytes
in interface AddressSegment
public abstract IPAddressSegment removePrefixLength()
public abstract IPAddressSegment removePrefixLength(boolean zeroed)
public boolean isBoundedBy(int value)
AddressDivision
isBoundedBy
in interface AddressStringDivision
isBoundedBy
in class AddressDivision
public java.lang.Integer getSegmentPrefixLength()
public int hashCode()
hashCode
in class java.lang.Object
public boolean contains(AddressSegment other)
contains
in interface AddressSegment
other
- public static boolean isFullRange(int lower, int upper, java.lang.Integer prefix, IPAddress.IPVersion version)
public static boolean isFullRange(int lower, int upper, IPAddress.IPVersion version)
public boolean isFullRange()
isFullRange
in interface AddressItem
isFullRange
in class AddressDivision
public java.lang.String toHexString(boolean with0xPrefix)
AddressComponent
toHexString
in interface AddressComponent
public java.lang.String toNormalizedString()
AddressComponent
toNormalizedString
in interface AddressComponent
public java.lang.String toNormalizedString(IPAddressSection.IPStringOptions options)