public class MACAddress extends Address implements java.lang.Iterable<MACAddress>
Address.SegmentValueProvider
Modifier and Type | Field and Description |
---|---|
static int |
BITS_PER_SEGMENT |
static int |
BYTES_PER_SEGMENT |
static char |
COLON_SEGMENT_SEPARATOR |
static char |
DASH_SEGMENT_SEPARATOR |
static char |
DASHED_SEGMENT_RANGE_SEPARATOR |
static java.lang.String |
DASHED_SEGMENT_RANGE_SEPARATOR_STR |
static int |
DEFAULT_TEXTUAL_RADIX |
static char |
DOTTED_SEGMENT_SEPARATOR |
static int |
EXTENDED_UNIQUE_IDENTIFIER_48_SEGMENT_COUNT |
static int |
EXTENDED_UNIQUE_IDENTIFIER_64_SEGMENT_COUNT |
static int |
MAX_VALUE_PER_DOTTED_SEGMENT |
static int |
MAX_VALUE_PER_SEGMENT |
static int |
MEDIA_ACCESS_CONTROL_DOTTED_64_SEGMENT_COUNT |
static int |
MEDIA_ACCESS_CONTROL_DOTTED_BITS_PER_SEGMENT |
static int |
MEDIA_ACCESS_CONTROL_DOTTED_SEGMENT_COUNT |
static int |
MEDIA_ACCESS_CONTROL_SEGMENT_COUNT |
static int |
MEDIA_ACCESS_CONTROL_SINGLE_DASHED_SEGMENT_COUNT |
static int |
ORGANIZATIONAL_UNIQUE_IDENTIFIER_BIT_COUNT |
static int |
ORGANIZATIONAL_UNIQUE_IDENTIFIER_SEGMENT_COUNT |
static char |
SPACE_SEGMENT_SEPARATOR |
addressComparator, ALTERNATIVE_RANGE_SEPARATOR, ALTERNATIVE_RANGE_SEPARATOR_STR, ALTERNATIVE_SEGMENT_WILDCARD_STR, HEX_PREFIX, OCTAL_PREFIX, RANGE_SEPARATOR, RANGE_SEPARATOR_STR, SEGMENT_SQL_SINGLE_WILDCARD, SEGMENT_SQL_SINGLE_WILDCARD_STR, SEGMENT_SQL_WILDCARD, SEGMENT_SQL_WILDCARD_STR, SEGMENT_WILDCARD, SEGMENT_WILDCARD_STR
Constructor and Description |
---|
MACAddress(Address.SegmentValueProvider lowerValueProvider,
Address.SegmentValueProvider upperValueProvider)
Constructs a MAC address
|
MACAddress(Address.SegmentValueProvider lowerValueProvider,
Address.SegmentValueProvider upperValueProvider,
boolean extended)
Constructs a MAC address
|
MACAddress(Address.SegmentValueProvider lowerValueProvider,
Address.SegmentValueProvider upperValueProvider,
boolean extended,
java.lang.Integer prefixLength)
Constructs a MAC address
|
MACAddress(Address.SegmentValueProvider lowerValueProvider,
Address.SegmentValueProvider upperValueProvider,
java.lang.Integer prefixLength)
Constructs a MAC address
|
MACAddress(byte[] bytes)
Constructs a MAC address.
|
MACAddress(byte[] bytes,
java.lang.Integer prefixLength)
Constructs a MAC address.
|
MACAddress(long address)
Constructs a MAC address.
|
MACAddress(long address,
boolean extended)
Constructs a MAC address.
|
MACAddress(long address,
boolean extended,
java.lang.Integer prefixLength)
Constructs a MAC address.
|
MACAddress(long address,
java.lang.Integer prefixLength)
Constructs a MAC address.
|
MACAddress(MACAddressSection section)
Constructs a MAC address.
|
MACAddress(MACAddressSegment[] segments)
Constructs a MAC address.
|
MACAddress(MACAddressSegment[] segments,
java.lang.Integer prefixLength)
Constructs a MAC address.
|
Modifier and Type | Method and Description |
---|---|
MACAddress |
adjustPrefixBySegment(boolean nextSegment)
Increases or decreases prefix length to the next segment boundary.
|
MACAddress |
adjustPrefixLength(int adjustment)
Increases or decreases prefix length by the given increment.
|
MACAddress |
applyPrefixLength(int networkPrefixLength)
Applies the given prefix length to create a new segment series representing all segment series starting with the same prefix.
|
boolean |
contains(Address other) |
boolean |
contains(MACAddress other) |
static MACAddressNetwork.MACAddressCreator |
getAddressCreator() |
int |
getBitCount() |
int |
getBitsPerSegment() |
int |
getByteCount()
returns the number of bytes in each of the address components represented by this instance
|
int |
getBytesPerSegment() |
AddressDivisionGrouping |
getDottedAddress() |
java.lang.Iterable<MACAddress> |
getIterable()
Useful for using an instance in a "for-each loop".
|
MACAddress |
getLower()
If this instance represents multiple address components, returns the one with the lowest numeric value.
|
int |
getMaxSegmentValue() |
MACAddressSection |
getODISection() |
MACAddressSection |
getOUISection() |
MACAddressSection |
getSection() |
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) |
MACAddressSegment[] |
getSegments() |
MACAddress |
getUpper()
If this instance represents multiple address components, returns the one with the highest numeric value.
|
boolean |
isAllAddresses() |
boolean |
isEUI64(boolean asMAC)
Whether this section is consistent with an IPv6 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 |
isLocal() |
boolean |
isMulticast() |
boolean |
isUniversal() |
java.util.Iterator<MACAddress> |
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.
|
static int |
maxSegmentValue() |
static MACAddressNetwork |
network() |
MACAddress |
removePrefixLength()
Removes the prefix.
|
MACAddress |
reverseBits(boolean perByte)
Use to produce:
"MSB format", "IBM format", "Token-Ring format", and "non-canonical form"
See RFC 2469 section 2
Also see https://en.wikipedia.org/wiki/MAC_address
|
MACAddress |
reverseBytes()
Returns a new segment series with the bytes reversed.
|
MACAddress |
reverseBytesPerSegment()
Returns a new segment series with the bytes reversed within each segment.
|
MACAddress |
reverseSegments()
Returns a new segment series with the segments reversed.
|
java.util.Iterator<MACAddressSegment[]> |
segmentsIterator() |
MACAddress |
setPrefixLength(int prefixLength)
Sets the prefix length.
|
MACAddressString |
toAddressString()
Returns a host identifier string representation for this address,
which will be validated already.
|
java.lang.String |
toColonDelimitedString() |
java.lang.String |
toDashedString() |
java.lang.String |
toDottedString() |
MACAddress |
toEUI64(boolean asMAC)
Convert to IPv6 EUI-64 section
http://standards.ieee.org/develop/regauth/tut/eui64.pdf
|
IPv6AddressSection |
toEUI64IPv6() |
IPv6Address |
toLinkLocalIPv6() |
java.lang.String |
toNormalizedString(AddressDivisionGrouping.StringOptions stringOptions) |
MACAddress |
toOUIPrefixed() |
java.lang.String |
toSpaceDelimitedString() |
compareTo, equals, getBytes, getBytes, getCount, getDivision, getDivisionCount, getEquivalentPrefix, getMinPrefix, getPrefixLength, getSegmentCount, getSegments, getSegments, getUpperBytes, getUpperBytes, hashCode, isFullRange, isMore, isMultiple, isMultipleByPrefix, isPrefixed, isRangeEquivalentToPrefix, isSameAddress, isZero, toCanonicalString, toCompressedString, toHexString, toNormalizedString, toString
public static final char COLON_SEGMENT_SEPARATOR
public static final char DASH_SEGMENT_SEPARATOR
public static final char SPACE_SEGMENT_SEPARATOR
public static final char DOTTED_SEGMENT_SEPARATOR
public static final char DASHED_SEGMENT_RANGE_SEPARATOR
public static final java.lang.String DASHED_SEGMENT_RANGE_SEPARATOR_STR
public static final int BITS_PER_SEGMENT
public static final int BYTES_PER_SEGMENT
public static final int MEDIA_ACCESS_CONTROL_SEGMENT_COUNT
public static final int MEDIA_ACCESS_CONTROL_DOTTED_SEGMENT_COUNT
public static final int MEDIA_ACCESS_CONTROL_DOTTED_64_SEGMENT_COUNT
public static final int MEDIA_ACCESS_CONTROL_DOTTED_BITS_PER_SEGMENT
public static final int MEDIA_ACCESS_CONTROL_SINGLE_DASHED_SEGMENT_COUNT
public static final int EXTENDED_UNIQUE_IDENTIFIER_48_SEGMENT_COUNT
public static final int EXTENDED_UNIQUE_IDENTIFIER_64_SEGMENT_COUNT
public static final int DEFAULT_TEXTUAL_RADIX
public static final int MAX_VALUE_PER_SEGMENT
public static final int MAX_VALUE_PER_DOTTED_SEGMENT
public static final int ORGANIZATIONAL_UNIQUE_IDENTIFIER_SEGMENT_COUNT
public static final int ORGANIZATIONAL_UNIQUE_IDENTIFIER_BIT_COUNT
public MACAddress(MACAddressSegment[] segments)
segments
- the address segmentspublic MACAddress(MACAddressSegment[] segments, java.lang.Integer prefixLength)
segments
- the address segmentspublic MACAddress(MACAddressSection section)
section
- the address segmentspublic MACAddress(long address)
public MACAddress(long address, boolean extended)
public MACAddress(long address, java.lang.Integer prefixLength)
public MACAddress(long address, boolean extended, java.lang.Integer prefixLength)
address
- the bytesprefixLength
- the length for which the address represents all addresses with the same prefix identifier such as the 24 bit Organizational Unique Identifier (OUI)extended
- if true, treated as an 8-byte EUI-64 address, otherwise treated as a 6-byte MAC or EUI-48public MACAddress(byte[] bytes)
public MACAddress(byte[] bytes, java.lang.Integer prefixLength)
public MACAddress(Address.SegmentValueProvider lowerValueProvider, Address.SegmentValueProvider upperValueProvider, boolean extended, java.lang.Integer prefixLength)
lowerValueProvider
- supplies the 1 byte lower values for each segmentupperValueProvider
- supplies the 1 byte upper values for each segmentpublic MACAddress(Address.SegmentValueProvider lowerValueProvider, Address.SegmentValueProvider upperValueProvider, java.lang.Integer prefixLength)
lowerValueProvider
- supplies the 1 byte lower values for each segmentupperValueProvider
- supplies the 1 byte upper values for each segmentpublic MACAddress(Address.SegmentValueProvider lowerValueProvider, Address.SegmentValueProvider upperValueProvider, boolean extended)
lowerValueProvider
- supplies the 1 byte lower values for each segmentupperValueProvider
- supplies the 1 byte upper values for each segmentpublic MACAddress(Address.SegmentValueProvider lowerValueProvider, Address.SegmentValueProvider upperValueProvider)
lowerValueProvider
- supplies the 1 byte lower values for each segmentupperValueProvider
- supplies the 1 byte upper values for each segmentpublic static MACAddressNetwork network()
public static MACAddressNetwork.MACAddressCreator getAddressCreator()
public boolean isExtended()
public boolean isAllAddresses()
public MACAddressSection getSection()
getSection
in class Address
public MACAddressSegment getSegment(int index)
getSegment
in interface AddressSegmentSeries
getSegment
in class Address
public MACAddressSegment[] getSegments()
getSegments
in interface AddressSegmentSeries
getSegments
in class Address
public static int maxSegmentValue()
public int getMaxSegmentValue()
getMaxSegmentValue
in class Address
public int getByteCount()
AddressComponent
getByteCount
in interface AddressComponent
getByteCount
in class Address
public int getBitCount()
getBitCount
in interface AddressItem
getBitCount
in class Address
public int getBytesPerSegment()
getBytesPerSegment
in interface AddressSegmentSeries
public int getBitsPerSegment()
getBitsPerSegment
in interface AddressSegmentSeries
public boolean contains(MACAddress other)
other
- public java.lang.Iterable<MACAddress> getIterable()
AddressComponent
AddressComponent.iterator()
directly.getIterable
in interface AddressComponent
getIterable
in interface AddressSegmentSeries
getIterable
in class Address
public java.util.Iterator<MACAddress> 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 AddressSegmentSeries
iterator
in interface java.lang.Iterable<MACAddress>
iterator
in class Address
public java.util.Iterator<MACAddressSegment[]> segmentsIterator()
segmentsIterator
in interface AddressSegmentSeries
segmentsIterator
in class Address
public MACAddress getLower()
AddressComponent
getLower
in interface AddressComponent
getLower
in interface AddressSegmentSeries
getLower
in class Address
public MACAddress getUpper()
AddressComponent
getUpper
in interface AddressComponent
getUpper
in interface AddressSegmentSeries
getUpper
in class Address
public MACAddress reverseBits(boolean perByte)
reverseBits
in interface AddressComponent
reverseBits
in interface AddressSegmentSeries
reverseBits
in class Address
perByte
- if true, only the bits in each byte are reversed, if false, then all bits in the component are reversedpublic MACAddress reverseBytes()
AddressSegmentSeries
reverseBytes
in interface AddressComponent
reverseBytes
in interface AddressSegmentSeries
reverseBytes
in class Address
public MACAddress reverseBytesPerSegment()
AddressSegmentSeries
reverseBytesPerSegment
in interface AddressSegmentSeries
reverseBytesPerSegment
in class Address
public MACAddress reverseSegments()
AddressSegmentSeries
reverseSegments
in interface AddressSegmentSeries
reverseSegments
in class Address
public MACAddress removePrefixLength()
AddressSegmentSeries
removePrefixLength
in interface AddressSegmentSeries
removePrefixLength
in class Address
public MACAddress applyPrefixLength(int networkPrefixLength)
AddressSegmentSeries
applyPrefixLength
in interface AddressSegmentSeries
applyPrefixLength
in class Address
public MACAddress adjustPrefixBySegment(boolean nextSegment)
AddressSegmentSeries
adjustPrefixBySegment
in interface AddressSegmentSeries
adjustPrefixBySegment
in class Address
public MACAddress adjustPrefixLength(int adjustment)
AddressSegmentSeries
adjustPrefixLength
in interface AddressSegmentSeries
adjustPrefixLength
in class Address
public MACAddress setPrefixLength(int prefixLength)
AddressSegmentSeries
setPrefixLength
in interface AddressSegmentSeries
setPrefixLength
in class Address
public MACAddressSection getSection(int index)
AddressSegmentSeries
getSection
in interface AddressSegmentSeries
getSection
in class Address
public MACAddressSection getSection(int index, int endIndex)
AddressSegmentSeries
getSection
in interface AddressSegmentSeries
getSection
in class Address
public MACAddressSection getODISection()
public MACAddressSection getOUISection()
public MACAddress toOUIPrefixed()
public IPv6Address toLinkLocalIPv6()
public IPv6AddressSection toEUI64IPv6()
public boolean isEUI64(boolean asMAC)
asMAC
- public MACAddress toEUI64(boolean asMAC)
asMAC
- if true, this address is considered MAC and the EUI-64 is extended using ff-ff, otherwise this address is considered EUI-48 and extended using ff-fe
Note that IPv6 treats MAC as EUI-48 and extends MAC to IPv6 addresses using ff-fepublic AddressDivisionGrouping getDottedAddress()
public MACAddressString toAddressString()
Address
toAddressString
in class Address
public java.lang.String toNormalizedString(AddressDivisionGrouping.StringOptions stringOptions)
public java.lang.String toDottedString()
public java.lang.String toDashedString()
public java.lang.String toColonDelimitedString()
public java.lang.String toSpaceDelimitedString()
public boolean isMulticast()
isMulticast
in class Address
InetAddress.isMulticastAddress()
public boolean isUniversal()