public class IPv4AddressSegment extends IPAddressSegment implements java.lang.Iterable<IPv4AddressSegment>
Modifier and Type | Field and Description |
---|---|
static int |
MAX_CHARS
When printed with the default radix of 10, the max number of characters per segment
|
Constructor and Description |
---|
IPv4AddressSegment(int value)
Constructs a segment of an IPv4 address with the given value.
|
IPv4AddressSegment(int value,
java.lang.Integer segmentPrefixLength)
Constructs a segment of an IPv4 address.
|
IPv4AddressSegment(int lower,
int upper,
java.lang.Integer segmentPrefixLength)
Constructs a segment of an IPv4 address that represents a range of values.
|
Modifier and Type | Method and Description |
---|---|
boolean |
contains(AddressSegment other) |
boolean |
equals(java.lang.Object other) |
int |
getBitCount() |
int |
getByteCount()
returns the number of bytes in each of the address components represented by this instance
|
int |
getDefaultTextualRadix() |
IPAddress.IPVersion |
getIPVersion() |
java.lang.Iterable<IPv4AddressSegment> |
getIterable()
Useful for using an instance in a "for-each loop".
|
IPv4AddressSegment |
getLower()
If this segment represents a range of values, returns a segment representing just the lowest value in the range, otherwise returns this.
|
int |
getMaxDigitCount() |
int |
getMaxSegmentValue()
Gets the maximum possible value for this type of segment (for the highest range value of this particular segment, use
AddressSegment.getUpper() |
IPv4AddressNetwork |
getNetwork() |
IPv4AddressNetwork.IPv4AddressCreator |
getSegmentCreator() |
IPv4AddressSegment |
getUpper()
If this segment represents a range of values, returns a segment representing just the highest value in the range, otherwise returns this.
|
boolean |
isIPv4() |
java.util.Iterator<IPv4AddressSegment> |
iterator()
Iterates through the individual elements of this address component.
|
IPv6AddressSegment |
join(IPv6AddressNetwork.IPv6AddressCreator creator,
IPv4AddressSegment low)
Joins with another IPv4 segment to produce a IPv6 segment.
|
java.util.Iterator<IPv4AddressSegment> |
prefixBlockIterator()
Iterates through the individual prefix blocks.
|
IPv4AddressSegment |
removePrefixLength() |
IPv4AddressSegment |
removePrefixLength(boolean zeroed) |
IPv4AddressSegment |
reverseBits() |
IPv4AddressSegment |
reverseBits(boolean perByte)
Returns a new AddressComponent with the bits reversed.
|
IPv4AddressSegment |
reverseBytes()
Returns an AddressComponent with the bytes reversed.
|
IPv4AddressSegment |
toHostSegment(java.lang.Integer bits)
used by getHostSection, see
IPAddressSegmentSeries.getHostSection(int) |
IPv4AddressSegment |
toNetworkSegment(java.lang.Integer segmentPrefixLength)
used by constructors of IPAddressSection, see
IPAddressSegmentSeries.getNetworkSection(int, boolean) |
IPv4AddressSegment |
toNetworkSegment(java.lang.Integer segmentPrefixLength,
boolean withPrefixLength)
used by getNetworkSection and by constructors of IPAddressSection, see
IPAddressSegmentSeries.getNetworkSection(int, boolean) |
getBitCount, getByteCount, getDefaultTextualRadix, getDivisionValueCount, getLowerSegmentValue, getLowerValue, getMaxSegmentValue, getMaxValue, getMinPrefixLengthForBlock, getPrefixValueCount, getSegmentPrefixLength, getUpperSegmentValue, getUpperValue, getValueCount, hashCode, includesMax, includesZero, isBitwiseOrCompatibleWithRange, isBoundedBy, isIPv6, isMaskCompatibleWithRange, isMultiple, isPrefixBlock, matches, matchesWithMask, matchesWithMask, matchesWithPrefixMask, toHexString, toNormalizedString, toNormalizedString
getBlockMaskPrefixLength, getDivisionPrefixLength, getPrefixAdjustedRangeString, getString, getWildcardString, isPrefixBlock, isPrefixed, isSinglePrefixBlock, isSinglePrefixBlock, matchesWithPrefixMask
compareTo, getCount, getDigitCount, getDivisionPrefixCount, getMaxDigitCount, hasUppercaseVariations, isFullRange, isMax, isZero, matches, matchesWithMask, matchesWithMask
getBytes, getBytes, getDigitCount, getLowerStandardString, getStandardString, getUpperBytes, getUpperBytes, toString
getBytes, getBytes, getCount, getUpperBytes, getUpperBytes, isFullRange, isMax, isZero
isFullRange
getDigitCount, getLowerStandardString, getMaxDigitCount, getStandardString
public static final int MAX_CHARS
public IPv4AddressSegment(int value) throws AddressValueException
value
- the value of the segmentAddressValueException
- if value is negative or too largepublic IPv4AddressSegment(int value, java.lang.Integer segmentPrefixLength) throws AddressValueException
value
- the value of the segment. If the segmentPrefixLength is non-null, the network prefix of the value is used, and the segment represents all segment values with the same network prefix.segmentPrefixLength
- the segment prefix, which can be nullAddressValueException
- if value or prefix length is negative or too largepublic IPv4AddressSegment(int lower, int upper, java.lang.Integer segmentPrefixLength) throws AddressValueException
segmentPrefixLength
- the segment prefix length, which can be null. If segmentPrefixLength is non-null, this segment represents a range of segment values with the given network prefix length.lower
- the lower value of the range of values represented by the segment. If segmentPrefixLength is non-null, the lower value becomes the smallest value with the same network prefix.upper
- the upper value of the range of values represented by the segment. If segmentPrefixLength is non-null, the upper value becomes the largest value with the same network prefix.AddressValueException
- if either lower or upper value or prefix length is negative or too largepublic boolean isIPv4()
isIPv4
in class IPAddressSegment
public IPAddress.IPVersion getIPVersion()
getIPVersion
in class IPAddressSegment
public int getMaxSegmentValue()
AddressSegment
AddressSegment.getUpper()
getMaxSegmentValue
in interface AddressSegment
public IPv4AddressSegment toNetworkSegment(java.lang.Integer segmentPrefixLength)
IPAddressSegment
IPAddressSegmentSeries.getNetworkSection(int, boolean)
toNetworkSegment
in class IPAddressSegment
public IPv4AddressSegment toNetworkSegment(java.lang.Integer segmentPrefixLength, boolean withPrefixLength)
IPAddressSegment
IPAddressSegmentSeries.getNetworkSection(int, boolean)
toNetworkSegment
in class IPAddressSegment
public IPv4AddressSegment toHostSegment(java.lang.Integer bits)
IPAddressSegment
IPAddressSegmentSeries.getHostSection(int)
toHostSegment
in class IPAddressSegment
public IPv4AddressSegment getLower()
IPAddressSegment
getLower
in interface AddressComponent
getLower
in interface AddressSegment
getLower
in class IPAddressSegment
public IPv4AddressSegment getUpper()
IPAddressSegment
getUpper
in interface AddressComponent
getUpper
in interface AddressSegment
getUpper
in class IPAddressSegment
public IPv4AddressNetwork getNetwork()
getNetwork
in interface AddressSegment
getNetwork
in class IPAddressSegment
public IPv4AddressNetwork.IPv4AddressCreator getSegmentCreator()
public java.lang.Iterable<IPv4AddressSegment> getIterable()
AddressComponent
AddressComponent.iterator()
directly.getIterable
in interface AddressComponent
getIterable
in interface AddressSegment
getIterable
in class IPAddressSegment
public java.util.Iterator<IPv4AddressSegment> iterator()
AddressComponent
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.
Call AddressItem.isMultiple()
to determine if this instance represents multiple.
iterator
in interface AddressComponent
iterator
in interface AddressSegment
iterator
in interface java.lang.Iterable<IPv4AddressSegment>
iterator
in class IPAddressSegment
public java.util.Iterator<IPv4AddressSegment> prefixBlockIterator()
IPAddressSegment
IPAddressSegment.iterator()
prefixBlockIterator
in class IPAddressSegment
public int getBitCount()
getBitCount
in interface AddressItem
getBitCount
in interface IPAddressStringDivision
public int getByteCount()
AddressComponent
getByteCount
in interface AddressComponent
public int getDefaultTextualRadix()
getDefaultTextualRadix
in class AddressDivisionBase
public int getMaxDigitCount()
getMaxDigitCount
in class AddressDivisionBase
public IPv4AddressSegment reverseBits(boolean perByte)
AddressComponent
IncompatibleAddressException
. 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 AddressComponent
reverseBits
in interface AddressSegment
reverseBits
in class IPAddressSegment
perByte
- if true, only the bits in each byte are reversed, if false, then all bits in the component are reversedpublic IPv4AddressSegment reverseBits()
public IPv4AddressSegment reverseBytes()
AddressComponent
IncompatibleAddressException
. 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 AddressComponent
reverseBytes
in interface AddressSegment
reverseBytes
in class IPAddressSegment
public IPv4AddressSegment removePrefixLength(boolean zeroed)
removePrefixLength
in class IPAddressSegment
public IPv4AddressSegment removePrefixLength()
removePrefixLength
in class IPAddressSegment
public boolean contains(AddressSegment other)
contains
in interface AddressSegment
public boolean equals(java.lang.Object other)
equals
in interface AddressSegment
equals
in class java.lang.Object
public IPv6AddressSegment join(IPv6AddressNetwork.IPv6AddressCreator creator, IPv4AddressSegment low) throws IncompatibleAddressException
creator
- low
- IncompatibleAddressException