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()
Returns a hash code value for the object.
|
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 |
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, matchesWithMaskgetBytes, getBytes, getBytes, getDigitCount, getLowerStandardString, getStandardString, getUpperBytes, getUpperBytes, getUpperBytes, toStringisOneBit, testBitstream, streamcompareTo, getBytes, getBytes, getBytes, getCount, getMinPrefixLengthForBlock, getPrefixCount, getPrefixLengthForSingleBlock, getUpperBytes, getUpperBytes, getUpperBytes, getUpperValue, getValue, includesMax, includesZero, isFullRange, isMax, isMultiple, isZerogetDigitCount, getLowerStandardString, getMaxDigitCount, getStandardStringpublic 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()
AddressComponentgetNetwork in interface AddressComponentpublic int getValueCount()
AddressSegmentgetValueCount in interface AddressSegmentAddressItem.getCount() as an integerpublic int getPrefixValueCount(int segmentPrefixLength)
AddressSegmentgetPrefixValueCount in interface AddressSegmentpublic int getBitCount()
AddressItemgetBitCount in interface AddressItempublic int getByteCount()
AddressItemgetByteCount in interface AddressItempublic long getMaxValue()
getMaxValue in class AddressDivisionpublic long getDivisionValue()
getDivisionValue in class AddressDivisionpublic long getUpperDivisionValue()
getUpperDivisionValue in class AddressDivisionpublic int getSegmentValue()
getSegmentValue in interface AddressSegmentpublic int getUpperSegmentValue()
getUpperSegmentValue in interface AddressSegmentpublic MACAddressSegment getLower()
AddressSegmentgetLower in interface AddressSegmentgetLower in interface AddressComponentRangepublic MACAddressSegment getUpper()
AddressSegmentgetUpper in interface AddressSegmentgetUpper in interface AddressComponentRangepublic 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()
java.lang.ObjectHashMap.
The general contract of hashCode is:
hashCode method
must consistently return the same integer, provided no information
used in equals comparisons on the object is modified.
This integer need not remain consistent from one execution of an
application to another execution of the same application.
equals(Object)
method, then calling the hashCode method on each of
the two objects must produce the same integer result.
Object.equals(java.lang.Object)
method, then calling the hashCode method on each of the
two objects must produce distinct integer results. However, the
programmer should be aware that producing distinct integer results
for unequal objects may improve the performance of hash tables.
As much as is reasonably practical, the hashCode method defined by
class Object does return distinct integers for distinct
objects. (This is typically implemented by converting the internal
address of the object into an integer, but this implementation
technique is not required by the
Java™ programming language.)
hashCode in class AddressDivisionObject.equals(java.lang.Object),
System.identityHashCode(java.lang.Object)public boolean equals(Object other)
AddressDivisionBaseequals in interface AddressSegmentequals in class AddressDivisionother - the reference object with which to compare.true if this object is the same as the obj
argument; false otherwise.Object.hashCode(),
HashMappublic boolean contains(MACAddressSegment other)
other - public int getDefaultTextualRadix()
public int getMaxDigitCount()
public 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 Iterable<MACAddressSegment> getIterable()
AddressComponentRangeAddressComponentRange.iterator() directly.getIterable in interface AddressSegmentgetIterable in interface AddressComponentRangepublic Iterator<MACAddressSegment> iterator()
AddressComponentRangeAn 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 AddressSegmentiterator in interface AddressComponentRangeiterator in interface Iterable<MACAddressSegment>public AddressComponentSpliterator<MACAddressSegment> spliterator()
AddressComponentRangespliterator in interface AddressComponentspliterator in interface AddressSegmentspliterator in interface AddressComponentRangespliterator in interface Iterable<MACAddressSegment>Spliterator over the elements described by this
Iterable.public Stream<MACAddressSegment> stream()
AddressComponentRangeBaseStream.parallel() on the returned stream.stream in interface AddressSegmentstream in interface AddressComponentRangepublic int getMaxSegmentValue()
AddressSegmentAddressSegment.getUpper()getMaxSegmentValue in interface AddressSegmentpublic boolean prefixEquals(AddressSegment o, int segmentPrefixLength)
AddressSegmentprefixEquals in interface AddressSegmentpublic boolean contains(AddressSegment other)
contains in interface AddressSegmentpublic 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 String toNormalizedString()
AddressComponentAddressSegmentSeries.toCanonicalString() in AddressComponent instances that are also AddressSegmentSeries instances.toNormalizedString in interface AddressComponentpublic 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 AddressItempublic boolean containsSinglePrefixBlock(int divisionPrefixLen)
containsSinglePrefixBlock in interface AddressItemdivisionPrefixLen -