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, matchesWithMaskgetBytes, getBytes, getDigitCount, getLowerStandardString, getStandardString, getString, getUpperBytes, getUpperBytes, toStringgetBytes, getBytes, getCount, getUpperBytes, getUpperBytes, includesMax, includesZero, isMax, isMultiple, isZeropublic 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 AddressSegmentpublic int getValueCount()
getValueCount in interface AddressSegmentAddressItem.getCount() as an integerpublic long getDivisionValueCount()
getDivisionValueCount in class AddressDivisionpublic int getBitCount()
getBitCount in interface AddressItempublic int getByteCount()
AddressComponentgetByteCount in interface AddressComponentpublic long getMaxValue()
getMaxValue in class AddressDivisionpublic long getLowerValue()
getLowerValue in class AddressDivisionpublic long getUpperValue()
getUpperValue in class AddressDivisionpublic int getLowerSegmentValue()
getLowerSegmentValue in interface AddressSegmentpublic int getUpperSegmentValue()
getUpperSegmentValue in interface AddressSegmentpublic MACAddressSegment getLower()
AddressSegmentgetLower in interface AddressComponentgetLower in interface AddressSegmentpublic MACAddressSegment getUpper()
AddressSegmentgetUpper in interface AddressComponentgetUpper in interface AddressSegmentpublic MACAddressSegment 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 MACAddressSegment reverseBits()
public MACAddressSegment 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 boolean isBoundedBy(int value)
AddressDivisionisBoundedBy in interface AddressStringDivisionisBoundedBy in class AddressDivisionpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object other)
equals in interface AddressSegmentequals in class java.lang.Objectpublic boolean contains(MACAddressSegment other)
other - public boolean isFullRange()
isFullRange in interface AddressItemisFullRange in class AddressDivisionpublic int getDefaultTextualRadix()
getDefaultTextualRadix in class AddressDivisionBasepublic int getMaxDigitCount()
getMaxDigitCount in class AddressDivisionBasepublic boolean matches(int value)
matches in interface AddressSegmentpublic boolean matchesWithMask(int value,
int mask)
matchesWithMask in interface AddressSegmentpublic boolean matchesWithMask(int lowerValue,
int upperValue,
int mask)
matchesWithMask in interface AddressSegmentpublic java.lang.Iterable<MACAddressSegment> getIterable()
AddressComponentAddressComponent.iterator() directly.getIterable in interface AddressComponentgetIterable in interface AddressSegmentpublic java.util.Iterator<MACAddressSegment> iterator()
AddressComponentAn 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 AddressComponentiterator in interface AddressSegmentiterator in interface java.lang.Iterable<MACAddressSegment>public int getMaxSegmentValue()
AddressSegmentAddressSegment.getUpper()getMaxSegmentValue in interface AddressSegmentpublic boolean contains(AddressSegment other)
contains in interface AddressSegmentpublic 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(AddressDivisionGrouping.StringOptions options)