public class MACAddressSegment extends AddressDivision implements AddressSegment, Iterable<MACAddressSegment>
AddressDivision.BitwiseOrResult, AddressDivision.MaskResult
Modifier and Type | Field and Description |
---|---|
static int |
MAX_CHARS |
EXTENDED_DIGITS
Constructor and Description |
---|
MACAddressSegment(int value)
Constructs a segment of an IPv4 or IPv6 address with the given value.
|
MACAddressSegment(int lower,
int upper)
Constructs a segment of a MAC address that represents a range of values.
|
Modifier and Type | Method and Description |
---|---|
boolean |
contains(AddressSegment other) |
boolean |
contains(MACAddressSegment other) |
boolean |
containsPrefixBlock(int divisionPrefixLen)
Returns whether the values of this series contains the prefix block for the given prefix length.
|
boolean |
containsSinglePrefixBlock(int divisionPrefixLen)
Returns whether the division range matches exactly the block of values for the given prefix length.
|
boolean |
equals(Object other)
Two divisions are equal if they:
- they match type/version (ipv4, ipv6, mac, or a specific division class)
- match bit counts
- match values
Prefix lengths, for those divisions that have them, are ignored.
|
int |
getBitCount()
Provides the number of bits comprising this address item
|
int |
getByteCount()
Provides the number of bytes required for this address item, rounding up if the bit count is not a multiple of 8
|
int |
getDefaultTextualRadix() |
long |
getDivisionValue() |
Iterable<MACAddressSegment> |
getIterable()
Useful for using an instance in a "for-each loop".
|
MACAddressSegment |
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() |
long |
getMaxValue() |
MACAddressNetwork |
getNetwork()
Returns the network object for components of the same version (eg IPv4, IPv6 and MAC each have their own network object)
|
int |
getPrefixValueCount(int segmentPrefixLength)
Returns the count of prefix values in this address segment for the given prefix bit count.
|
int |
getSegmentValue()
returns the lower value
|
MACAddressSegment |
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() |
int |
getUpperSegmentValue()
returns the upper value
|
int |
getValueCount()
Returns the count of values in this address segment.
|
int |
hashCode() |
boolean |
isBoundedBy(int value)
Returns true if the possible values of this division fall below the given value.
|
Iterator<MACAddressSegment> |
iterator()
Iterates through the individual address components.
|
boolean |
matches(int value) |
boolean |
matchesWithMask(int value,
int mask) |
boolean |
matchesWithMask(int lowerValue,
int upperValue,
int mask) |
boolean |
overlaps(AddressSegment other) |
boolean |
prefixEquals(AddressSegment o,
int segmentPrefixLength)
Returns whether the given prefix bits match the same bits of the given segment.
|
MACAddressSegment |
reverseBits() |
MACAddressSegment |
reverseBits(boolean perByte)
Returns a new AddressComponent with the bits reversed.
|
MACAddressSegment |
reverseBytes()
Returns an AddressComponent with the bytes reversed.
|
AddressComponentSpliterator<MACAddressSegment> |
spliterator()
Partitions and traverses through the individual address components.
|
Stream<MACAddressSegment> |
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.
|
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(AddressDivisionGrouping.StringOptions options) |
bitwiseOrRange, getDigitCount, getMaxDigitCount, getMinPrefixLengthForBlock, getPrefixLengthForSingleBlock, getUpperValue, getValue, hasUppercaseVariations, includesMax, includesZero, isBitwiseOrCompatibleWithRange, isMaskCompatibleWithRange, isMax, isMultiple, isZero, maskRange, matches, matchesWithMask, matchesWithMask
getBytes, getBytes, getBytes, getDigitCount, getDigitCount, getLowerStandardString, getStandardString, getUpperBytes, getUpperBytes, getUpperBytes, toString
isOneBit, testBit
stream, stream
compareTo, getBitsForCount, getBlockSize, getBytes, getBytes, getBytes, getCount, getMinPrefixLengthForBlock, getPrefixCount, getPrefixLengthForSingleBlock, getUpperBytes, getUpperBytes, getUpperBytes, getUpperValue, getValue, includesMax, includesZero, isFullRange, isMax, isMultiple, isZero
getDigitCount, getLowerStandardString, getMaxDigitCount, getStandardString
public static final int MAX_CHARS
public MACAddressSegment(int value)
value
- the value of the segmentAddressValueException
- if value is negative or too largepublic MACAddressSegment(int lower, int upper)
lower
- the lower value of the range of values represented by the segment.upper
- the upper value of the range of values represented by the segment.AddressValueException
- if value is negative or too largepublic MACAddressNetwork getNetwork()
AddressComponent
getNetwork
in interface AddressComponent
public int getValueCount()
AddressSegment
getValueCount
in interface AddressSegment
AddressItem.getCount()
as an integerpublic int getPrefixValueCount(int segmentPrefixLength)
AddressSegment
getPrefixValueCount
in interface AddressSegment
public int getBitCount()
AddressItem
getBitCount
in interface AddressItem
public int getByteCount()
AddressItem
getByteCount
in interface AddressItem
public long getMaxValue()
getMaxValue
in class AddressDivision
public long getDivisionValue()
getDivisionValue
in class AddressDivision
public long getUpperDivisionValue()
getUpperDivisionValue
in class AddressDivision
public int getSegmentValue()
getSegmentValue
in interface AddressSegment
public int getUpperSegmentValue()
getUpperSegmentValue
in interface AddressSegment
public MACAddressSegment getLower()
AddressSegment
getLower
in interface AddressSegment
getLower
in interface AddressComponentRange
public MACAddressSegment getUpper()
AddressSegment
getUpper
in interface AddressSegment
getUpper
in interface AddressComponentRange
public MACAddressSegment 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
perByte
- if true, only the bits in each byte are reversed, if false, then all bits in the component are reversedpublic MACAddressSegment reverseBits()
public MACAddressSegment 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
public boolean isBoundedBy(int value)
AddressDivision
isBoundedBy
in interface AddressStringDivision
isBoundedBy
in class AddressDivision
public int hashCode()
hashCode
in class AddressDivision
public boolean equals(Object other)
AddressDivisionBase
equals
in interface AddressSegment
equals
in class AddressDivision
public boolean contains(MACAddressSegment other)
other
- public int getDefaultTextualRadix()
public int getMaxDigitCount()
public boolean matches(int value)
matches
in interface AddressSegment
public boolean matchesWithMask(int value, int mask)
matchesWithMask
in interface AddressSegment
public boolean matchesWithMask(int lowerValue, int upperValue, int mask)
matchesWithMask
in interface AddressSegment
public Iterable<MACAddressSegment> getIterable()
AddressComponentRange
AddressComponentRange.iterator()
directly.getIterable
in interface AddressSegment
getIterable
in interface AddressComponentRange
public Iterator<MACAddressSegment> 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 AddressSegment
iterator
in interface AddressComponentRange
iterator
in interface Iterable<MACAddressSegment>
public AddressComponentSpliterator<MACAddressSegment> spliterator()
AddressComponentRange
spliterator
in interface AddressComponent
spliterator
in interface AddressSegment
spliterator
in interface AddressComponentRange
spliterator
in interface Iterable<MACAddressSegment>
public Stream<MACAddressSegment> stream()
AddressComponentRange
BaseStream.parallel()
on the returned stream.stream
in interface AddressSegment
stream
in interface AddressComponentRange
public int getMaxSegmentValue()
AddressSegment
AddressSegment.getUpper()
getMaxSegmentValue
in interface AddressSegment
public boolean prefixEquals(AddressSegment o, int segmentPrefixLength)
AddressSegment
prefixEquals
in interface AddressSegment
public boolean overlaps(AddressSegment other)
overlaps
in interface AddressSegment
public boolean contains(AddressSegment other)
contains
in interface AddressSegment
public String toHexString(boolean with0xPrefix)
AddressComponent
If 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 AddressComponent
public String toNormalizedString()
AddressComponent
AddressSegmentSeries.toCanonicalString()
in AddressComponent
instances that are also AddressSegmentSeries
instances.toNormalizedString
in interface AddressComponent
public String toNormalizedString(AddressDivisionGrouping.StringOptions options)
public boolean containsPrefixBlock(int divisionPrefixLen)
AddressItem
Use AddressItem.getMinPrefixLengthForBlock()
to determine the smallest prefix length for which this method returns true.
containsPrefixBlock
in interface AddressItem
public boolean containsSinglePrefixBlock(int divisionPrefixLen)
containsSinglePrefixBlock
in interface AddressItem
divisionPrefixLen
-