public class MACAddressSection extends AddressDivisionGrouping implements AddressSection, java.lang.Iterable<MACAddressSection>
Modifier and Type | Class and Description |
---|---|
static class |
MACAddressSection.MACStringOptions
Represents a clear way to create a specific type of string.
|
AddressDivisionGrouping.StringOptions
Modifier and Type | Field and Description |
---|---|
boolean |
extended |
int |
startIndex |
Constructor and Description |
---|
MACAddressSection(byte[] bytes) |
MACAddressSection(byte[] bytes,
int startIndex,
boolean extended) |
MACAddressSection(byte[] bytes,
int startIndex,
boolean extended,
java.lang.Integer prefixLength) |
MACAddressSection(byte[] bytes,
java.lang.Integer prefixLength) |
MACAddressSection(long value) |
MACAddressSection(long value,
int startIndex,
boolean extended) |
MACAddressSection(long value,
int startIndex,
boolean extended,
java.lang.Integer prefixLength) |
MACAddressSection(long value,
java.lang.Integer prefixLength) |
MACAddressSection(MACAddressSegment segment)
Constructs a single segment section, the segment being the leading segment.
|
MACAddressSection(MACAddressSegment[] segments)
Use this constructor for any address section that includes the leading segment of a MAC address
|
MACAddressSection(MACAddressSegment[] segments,
int startIndex,
boolean extended) |
MACAddressSection(MACAddressSegment[] segments,
int startIndex,
boolean extended,
java.lang.Integer prefixLength) |
MACAddressSection(MACAddressSegment[] segments,
java.lang.Integer prefixLength) |
MACAddressSection(MACAddressSegment segment,
int startIndex,
boolean extended)
Constructs a single segment section with the segment at the given index in the address.
|
Modifier and Type | Method and Description |
---|---|
MACAddressSection |
adjustPrefixBySegment(boolean nextSegment)
Increases or decreases prefix length to the next segment boundary.
|
MACAddressSection |
adjustPrefixLength(int adjustment)
Increases or decreases prefix length by the given increment.
|
MACAddressSection |
append(MACAddressSection other) |
MACAddressSection |
applyPrefixLength(int prefixLength)
Applies the given prefix length to create a new segment series representing all segment series starting with the same prefix.
|
boolean |
contains(AddressSection other)
Determines if one section contains another.
|
boolean |
contains(MACAddressSection other) |
boolean |
equals(java.lang.Object o) |
int |
getBitCount() |
int |
getBitsPerSegment() |
int |
getByteCount()
returns the number of bytes in each of the address components represented by this instance
|
int |
getBytesPerSegment() |
AddressDivisionGrouping |
getDottedGrouping() |
java.lang.Iterable<MACAddressSection> |
getIterable()
Useful for using an instance in a "for-each loop".
|
MACAddressSection |
getLower()
If this instance represents multiple address components, returns the one with the lowest numeric value.
|
MACAddressSection |
getODISection() |
int |
getODISegmentCount() |
MACAddressSection |
getOUISection() |
int |
getOUISegmentCount() |
java.lang.Integer |
getPrefixLength()
The bit-length of the portion of the address that is not specific to an individual address but common amongst a group of addresses.
|
MACAddressSection |
getSection(int index)
Gets the subsection from the series starting from the given index
|
MACAddressSection |
getSection(int index,
int endIndex)
Gets the subsection from the series starting from the given index and ending just before the give endIndex
|
MACAddressSegment |
getSegment(int index) |
int |
getSegmentCount() |
MACAddressSegment[] |
getSegments() |
void |
getSegments(AddressSegment[] segs) |
void |
getSegments(java.util.Collection<? super MACAddressSegment> segs) |
void |
getSegments(int start,
int end,
AddressSegment[] segs,
int destIndex)
get the segments from start to end and insert into the segs array at the the given index
|
void |
getSegments(int start,
int end,
java.util.Collection<? super MACAddressSegment> segs) |
MACAddressSection |
getUpper()
If this instance represents multiple address components, returns the one with the highest numeric value.
|
boolean |
isEntireAddress(boolean extended) |
boolean |
isEUI64(boolean asMAC)
Equivalent to isEUI64(asMAC, false)
|
boolean |
isEUI64(boolean asMAC,
boolean partial)
Whether this section is consistent with an EUI64 section,
which means it came from an extended 8 byte address,
and the corresponding segments in the middle match 0xff and 0xff/fe for MAC/not-MAC
|
boolean |
isExtended() |
boolean |
isMultipleByPrefix()
whether there is a prefix and it is less than the bit-count
|
boolean |
isPrefixed()
Indicates if the address represents all devices with the same OUI segments.
|
java.util.Iterator<MACAddressSection> |
iterator()
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.
|
MACAddressSection |
prepend(MACAddressSection other) |
MACAddressSection |
removePrefixLength()
Removes the prefix.
|
MACAddressSection |
replace(MACAddressSection other,
int index) |
MACAddressSection |
reverseBits(boolean perByte)
Returns a new segment series with the bits reversed.
|
MACAddressSection |
reverseBytes()
Returns a new segment series with the bytes reversed.
|
MACAddressSection |
reverseBytesPerSegment()
Returns a new segment series with the bytes reversed within each segment.
|
MACAddressSection |
reverseSegments()
Returns a new segment series with the segments reversed.
|
java.util.Iterator<MACAddressSegment[]> |
segmentsIterator() |
MACAddressSection |
setPrefixLength(int networkPrefixLength)
Sets the prefix length.
|
java.lang.String |
toCanonicalString()
This produces a canonical string using the canonical standardized IEEE 802 MAC address representation of xx-xx-xx-xx-xx-xx
For range segments, '..' is used: 11-22-33..44-55-66
|
java.lang.String |
toColonDelimitedString() |
java.lang.String |
toCompressedString()
This produces a shorter string for the address that uses the canonical representation but not using leading zeroes.
|
java.lang.String |
toDashedString() |
java.lang.String |
toDottedString()
This produces the dotted hexadecimal format aaaa.bbbb.cccc
|
MACAddressSection |
toEUI64(boolean asMAC)
If this section is part of a shorter 48 bit MAC or EUI-48 address see
isExtended() ,
then the required sections are inserted (FF-FF for MAC, FF-FE for EUI-48) to extend it to EUI-64. |
IPv6AddressSection |
toEUI64IPv6() |
java.lang.String |
toHexString(boolean with0xPrefix)
Writes this address as a single hexadecimal value with always the exact same number of characters, with or without a preceding 0x prefix.
|
java.lang.String |
toNormalizedString()
The normalized string returned by this method is the most common representation of MAC addresses: xx:xx:xx:xx:xx:xx
|
java.lang.String |
toNormalizedString(AddressDivisionGrouping.StringOptions stringOptions) |
static java.lang.String |
toNormalizedString(AddressDivisionGrouping.StringOptions opts,
AddressDivisionGrouping section) |
MACAddressSection |
toOUIPrefixed() |
java.lang.String |
toSpaceDelimitedString()
This produces a string delimited by spaces: aa bb cc dd ee ff
|
java.lang.String |
toString() |
compareTo, getBytes, getBytes, getCount, getDivision, getDivisionCount, getEquivalentPrefix, getMinPrefix, getUpperBytes, getUpperBytes, hashCode, isFullRange, isMore, isMultiple, isRangeEquivalent, isRangeEquivalentToPrefix, isZero
getDivision, getEquivalentPrefix, getMinPrefix, isMore, isRangeEquivalentToPrefix
getDivisionCount
getBytes, getBytes, getCount, getUpperBytes, getUpperBytes, isFullRange, isMultiple, isZero
public MACAddressSection(MACAddressSegment segment)
segment
- public MACAddressSection(MACAddressSegment segment, int startIndex, boolean extended)
segment
- public MACAddressSection(MACAddressSegment[] segments)
public MACAddressSection(MACAddressSegment[] segments, int startIndex, boolean extended)
public MACAddressSection(MACAddressSegment[] segments, java.lang.Integer prefixLength)
public MACAddressSection(MACAddressSegment[] segments, int startIndex, boolean extended, java.lang.Integer prefixLength)
public MACAddressSection(byte[] bytes, int startIndex, boolean extended, java.lang.Integer prefixLength)
public MACAddressSection(byte[] bytes, int startIndex, boolean extended)
public MACAddressSection(byte[] bytes, java.lang.Integer prefixLength)
public MACAddressSection(byte[] bytes)
public MACAddressSection(long value, int startIndex, boolean extended, java.lang.Integer prefixLength)
public MACAddressSection(long value, int startIndex, boolean extended)
public MACAddressSection(long value, java.lang.Integer prefixLength)
public MACAddressSection(long value)
public boolean equals(java.lang.Object o)
equals
in class AddressDivisionGrouping
public MACAddressSegment[] getSegments()
getSegments
in interface AddressSegmentSeries
public void getSegments(AddressSegment[] segs)
getSegments
in interface AddressSegmentSeries
public void getSegments(int start, int end, AddressSegment[] segs, int destIndex)
AddressSegmentSeries
getSegments
in interface AddressSegmentSeries
public boolean isExtended()
public int getSegmentCount()
getSegmentCount
in interface AddressSegmentSeries
public boolean isEntireAddress(boolean extended)
public MACAddressSegment getSegment(int index)
getSegment
in interface AddressSegmentSeries
public void getSegments(java.util.Collection<? super MACAddressSegment> segs)
public void getSegments(int start, int end, java.util.Collection<? super MACAddressSegment> segs)
public int getByteCount()
AddressComponent
getByteCount
in interface AddressComponent
public int getBitCount()
getBitCount
in interface AddressItem
getBitCount
in class AddressDivisionGrouping
public int getBitsPerSegment()
getBitsPerSegment
in interface AddressSegmentSeries
public int getBytesPerSegment()
getBytesPerSegment
in interface AddressSegmentSeries
public boolean isPrefixed()
isPrefixed
in interface AddressDivisionSeries
isPrefixed
in class AddressDivisionGrouping
public int getOUISegmentCount()
public int getODISegmentCount()
public java.lang.Integer getPrefixLength()
AddressDivisionSeries
getPrefixLength
in interface AddressDivisionSeries
getPrefixLength
in class AddressDivisionGrouping
public boolean isMultipleByPrefix()
AddressDivisionSeries
isMultipleByPrefix
in interface AddressDivisionSeries
isMultipleByPrefix
in class AddressDivisionGrouping
public MACAddressSection getSection(int index)
AddressSegmentSeries
getSection
in interface AddressSection
getSection
in interface AddressSegmentSeries
public MACAddressSection getSection(int index, int endIndex)
AddressSegmentSeries
getSection
in interface AddressSection
getSection
in interface AddressSegmentSeries
public MACAddressSection getOUISection()
public MACAddressSection getODISection()
public MACAddressSection toOUIPrefixed()
public IPv6AddressSection toEUI64IPv6()
public boolean isEUI64(boolean asMAC)
public boolean isEUI64(boolean asMAC, boolean partial)
partial
- whether missing segments are considered a match (this only has an effect if this section came from an extended 8 byte address),
or in other words, we don't consider 6 byte addresses to be "missing" the bytes that would make it 8 byte.asMAC
- whether to search for the ffff or fffe patternpublic MACAddressSection toEUI64(boolean asMAC)
isExtended()
,
then the required sections are inserted (FF-FF for MAC, FF-FE for EUI-48) to extend it to EUI-64.
However, if the section does not encompass the parts of the address where
the new sections should be placed, then the section is unchanged.
If the section is already part of an EUI-64 address, then it is checked
to see if it has the segments that identify it as extended to EUI-64 (FF-FF for MAC, FF-FE for EUI-48),
and if not, AddressTypeException is thrown.asMAC
- public MACAddressSection replace(MACAddressSection other, int index)
public MACAddressSection prepend(MACAddressSection other)
public MACAddressSection append(MACAddressSection other)
public boolean contains(MACAddressSection other)
other
- public MACAddressSection getLower()
AddressComponent
getLower
in interface AddressComponent
getLower
in interface AddressSection
getLower
in interface AddressSegmentSeries
public MACAddressSection getUpper()
AddressComponent
getUpper
in interface AddressComponent
getUpper
in interface AddressSection
getUpper
in interface AddressSegmentSeries
public MACAddressSection reverseBits(boolean perByte)
AddressSegmentSeries
reverseBits
in interface AddressComponent
reverseBits
in interface AddressSection
reverseBits
in interface AddressSegmentSeries
perByte
- if true, only the bits in each byte are reversed, if false, then all bits in the component are reversedpublic MACAddressSection reverseBytes()
AddressSegmentSeries
reverseBytes
in interface AddressComponent
reverseBytes
in interface AddressSection
reverseBytes
in interface AddressSegmentSeries
public MACAddressSection reverseBytesPerSegment()
AddressSegmentSeries
reverseBytesPerSegment
in interface AddressSection
reverseBytesPerSegment
in interface AddressSegmentSeries
public MACAddressSection reverseSegments()
AddressSegmentSeries
reverseSegments
in interface AddressSection
reverseSegments
in interface AddressSegmentSeries
public MACAddressSection removePrefixLength()
AddressSegmentSeries
removePrefixLength
in interface AddressSection
removePrefixLength
in interface AddressSegmentSeries
public MACAddressSection adjustPrefixBySegment(boolean nextSegment)
AddressSegmentSeries
adjustPrefixBySegment
in interface AddressSection
adjustPrefixBySegment
in interface AddressSegmentSeries
public MACAddressSection adjustPrefixLength(int adjustment)
AddressSegmentSeries
adjustPrefixLength
in interface AddressSection
adjustPrefixLength
in interface AddressSegmentSeries
public MACAddressSection applyPrefixLength(int prefixLength)
AddressSegmentSeries
applyPrefixLength
in interface AddressSection
applyPrefixLength
in interface AddressSegmentSeries
public MACAddressSection setPrefixLength(int networkPrefixLength)
AddressSegmentSeries
setPrefixLength
in interface AddressSection
setPrefixLength
in interface AddressSegmentSeries
public java.lang.Iterable<MACAddressSection> getIterable()
AddressComponent
AddressComponent.iterator()
directly.getIterable
in interface AddressComponent
getIterable
in interface AddressSection
getIterable
in interface AddressSegmentSeries
public java.util.Iterator<MACAddressSection> iterator()
AddressComponent
AddressItem.isMultiple()
to determine if this instance represents multiple.
This method iterates through the individual elements.iterator
in interface AddressComponent
iterator
in interface AddressSection
iterator
in interface AddressSegmentSeries
iterator
in interface java.lang.Iterable<MACAddressSection>
public java.util.Iterator<MACAddressSegment[]> segmentsIterator()
segmentsIterator
in interface AddressSegmentSeries
public java.lang.String toHexString(boolean with0xPrefix)
toHexString
in interface AddressComponent
public java.lang.String toNormalizedString(AddressDivisionGrouping.StringOptions stringOptions)
public static java.lang.String toNormalizedString(AddressDivisionGrouping.StringOptions opts, AddressDivisionGrouping section)
public java.lang.String toNormalizedString()
toNormalizedString
in interface AddressComponent
public java.lang.String toCanonicalString()
toCanonicalString
in interface AddressSegmentSeries
public java.lang.String toCompressedString()
toCompressedString
in interface AddressSegmentSeries
public java.lang.String toDottedString()
public java.lang.String toSpaceDelimitedString()
public java.lang.String toDashedString()
public java.lang.String toColonDelimitedString()
public java.lang.String toString()
toString
in class AddressDivisionGrouping
public AddressDivisionGrouping getDottedGrouping()
public boolean contains(AddressSection other)
AddressSection
contains
in interface AddressSection