public class MACAddressSegment extends AddressDivision implements AddressSegment, java.lang.Iterable<MACAddressSegment>
Modifier and Type | Field and Description |
---|---|
static int |
MAX_CHARS |
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 |
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() |
long |
getDivisionValueCount() |
java.lang.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 |
getLowerSegmentValue()
returns the lower value
|
long |
getLowerValue() |
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() |
MACAddressSegment |
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() |
int |
getValueCount() |
int |
hashCode() |
boolean |
isBoundedBy(int value)
Returns true if the possible values of this division fall below the given value.
|
boolean |
isFullRange() |
java.util.Iterator<MACAddressSegment> |
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) |
MACAddressSegment |
reverseBits() |
MACAddressSegment |
reverseBits(boolean perByte)
Returns a new AddressComponent with the bits reversed.
|
MACAddressSegment |
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.
|
java.lang.String |
toNormalizedString()
Produces a string that is somewhat similar for all address components of the same type.
|
java.lang.String |
toNormalizedString(AddressDivisionGrouping.StringOptions options) |
compareTo, getCount, getDigitCount, getDivisionPrefixCount, getMaxDigitCount, hasUppercaseVariations, includesMax, includesZero, isMax, isMultiple, isZero, matches, matchesWithMask, matchesWithMask
getBytes, getBytes, getDigitCount, getLowerStandardString, getStandardString, getString, getUpperBytes, getUpperBytes, toString
getBytes, getBytes, getCount, getUpperBytes, getUpperBytes, includesMax, includesZero, isMax, isMultiple, isZero
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()
getNetwork
in interface AddressSegment
public int getValueCount()
getValueCount
in interface AddressSegment
AddressItem.getCount()
as an integerpublic long getDivisionValueCount()
getDivisionValueCount
in class AddressDivision
public int getBitCount()
getBitCount
in interface AddressItem
public int getByteCount()
AddressComponent
getByteCount
in interface AddressComponent
public long getMaxValue()
getMaxValue
in class AddressDivision
public long getLowerValue()
getLowerValue
in class AddressDivision
public long getUpperValue()
getUpperValue
in class AddressDivision
public int getLowerSegmentValue()
getLowerSegmentValue
in interface AddressSegment
public int getUpperSegmentValue()
getUpperSegmentValue
in interface AddressSegment
public MACAddressSegment getLower()
AddressSegment
getLower
in interface AddressComponent
getLower
in interface AddressSegment
public MACAddressSegment getUpper()
AddressSegment
getUpper
in interface AddressComponent
getUpper
in interface AddressSegment
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 java.lang.Object
public boolean equals(java.lang.Object other)
equals
in interface AddressSegment
equals
in class java.lang.Object
public boolean contains(MACAddressSegment other)
other
- public boolean isFullRange()
isFullRange
in interface AddressItem
isFullRange
in class AddressDivision
public int getDefaultTextualRadix()
getDefaultTextualRadix
in class AddressDivisionBase
public int getMaxDigitCount()
getMaxDigitCount
in class AddressDivisionBase
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 java.lang.Iterable<MACAddressSegment> getIterable()
AddressComponent
AddressComponent.iterator()
directly.getIterable
in interface AddressComponent
getIterable
in interface AddressSegment
public java.util.Iterator<MACAddressSegment> 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<MACAddressSegment>
public int getMaxSegmentValue()
AddressSegment
AddressSegment.getUpper()
getMaxSegmentValue
in interface AddressSegment
public boolean contains(AddressSegment other)
contains
in interface AddressSegment
public java.lang.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 java.lang.String toNormalizedString()
AddressComponent
toNormalizedString
in interface AddressComponent
public java.lang.String toNormalizedString(AddressDivisionGrouping.StringOptions options)